Ejemplo n.º 1
0
    private bool BuildUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            GameManager.Instance.EnterCombatPhase();
            return(false);
        }

        if (player.GetButtonDown("Toggle Build Menu"))
        {
            buildScreenUp = !buildScreenUp;
            GameManager.Instance.requireCursor = buildScreenUp;

            buildMenu.SetActive(buildScreenUp);
            return(true);
        }

        if (buildScreenUp)
        {
            return(true);
        }

        if (player.GetButtonDown("Next Weapon/Tool") || player.GetButtonDown("Previous Weapon/Tool"))
        {
            destroyTool = !destroyTool;
            UpdateEffect();
            UpdateAnimator();
        }


        if (player.GetButtonDown("Build"))
        {
            if (destroyTool)
            {
                HexTile tile = EyeLaser.Instance.SelectedTile;

                if (tile)
                {
                    coins += Mathf.RoundToInt(tile.DestroyTower() * .85F);
                }
            }
            else
            {
                RadioSelect selection = RadioSelect.Controller.GetSelection("BuildMenu.SelectedTower");

                if (selection)
                {
                    Debug.Assert(selection.additionalData is TowerBase, "Selection data of " + selection + "is of wrong type: " + selection.additionalData?.GetType());

                    HexTile tile = EyeLaser.Instance.SelectedTile;

                    if (tile)
                    {
                        TowerBase tower = selection.additionalData as TowerBase;

                        if (coins >= tower.towerCost && tile.BuildTower(selection.additionalData as TowerBase))
                        {
                            coins -= tower.towerCost;
                        }
                    }
                }
            }
        }

        return(false);
    }