コード例 #1
0
        protected void ChoseActionState()
        {
            SetInitiativeOrder();
            if (currentTurn < initiativeOrder.Count)
            {
                Character actingCharacter = initiativeOrder[currentTurn];
                if (actingCharacter.action != (int)ActionType.NoAction)
                {
                    currentTurn++;
                }
                else if (actingCharacter.playerControlled)
                {
                    UpdateButtonIcons(actingCharacter);
                    if (ChoseAction(actingCharacter))
                    {
                        if (actingCharacter.action == (int)ActionType.BasicAttack)
                        {
                            selectingCharacter = actingCharacter;
                            selectingSpell     = actingCharacter.spells[0];
                            currentState       = CombatState.SelectUnit;
                            return;
                        }

                        if (actingCharacter.action == (int)ActionType.CastSpell)
                        {
                            if (actingCharacter.spells[actingCharacter.spellToCast] is TargetSpell)
                            {
                                selectingCharacter = actingCharacter;
                                selectingSpell     = actingCharacter.spells[actingCharacter.spellToCast];
                                currentState       = CombatState.SelectUnit;
                            }
                            return;
                        }
                        currentTurn++;
                    }
                }
                else if (!actingCharacter.playerControlled)
                {
                    if (actingCharacter.action != (int)ActionType.PassTurn)
                    {
                        // AI decide action
                        actingCharacter.action = (int)ActionType.BasicAttack;
                        TargetSpell attackSpell = (TargetSpell)actingCharacter.spells[0];
                        attackSpell.target = team1[0]; // Attack first character
                    }
                    currentTurn++;
                }
            }
            else
            {
                currentState = CombatState.PlayActions;
                currentTurn  = 0;
            }
        }
コード例 #2
0
        protected void SelectUnitState()
        {
            TargetSpell spellToChange     = (TargetSpell)selectingSpell;
            Character   previousCharacter = null;
            Color       outlineColor      = Color.Yellow;

            foreach (Character c in allCharacters)
            {
                if (team1.Contains(c))
                {
                    if (spellToChange.targetTeam == TargetSpell.TargetTeam.Enemy)
                    {
                        c.outlineColor = Color.Red;
                    }
                }
                else
                {
                    c.outlineColor = Color.Yellow;
                }

                if (c.hitbox.Contains(KeyMouseReader.mousePosition))
                {
                    if (previousCharacter != null)
                    {
                        previousCharacter.drawOutline = false;
                    }
                    c.drawOutline = true;
                }
                else
                {
                    c.drawOutline = false;
                }
                previousCharacter = c;

                if (c.hitbox.Contains(KeyMouseReader.mousePosition) && KeyMouseReader.LeftClick())
                {
                    if (team2.Contains(c))
                    {
                        if (spellToChange.targetTeam == TargetSpell.TargetTeam.Enemy)
                        {
                            spellToChange.target = c;

                            c.drawOutline = false;

                            currentState = CombatState.ChoseAction;
                        }
                    }
                }
            }
        }