示例#1
0
    void Update()
    {
        // place the initial drones
        if (initialPlacementIsDone == false)
        {
            //  rollButton.interactable = false;
            //        Debug.Log(" started if sttement ");

            if (Input.GetMouseButtonUp(0))
            {
                initialPlacement.PlaceDrone(currentPlayer);
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                try
                {
                    Destroy(FindObjectOfType <StartupSettings>().gameObject);
                }
                catch (Exception e)
                {
                }
                SceneManager.LoadScene("MainMenu");
            }
        }

        if (!pausExcecution)
        {
            if (FindObjectOfType <CalculateLegalWarpDestination>().thisIsAQuantumLeap&& isDoneRolling == false)
            {
                diceRoller.Number();
            }
            //if (isDoneRolling == false) diceRoller.Number();


            if (initialPlacementIsDone == true && isDoneRolling == false) // time to roll the dice
            {
                CountActivePlayers();
                diceRoller.transform.GetChild(1).GetComponent <Image>().sprite = rollSprite;
                diceRoller.SetRollButtonColor();
                rollButton.interactable     = true;
                skipTurnButton.interactable = true;
                if (autoRollerIsEnabled && !isGameOver)
                {
                    diceRoller.Number();
                }
            }
            if (Input.GetKeyDown("enter"))
            {
                SkipTurn();
            }

            if (initialPlacementIsDone == true && isDoneRolling == true && isDoneMoving == false)
            {
                rollButton.interactable = false;
                //Debug.Log(" Time to selct ");
                //Select all drones so we can turn them off.

                HideThrottles();

                var allDrones = FindObjectsOfType <DroneLocation>();

                foreach (var drone in allDrones)
                {
                    if (drone.tag == currentPlayer.ToString())
                    {
                        drone.gameObject.layer = 10; // refenses to, selctable layer
                    }
                    else
                    {
                        drone.gameObject.layer = 11; // refenses to nonselctable layer
                    }
                }
            }

            if (initialPlacementIsDone == true && isDoneRolling == true && isDoneMoving == true && isGameOver == false)
            {
                var allDrones = FindObjectsOfType <DroneLocation>();

                foreach (var drone in allDrones)
                {
                    if (drone.tag == currentPlayer.ToString())
                    {
                        drone.gameObject.layer = 11; // refenses to, nonselctable layer
                    }
                }

                ThrottleBar[] allThrottleBars = userInterfaceCanvas.GetComponentsInChildren <ThrottleBar>(true);
                foreach (var throttleBar in allThrottleBars)
                {
                    throttleBar.gameObject.SetActive(false);
                }

                clickListener.ClearCurrentlySelected();
                clickListener.ClearLegalWarpDestinations();
                rollButton.interactable = false; // disables button. is here for now


                FindObjectOfType <BoosterPickUpGenerator>().chanceToSpawnBooster++;
                FindObjectOfType <BoosterPickUpGenerator>().CheckChanceToSpawnBooster();

                Debug.Log("chanceToSpawnBooster is now: " + FindObjectOfType <BoosterPickUpGenerator>().chanceToSpawnBooster);

                isDoneRolling = false;
                isDoneMoving  = false;

                Debug.Log("next turn");
                PassTurnToNextPlayer();
            }
        }
    }