示例#1
0
    public void ConfirmMovement()
    {
        UiController ui = FindObjectOfType <UiController>();

        ui.dpsAbility = false;
        Character character = player[turno].GetComponent <Character>();

        grid.ResetWalkableCell();
        character.isMovible = false;
        grid.cells[(int)character.pos.x, (int)character.pos.y].isOccupied = true;
        grid.cells[(int)character.pos.x, (int)character.pos.y].occupier   = character.gameObject;
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Joystick1Button1))
        {
            switch (faseUi)
            {
            case 1:
            {
                faseUi = 0;
                Character character = cc.player[cc.turno].GetComponent <Character>();
                character.PlayerMove(startPos);
                MainPanel.SetActive(true);
                BattleGrid grid = FindObjectOfType <BattleGrid>();
                grid.ResetWalkableCell();
                character.isMovible = false;
                grid.cells[(int)startPos.x, (int)startPos.y].isOccupied = true;
                grid.cells[(int)startPos.x, (int)startPos.y].occupier   = character.gameObject;
                //MoveButton.Select();
                break;
            }

            case 2:
            {
                faseUi = 0;

                foreach (Transform item in EnemyListPanel.transform)
                {
                    Destroy(item.gameObject);
                }
                MainPanel.SetActive(true);
                if (MoveButton.IsInteractable())
                {
                    MoveButton.Select();
                }
                else
                {
                    Button buttonAction = MainPanel.transform.Find("Action").GetComponent <Button>();
                    buttonAction.Select();
                }
                ActionPanel.SetActive(false);
                UiController ui = FindObjectOfType <UiController>();

                Text textVita = enemyInfoPanel.transform.Find("HealthText").GetComponent <Text>();
                textVita.text = "";
                Text textNome = enemyInfoPanel.transform.Find("NomeNemico").GetComponent <Text>();
                textNome.text = "";
                Image vita = enemyInfoPanel.transform.Find("Health").GetComponent <Image>();
                vita.color = new Color(vita.color.r, vita.color.g, vita.color.b, 0);
                Image BaseHealth = enemyInfoPanel.transform.Find("BaseHealth").GetComponent <Image>();
                BaseHealth.color = new Color(BaseHealth.color.r, BaseHealth.color.g, BaseHealth.color.b, 0);
                enemyInfoPanel.transform.Find("Poison").gameObject.SetActive(false);
                enemyInfoPanel.transform.Find("Att").gameObject.SetActive(false);
                enemyInfoPanel.transform.Find("Dif").gameObject.SetActive(false);
                ui.EnemyListPanel.SetActive(false);
                GameObject target = GameObject.FindGameObjectWithTag("Target");
                Destroy(target);
                break;
            }

            case 3:
            {
                faseUi = 2;
                foreach (var item in attackBoxList)
                {
                    Destroy(item);
                }
                foreach (Transform item in EnemyListPanel.transform)
                {
                    Destroy(item.gameObject);
                }
                foreach (var item in buffBoxList)
                {
                    Destroy(item);
                }
                buffBoxList.Clear();
                attackBoxList.Clear();
                ActionPanel.SetActive(true);
                activeAbilityPanel.SetActive(false);
                Player player = cc.player[cc.turno].GetComponent <Player>();
                player.CheckAttack();
                if (player.enemyDisp.Count == 0)
                {
                    Button buttonAttack = ActionPanel.transform.Find("Attack").GetComponent <Button>();
                    buttonAttack.interactable = false;
                    Button buttonAbility = ActionPanel.transform.Find("Ability").GetComponent <Button>();
                    buttonAbility.Select();
                }
                else
                {
                    Button buttonAttack = ActionPanel.transform.Find("Attack").GetComponent <Button>();
                    buttonAttack.interactable = true;
                    buttonAttack.Select();
                }
                break;
            }

            case 4:
            {
                Text textVita = enemyInfoPanel.transform.Find("HealthText").GetComponent <Text>();
                textVita.text = "";
                Text textNome = enemyInfoPanel.transform.Find("NomeNemico").GetComponent <Text>();
                textNome.text = "";
                Image vita = enemyInfoPanel.transform.Find("Health").GetComponent <Image>();
                vita.enabled = false;
                enemyInfoPanel.transform.Find("Poison").gameObject.SetActive(false);
                enemyInfoPanel.transform.Find("Att").gameObject.SetActive(false);
                enemyInfoPanel.transform.Find("Dif").gameObject.SetActive(false);

                GameObject[] frecce = GameObject.FindGameObjectsWithTag("Target");

                foreach (var item in frecce)
                {
                    Destroy(item);
                }

                foreach (Transform item in EnemyListPanel.transform)
                {
                    Destroy(item.gameObject);
                }

                faseUi = 2;
                foreach (var item in attackBoxList)
                {
                    Destroy(item);
                }
                attackBoxList.Clear();
                foreach (var item in buffBoxList)
                {
                    Destroy(item);
                }
                buffBoxList.Clear();
                ActionPanel.SetActive(true);
                Player player = cc.player[cc.turno].GetComponent <Player>();
                player.CheckAttack();
                foreach (var item in player.checkboxAttack)
                {
                    Destroy(item);
                }
                if (player.enemyDisp.Count == 0)
                {
                    Button buttonAttack = ActionPanel.transform.Find("Attack").GetComponent <Button>();
                    buttonAttack.interactable = false;
                    Button buttonAbility = ActionPanel.transform.Find("Ability").GetComponent <Button>();
                    buttonAbility.Select();
                }
                else
                {
                    Button buttonAttack = ActionPanel.transform.Find("Attack").GetComponent <Button>();
                    buttonAttack.interactable = true;
                    buttonAttack.Select();
                }
                break;
            }

            case 5:
            {
                faseUi = 3;
                foreach (var item in attackBoxList)
                {
                    Destroy(item);
                }
                attackBoxList.Clear();
                ActionPanel.SetActive(true);
                Player player = cc.player[cc.turno].GetComponent <Player>();
                player.CheckAttack();
                foreach (var item in player.checkboxAttack)
                {
                    Destroy(item);
                }
                break;
            }
            }
        }
        if ((Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Joystick1Button0)) && faseUi == 1 && waitMovement)
        {
            if (dpsAbility)
            {
                cc.ConfirmMovement();
                // Suono
                AudioSource audio = GameObject.Find("SoundManager").GetComponent <AudioSource>();
                audio.PlayOneShot(audioMovimentoDps);
                faseUi = 0;
                Button actionButton = MainPanel.transform.Find("Action").GetComponent <Button>();
                actionButton.interactable = false;
                MainPanel.SetActive(true);
                SetUiToPlayer(cc.player[cc.turno]);
                foreach (Transform item in MainPanel.transform)
                {
                    if (item.gameObject.GetComponent <Button>().IsInteractable())
                    {
                        item.gameObject.GetComponent <Button>().Select();
                        break;
                    }
                }
            }
            else
            {
                cc.ConfirmMovement();
                faseUi = 0;
                MoveButton.interactable = false;
                MainPanel.SetActive(true);
                SetUiToPlayer(cc.player[cc.turno]);
            }
        }
    }