Exemplo n.º 1
0
 //class constructor for creating a button
 public void Init(string _stringArg, BattleActions _actionArg, BaseChampion _championArg)
 {
     buttonInfo       = _stringArg;
     battleAction     = _actionArg;
     selectedChampion = _championArg;
     buttonCollider   = gameObject.GetComponent <BoxCollider2D>();
     buttonText       = gameObject.transform.GetChild(1).GetComponent <TextMeshPro>();
     buttonImage      = gameObject.transform.GetChild(0).GetComponent <Image>();
     buttonText.SetText(buttonInfo);
 }
Exemplo n.º 2
0
    public class Item : BattleActions { }                   //a subclass for using items in battle


    private IEnumerator WaitForTargetSelect(BaseChampion thisChampion, string nameOfAction)
    {
        if (thisChampion.GetComponent <PlayerChampion>() != null)
        {
            BattleGUI._battleGUI.SetBattleMessage(thisChampion.stats.championName + ", select a target to " + nameOfAction);
        }
        while (!thisChampion.targetConfirmed)
        {
            yield return(null);
        }
    }
Exemplo n.º 3
0
    //select a target for a champion
    public virtual void SelectTarget(BaseChampion targetArg)
    {
        //returns function if it is not this champion's current turn
        if (!currentTurn)
        {
            return;
        }

        targetChampion  = targetArg;
        targetConfirmed = true;
    }
Exemplo n.º 4
0
    //removes a defeated player or enemy from the battle
    public void RemoveFromBattle(BaseChampion removedChampion)
    {
        if (removedChampion.GetComponent <PlayerChampion>() != null)
        {
            playerCharacters.Remove(removedChampion.GetComponent <PlayerChampion>());
        }
        else if (removedChampion.GetComponent <BaseEnemyChampion>() != null)
        {
            enemyCharacters.Remove(removedChampion.GetComponent <BaseEnemyChampion>());
        }

        ShouldBattleContinue();
    }
Exemplo n.º 5
0
        public override IEnumerator AttemptAction(BaseChampion attackingChampion)
        {
            int          damageTaken = 0;
            BaseChampion defendingChampion;

            attackingChampion.targetConfirmed = false;
            yield return(StartCoroutine(WaitForTargetSelect(attackingChampion, "Attack")));

            defendingChampion = attackingChampion.targetChampion;
            BattleGUI._battleGUI.SetBattleMessage(attackingChampion.stats.championName + " is attacking " + defendingChampion.stats.championName);
            damageTaken = attackingChampion.stats.strength - (defendingChampion.stats.constitution / 10);
            if (defendingChampion.currentAction is BattleActions.Defend)
            {
                damageTaken = damageTaken / 4;
            }
            defendingChampion.TakeDamage(damageTaken);
            attackingChampion.actionTaken = true;
            yield return(null);
        }
Exemplo n.º 6
0
    //creates buttons for actions so a player to choose an action
    public void UpdateActionsAvailable(BaseChampion currentChampion)
    {
        //clear pre-existing actions
        ClearActionButtons();

        //if the actions being updated are not for a player... return
        if (!(currentChampion is PlayerChampion))
        {
            return;
        }

        //loop though actions avaiable and creates buttons for them
        for (int idx = 0; idx <= currentChampion.actions.Count - 1; idx++)
        {
            Vector3 bPosition  = new Vector3(XButtonStartPos, YButtonStartPos - idx, 0);
            string  actionName = currentChampion.actions[idx].ToString();

            CreateActionButton(bPosition, actionName, currentChampion.actions[idx], currentChampion);
        }
    }
Exemplo n.º 7
0
    //determines the order in which enemies and allies go
    public IEnumerator NewChampionRound()
    {
        //if the battle is no longer contiuing... return
        if (!continueBattle)
        {
            yield return(null);
        }

        //clear the turn order and rebuild
        turnOrder.Clear();

        //determine which list has the highest number of champions
        int highestCount = playerCharacters.Count >= enemyCharacters.Count ? playerCharacters.Count : enemyCharacters.Count;

        //loop though each champion in both lists to add them both to a single list
        for (int idx = 0; idx <= highestCount - 1; idx++)
        {
            if (idx <= playerCharacters.Count - 1)
            {
                turnOrder.Add(playerCharacters[idx] as BaseChampion);
            }
            if (idx <= enemyCharacters.Count - 1)
            {
                turnOrder.Add(enemyCharacters[idx] as BaseChampion);
            }
        }

        //sort the champions by dexterity and return the list
        List <BaseChampion> sortedOrder = turnOrder.OrderByDescending(champ => champ.stats.dexterity).ToList();

        turnOrder = sortedOrder;

        //reset everyone's actions
        StartCoroutine(ResetActionsTaken());

        //set the current champion's turn to the top of the list
        currentChampionTurn             = turnOrder[0];
        currentChampionTurn.currentTurn = true;
        yield return(null);
    }
Exemplo n.º 8
0
    //puts the next champion in the rotation, starts a new round if the last champion in the round has gone
    public IEnumerator NewChampionTurn()
    {
        //if the battle is no longer contiuing... return
        if (!continueBattle)
        {
            yield return(null);
        }

        //loop though the turn order
        for (int idx = 0; idx < turnOrder.Count; idx++)
        {
            //if the current index is greater than or equal to the current champion index
            if (idx >= GetCurrentChampionIndex())
            {
                // if the current champion is not at the end of the turn order...
                if (idx != turnOrder.Count - 1)
                {
                    //if the next champion can take an action
                    if (turnOrder[idx + 1].canTakeAction)
                    {
                        //set the current champion to the next one on the list and break the loop
                        currentChampionTurn             = turnOrder[idx + 1];
                        currentChampionTurn.currentTurn = true;
                        break;
                    }
                }
                //if the last champion in the turn order is the selected current champion
                else if (idx == turnOrder.Count - 1)
                {
                    StartCoroutine(NewChampionRound());
                }
                else
                {
                    Debug.Log("ERROR: cannot determine which champion goes next");
                }
            }
        }
        yield return(null);
    }
Exemplo n.º 9
0
 //public virtual IEnumerator AttemptAction(BaseChampion thisChampion) { yield return null; }
 public virtual IEnumerator AttemptAction(BaseChampion thisChampion)
 {
     yield return(null);
 }
Exemplo n.º 10
0
 public override IEnumerator AttemptAction(BaseChampion thisChampion)
 {
     BattleGUI._battleGUI.SetBattleMessage(thisChampion.stats.championName + " is defending...");
     thisChampion.actionTaken = true;
     yield return(null);
 }
Exemplo n.º 11
0
 //attempt the action of the button that is selected
 public void AttemptButtonAction(BaseChampion selectedChampion)
 {
     selectedChampion.SelectAction(battleAction);
 }
Exemplo n.º 12
0
    //creates a button for a player to use an action and ass it to the action button list
    private void CreateActionButton(Vector3 position, string buttonName, BattleActions buttonAction, BaseChampion championSelected)
    {
        GameObject   newButtonObject = Instantiate(GameManager._prefabs.actionButtonPrefab, position, Quaternion.identity);
        ActionButton newButton       = newButtonObject.GetComponent <ActionButton>();

        newButton.Init(buttonName, buttonAction, championSelected);
        actionButtons.Add(newButton);
    }