Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by swartak · May 28, 2014 at 08:22 PM · integerboardgamearray list

Trouble with array int board game

Hi I'm new to unity and I'm making "monopoly" style board game and I've trying to figure out how to use this array properly for days. What I want is for an event to be triggered after the dice is rolled so that the tile the player needs to go to becomes active. The hard part for me though is setting the value of oldsquare. I have it showing (oldsquare + whatever the play rolled) How would I set the value for oldsquare to the new square?

using UnityEngine; using System.Collections; using System.Collections.Generic; public class PlayerScript : MonoBehaviour { public GuiPanels Numberbox; public int GotoTile = 1; public List<int> TileList; private float distance; public int roll; public int currentSquare; public int numSquaresToMove; public GameObject player1; public GuiPanels count1; public GuiPanels count2; public GuiPanels count3; public GuiPanels count4; public GuiPanels count5; public GuiPanels count6; private GuiPanels rolled; public float totalNumberOfSquares; public int oldsquare; // Use this for initialization void Start () { TileList = new List<int>(); TileList.Add(29); TileList[0] = 0; TileList[1] = 1; TileList[2] = 2; TileList[3] = 3; TileList[4] = 4; TileList[5] = 5; TileList[6] = 6; TileList[7] = 7; TileList[8] = 8; TileList[9] = 9; TileList[10] = 10; TileList[11] = 11; TileList[12] = 11; TileList[13] = 12; TileList[14] = 14; TileList[15] = 15; TileList[16] = 16; TileList[17] = 17; TileList[18] = 18; TileList[19] = 19; TileList[20] = 20; TileList[21] = 21; TileList[22] = 22; TileList[23] = 23; TileList[24] = 24; TileList[25] = 25; TileList[26] = 26; TileList[27] = 27; TileList[28] = 28; TileList[29] = 29; oldsquare = 0; //currentSquare = 0; player1 = GameObject.FindGameObjectWithTag ("Player"); for (int i = 0; i < 30; i++){ if (count1 == true) { currentSquare = TileList[oldsquare + 1]; } if (count2 == true) { currentSquare = TileList[oldsquare + 2]; } if (count3 == true) { currentSquare = TileList[oldsquare + 3]; } if (count4 == true) { currentSquare = TileList[oldsquare + 4]; } if (count5 == true) { currentSquare = TileList[oldsquare + 5]; } if (count6 == true) { currentSquare = TileList[oldsquare + 6]; } // (currentSquare + 1) % 30; } } // Update is called once per frame void Update () { Numberbox = GetComponent<GuiPanels>(); if (Numberbox == true) { count1 = GetComponent<GuiPanels> (); count2 = GetComponent<GuiPanels> (); count3 = GetComponent<GuiPanels> (); count4 = GetComponent<GuiPanels> (); count5 = GetComponent<GuiPanels> (); count6 = GetComponent<GuiPanels> (); rolled = GetComponent<GuiPanels> (); } } }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help with basic magic system 0 Answers

if statements is not working properly 1 Answer

if statement for 6 ints help C# 2 Answers

How do I increase an integer?? 3 Answers

How do I get my project to sense when an integer has gone up by a certain amount? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges