/*public void MoveCubeClass() { * cubeClass.active = true; * allCubes [cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.white; * cubeClass.Move (); * allCubes [cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.yellow; * } * * void MoveCube() { * int nextX = cubeClass.x; * int nextY = cubeClass.y; * if (cubeClass.targetX > cubeClass.x) { * nextX++; * } * else if (cubeClass.targetX < cubeClass.x) { * nextX--; * } * if (cubeClass.targetY > cubeClass.y) { * nextY++; * } * else if (cubeClass.targetY < cubeClass.y) { * nextY--; * } * // Set the old cube to black if it's the depot * if (checkActivity) { * allCubes[cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.red; * } * // otherwise, set the old cube to white * else { * allCubes[cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.white; * } * // Set the new cube to yellow if the airplane is still active * if (cubeClass.active) { * allCubes[nextX, nextY].GetComponent<Renderer>().material.color = Color.yellow; * } * // otherwise the airplane is deactive and red * else { * allCubes[nextX, nextY].GetComponent<Renderer>().material.color = Color.red; * } * // Update the airplane to be in the new location * cubeClass.x = nextX; * cubeClass.y = nextY; * * }*/ // Use this for initialization void Start() { timeToAct = turnLength; GameObject nextCube = (GameObject)Instantiate(nextCubePrefab, new Vector3(-7, 2, 0), Quaternion.identity); allCubes = new GameObject[gridWidth, gridHeight]; cubeClass = new CubeClass(); cubeClass.targetX = cubeClassStartX; cubeClass.targetY = cubeClassStartY; //NextCubeColor nextCube.GetComponent <Renderer> ().material.color = colors [Random.Range(0, 5)]; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { allCubes[x, y] = (GameObject)Instantiate(cubePrefab, new Vector3(x * 2 - 14, y * 2 - 8, 0), Quaternion.identity); } } //cubeClass.x = cubeClassStartX; //cubeClass.y = cubeClassStartY; }
void Start() { me = this.GetComponent <CubeClass>(); _pp.SubscribeToAckTopic(Packet.Input, HandleAcknowledge); }
/*public void MoveCubeClass() { cubeClass.active = true; allCubes [cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.white; cubeClass.Move (); allCubes [cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.yellow; } void MoveCube() { int nextX = cubeClass.x; int nextY = cubeClass.y; if (cubeClass.targetX > cubeClass.x) { nextX++; } else if (cubeClass.targetX < cubeClass.x) { nextX--; } if (cubeClass.targetY > cubeClass.y) { nextY++; } else if (cubeClass.targetY < cubeClass.y) { nextY--; } // Set the old cube to black if it's the depot if (checkActivity) { allCubes[cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.red; } // otherwise, set the old cube to white else { allCubes[cubeClass.x, cubeClass.y].GetComponent<Renderer>().material.color = Color.white; } // Set the new cube to yellow if the airplane is still active if (cubeClass.active) { allCubes[nextX, nextY].GetComponent<Renderer>().material.color = Color.yellow; } // otherwise the airplane is deactive and red else { allCubes[nextX, nextY].GetComponent<Renderer>().material.color = Color.red; } // Update the airplane to be in the new location cubeClass.x = nextX; cubeClass.y = nextY; }*/ // Use this for initialization void Start() { timeToAct = turnLength; GameObject nextCube = (GameObject) Instantiate(nextCubePrefab, new Vector3(-7,2,0), Quaternion.identity); allCubes = new GameObject[gridWidth, gridHeight]; cubeClass = new CubeClass(); cubeClass.targetX = cubeClassStartX; cubeClass.targetY = cubeClassStartY; //NextCubeColor nextCube.GetComponent<Renderer> ().material.color = colors [Random.Range (0, 5)]; for (int x = 0; x < gridWidth; x++) { for (int y = 0; y < gridHeight; y++) { allCubes[x,y] = (GameObject) Instantiate(cubePrefab, new Vector3(x*2 - 14, y*2 - 8,0), Quaternion.identity); } } //cubeClass.x = cubeClassStartX; //cubeClass.y = cubeClassStartY; }
public override void TrackObject(GameObject obj) { cubeClass = obj.GetComponent <CubeClass>(); }
public void Start() { this.rigidBody = GetComponent <Rigidbody>(); _pp.SubscribeToTopic(Packet.Input, HandleUpdate); me = this.GetComponent <CubeClass>(); }