Пример #1
0
 private void removeAttack(int location)
 {
     if (attacks.Count > 0)
     {
         UIChoosable toBeRemovedAttack = attacks[location];
         ApUsed -= toBeRemovedAttack.getApCost();
         attacks.RemoveAt(location);
         GameObject attackBarUI = AttackBars[location];
         AttackBars.RemoveAt(location);
         Destroy(attackBarUI);
     }
 }
Пример #2
0
 public void AddAttack(UIChoosable attack)
 {
     if (ApUsed < MaxAp && (ApUsed + attack.getApCost()) <= MaxAp)
     {
         GameObject    attackBarUI = Instantiate(AttackBar, this.transform);
         RectTransform attackBarRT = attackBarUI.GetComponent <RectTransform>();
         attackBarRT.anchoredPosition = CalcLocation(ApUsed, attack.getApCost());
         AttackBars.Add(attackBarUI);
         attackBarUI.GetComponent <Text>().text = attack.getName();
         attackBarRT.sizeDelta = new Vector2(attackBarRT.rect.width * attack.getApCost(), attackBarRT.rect.height);
         attacks.Add(attack);
         ApUsed += attack.getApCost();
     }
 }
Пример #3
0
    public void RemoveFirstAttack()
    {
        removeAttack(0);
        int x      = 0;
        int apUsed = 0;

        foreach (GameObject attackBarUI in AttackBars)
        {
            UIChoosable   attack      = attacks[x];
            RectTransform attackBarRT = attackBarUI.GetComponent <RectTransform>();
            attackBarRT.anchoredPosition = CalcLocation(apUsed, attack.getApCost());
            apUsed += attack.getApCost();
            x++;
        }
    }
Пример #4
0
    private void checkControls(int PlayerNumber)
    {
        AttackPanelManager attackPanel = null;

        switch (PlayerNumber)
        {
        case 1:
            attackPanel = P1AttackPanel;
            break;

        case 2:
            attackPanel = P2AttackPanel;
            break;
        }

        if (attackPanel != null)
        {
            //Vertical movement
            if (Input.GetButtonDown("P" + PlayerNumber + "Vertical"))
            {
                int newPosition = 4;
                if (Input.GetAxis("P" + PlayerNumber + "Vertical") < 0)
                {
                    newPosition -= (newPosition * 2);
                }
                attackPanel.ChoiceChanged(newPosition);
            }

            //Horizontal movement
            if (Input.GetButtonDown("P" + PlayerNumber + "Horizontal"))
            {
                int newPosition = 1;
                if (Input.GetAxis("P" + PlayerNumber + "Horizontal") < 0)
                {
                    newPosition -= (newPosition * 2);
                }
                attackPanel.ChoiceChanged(newPosition);
            }

            //Choose controls
            if (Input.GetButtonDown("P" + PlayerNumber + "Choose"))
            {
                int choice = -1;
                switch (PlayerNumber)
                {
                case 1:
                    choice = P1AttackPanel.GetChoice();
                    if (choice != -1)
                    {
                        UIChoosable uiChoosable = null;
                        if (P1CharSelect)
                        {
                            if (player1.ToBeActiveCharacter == null)
                            {
                                uiChoosable = GetCharacterByChoice(choice);
                                player1.ToBeActiveCharacter = (Character)uiChoosable;
                                P1AttackPanel.showData(player1.ToBeActiveCharacter.GetAttacks());
                                P1CharSelect = false;
                            }
                        }
                        else
                        {
                            if (player1.ToBeActiveCharacter != null)
                            {
                                uiChoosable = GetAttackByChoice(player1.ToBeActiveCharacter, choice);
                            }
                            else
                            {
                                uiChoosable = GetAttackByChoice(player1.ActiveCharacter, choice);
                            }
                        }
                        if (uiChoosable != null)
                        {
                            P1AttackBarManager.AddAttack(uiChoosable);
                        }
                    }
                    break;

                case 2:
                    choice = P2AttackPanel.GetChoice();
                    if (choice != -1)
                    {
                        UIChoosable uiChoosable = null;
                        if (P2CharSelect)
                        {
                            if (player2.ToBeActiveCharacter == null)
                            {
                                uiChoosable = GetCharacterByChoice(choice);
                                player2.ToBeActiveCharacter = (Character)uiChoosable;
                                P2AttackPanel.showData(player2.ToBeActiveCharacter.GetAttacks());
                                P2CharSelect = false;
                            }
                        }
                        else
                        {
                            if (player2.ToBeActiveCharacter != null)
                            {
                                uiChoosable = GetAttackByChoice(player2.ToBeActiveCharacter, choice);
                            }
                            else
                            {
                                uiChoosable = GetAttackByChoice(player2.ActiveCharacter, choice);
                            }
                        }
                        if (uiChoosable != null)
                        {
                            P2AttackBarManager.AddAttack(uiChoosable);
                        }
                    }
                    break;
                }
            }

            //Release
            if (Input.GetButtonDown("P" + PlayerNumber + "Release"))
            {
                switch (PlayerNumber)
                {
                case 1:
                    if (!player1.isAttacking && player1.Charge >= 1)
                    {
                        StartCoroutine(P1Attack());
                    }
                    break;

                case 2:
                    if (!player2.isAttacking && player2.Charge >= 1)
                    {
                        StartCoroutine(P2Attack());
                    }
                    break;
                }
            }

            //Switch
            if (Input.GetButtonDown("P" + PlayerNumber + "Switch"))
            {
                switch (PlayerNumber)
                {
                case 1:
                    if (player1.ToBeActiveCharacter == null)
                    {
                        P1AttackPanel.showData(getListOfChooseAbleCharacters());
                        P1CharSelect = true;
                    }
                    break;

                case 2:
                    if (player2.ToBeActiveCharacter == null)
                    {
                        P2AttackPanel.showData(getListOfChooseAbleCharacters());
                        P2CharSelect = true;
                    }
                    break;
                }
            }
        }
    }