// Update is called once per frame void Update() { bool advanceState = false; bool advanceTurn = false; // graph.DebugDraw (); if (Input.GetKeyDown(KeyCode.Space)) { advanceTurn = true; } if (Input.GetKeyDown(KeyCode.R)) { Reset(); } if (Input.GetKeyDown(KeyCode.S)) { gameStep++; if (gameStep == 4) { gameStep = 1; } } if (cityPopupText == null) { cityPopupText = GameObject.Find("CityPopupText"); } if (currentState != State.BuildCities) { cityPopupText.transform.position = new Vector3(100, 100, 100); //offscreen } if (currentState != State.BuyMaterials) { materialShopPopup.transform.localPosition = new Vector3(-2.0f, 0.3f, -0.05f); } // cityPopupText.transform.position = new Vector3(100,100,100);//offscreen switch (currentState) { case State.ComputeTurn: // print (currentState); players.Sort(); players.Reverse(); //set piece colors for (int i = 0; i < players.Count; i++) { ((GameObject)playerOrderPieces [i]).GetComponent <Renderer> ().material.color = ((Player)players[i]).color; } currentState = State.BuyPlants; powerplantShop.Show(true); playerTurn = 0; break; case State.BuyPlants: //show plants //click on plant or pass //adjust price //click on player that buys //redraw //move plant shop into place if (advanceTurn) { playerTurn++; if (playerTurn == players.Count) { advanceState = true; playerTurn = players.Count - 1; powerplantShop.Show(false); } } if (advanceState) { powerplantShop.DealCards(); currentState = State.BuyMaterials; // print (currentState); } break; case State.BuyMaterials: //show each player's power plants //show market //allow buying into each plant by clicking materialShopPopup.transform.localPosition = new Vector3(-0.4f, 0.3f, -0.05f); if (advanceTurn) { playerTurn--; if (playerTurn == -1) { advanceState = true; playerTurn = players.Count - 1; } } if (advanceState) { currentState = State.BuildCities; RecomputeTravelCosts(); // print (currentState); } break; case State.BuildCities: //hovering over city to shows cost (compute cost by searching over graph) if (advanceTurn) { CommitCityPurchases(); playerTurn--; if (playerTurn == -1) { advanceState = true; playerTurn = 0; } else { RecomputeTravelCosts(); } } if (advanceState) { currentState = State.Bureaucracy; CommitCityPurchases(); } break; case State.Bureaucracy: // print (currentState); DoBureaucracy(); materialStore.Restock(players.Count, gameStep); currentState = State.ComputeTurn; gameRound++; break; } int index = 0; for (int i = 0; i < players.Count; i++) { GameObject playerOrderPiece = ((GameObject)playerOrderPieces [i]); Vector3 pos = playerOrderPiece.transform.position; Quaternion rot = Quaternion.identity; if (i == playerTurn) { pos.y = 0.0f + 0.1f * (1.0f + Mathf.Sin(5 * UnityEngine.Time.realtimeSinceStartup)); rot = Quaternion.Euler(0, 120 * UnityEngine.Time.realtimeSinceStartup, 0); } else { pos.y = 0.0f; } playerOrderPiece.transform.position = pos; playerOrderPiece.transform.rotation = rot; } }