Ejemplo n.º 1
0
        public virtual Character Spawn(Team team, IMobSpawnMap map)
        {
            Character newChar = SpawnBase(team, map);

            AITactic tactic = DataManager.Instance.GetAITactic(Tactic);

            newChar.Tactic = new AITactic(tactic);

            foreach (MobSpawnExtra spawnExtra in SpawnFeatures)
            {
                spawnExtra.ApplyFeature(map, newChar);
            }

            return(newChar);
        }
Ejemplo n.º 2
0
        public Character CreatePlayer(CharData character)
        {
            Character player = new Character(character, this);

            foreach (BackReference <Skill> skill in player.Skills)
            {
                if (skill.Element.SkillNum > -1)
                {
                    SkillData entry = DataManager.Instance.GetSkill(skill.Element.SkillNum);
                    skill.Element.Enabled = (entry.Data.Category == BattleData.SkillCategory.Physical || entry.Data.Category == BattleData.SkillCategory.Magical);
                }
            }
            AITactic tactic = DataManager.Instance.GetAITactic(0);

            player.Tactic = new AITactic(tactic);

            return(player);
        }
Ejemplo n.º 3
0
        public IEnumerator <YieldInstruction> ProcessInput(GameAction action)
        {
            GroundChar character = FocusedCharacter;

            switch (action.Type)
            {
            case GameAction.ActionType.Dir:
            {
                //result.Success = ActionResult.ResultType.Success;
                break;
            }

            case GameAction.ActionType.Move:
            {
                character.CurrentCommand = action;
                break;
            }

            case GameAction.ActionType.Drop:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessTrashItem(character, action[0], action[1] != 0)));

                break;
            }

            case GameAction.ActionType.Give:
            {
                //[0] = item slot to use (-1 for the ground item)
                //[1] = who to give it to (-1 for the user)
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessGiveItem(character, action[0], action[1])));

                break;
            }

            case GameAction.ActionType.Take:
            {
                //[0] = team slot to take from
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessTakeItem(character, action[0])));

                break;
            }

            case GameAction.ActionType.Attack:
            {
                character.CurrentCommand = action;
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessObjectInteract(character)));

                break;
            }

            case GameAction.ActionType.UseItem:
            {
                //[0] = item slot to use (-1 for held item, -2 for the ground item)
                //[1] = who to use it on (-1 for the user)
                //others: which slot to delete,
                //which intrinsic to have, which team member/item to send in, etc.
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessUseItem(character, action[0], action[1] != 0)));

                break;
            }

            case GameAction.ActionType.ShiftTeam:
            {
                int       charIndex  = action[0];
                Character targetChar = DataManager.Instance.Save.ActiveTeam.Players[charIndex];
                DataManager.Instance.Save.ActiveTeam.Players.RemoveAt(charIndex);
                DataManager.Instance.Save.ActiveTeam.Players.Insert(charIndex + 1, targetChar);

                //update the leader indices
                if (DataManager.Instance.Save.ActiveTeam.LeaderIndex == charIndex)
                {
                    DataManager.Instance.Save.ActiveTeam.LeaderIndex++;
                }
                else if (DataManager.Instance.Save.ActiveTeam.LeaderIndex == charIndex + 1)
                {
                    DataManager.Instance.Save.ActiveTeam.LeaderIndex--;
                }
                break;
            }

            case GameAction.ActionType.SetLeader:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(MakeLeader(action[0], action[1] != 0)));

                break;
            }

            case GameAction.ActionType.SendHome:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(SendHome(action[0])));

                break;
            }

            case GameAction.ActionType.GiveUp:
            {
                GameManager.Instance.SceneOutcome = GameManager.Instance.EndSegment((GameProgress.ResultType)action[0]);
                break;
            }

            case GameAction.ActionType.Tactics:
            {
                //saves all the settings to the characters
                for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++)
                {
                    int       choice = action[ii];
                    Character target = DataManager.Instance.Save.ActiveTeam.Players[ii];
                    AITactic  tactic = DataManager.Instance.GetAITactic(choice);
                    if (tactic.ID != target.Tactic.ID)
                    {
                        target.Tactic = new AITactic(tactic);
                    }
                    target.Tactic.Initialize(target);
                }
                break;
            }

            case GameAction.ActionType.SetSkill:
            {
                Skill skill = DataManager.Instance.Save.ActiveTeam.Players[action[0]].Skills[action[1]].Element;
                skill.Enabled = !skill.Enabled;
                break;
            }

            case GameAction.ActionType.ShiftSkill:
            {
                int                   slot       = action[1];
                Character             targetChar = DataManager.Instance.Save.ActiveTeam.Players[action[0]];
                BackReference <Skill> upState    = targetChar.Skills[slot];
                BackReference <Skill> downState  = targetChar.Skills[slot + 1];
                targetChar.Skills[slot]     = downState;
                targetChar.Skills[slot + 1] = upState;

                if (upState.BackRef > -1 && downState.BackRef > -1)
                {
                    SlotSkill skill = targetChar.BaseSkills[slot];
                    targetChar.BaseSkills.RemoveAt(slot);
                    targetChar.BaseSkills.Insert(slot + 1, skill);
                }
                break;
            }

            case GameAction.ActionType.SortItems:
            {
                DataManager.Instance.Save.ActiveTeam.SortItems();
                break;
            }

            default:
            {
                throw new Exception("Undefined Command: " + action.Type);
            }
            }
        }
Ejemplo n.º 4
0
        //the intention, and its result to that frame
        //"choose the action to partake in"
        public IEnumerator <YieldInstruction> ProcessInput(GameAction action, Character character, ActionResult result)
        {
            //translates commands into actions
            if (character.AttackOnly && character.CantWalk && action.Type == GameAction.ActionType.Wait)
            {
                action = new GameAction(GameAction.ActionType.Attack, action.Dir);
            }

            ProcessDir(action.Dir, character);

            switch (action.Type)
            {
            case GameAction.ActionType.Dir:
            {
                //result.Success = ActionResult.ResultType.Success;
                break;
            }

            case GameAction.ActionType.Wait:
            {
                result.Success = ActionResult.ResultType.TurnTaken;

                //if it's a team character and it's team mode, wait a little while
                if (DataManager.Instance.Save.TeamMode && character.MemberTeam == ActiveTeam)
                {
                    DungeonScene.Instance.LogMsg(Text.FormatKey("MSG_SKIP_TURN", character.GetDisplayName(false)), false, true);
                    yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(20)));
                }
                else if (character == FocusedCharacter)       //add just one little wait to slow down the turn-passing when no enemies are in view
                {
                    yield return(new WaitForFrames(1));       //this will cause 1-frame breaks when waiting with walking characters in view, but it's barely noticable
                }
                yield return(CoroutineManager.Instance.StartCoroutine(FinishTurn(character, true, false, false)));

                break;
            }

            case GameAction.ActionType.Move:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessWalk(character, (action[0] == 1), result)));

                break;
            }

            case GameAction.ActionType.Pickup:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessPickup(character, result)));

                break;
            }

            case GameAction.ActionType.Drop:
            {
                //takes an index argument
                //[0] = item slot to use (-1 for the held item)
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessPlaceItem(character, action[0], result)));

                break;
            }

            case GameAction.ActionType.Give:
            {
                //[0] = item slot to use (-1 for the ground item)
                //[1] = who to give it to (-1 for the user)
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessGiveItem(character, action[0], action[1], result)));

                break;
            }

            case GameAction.ActionType.Take:
            {
                //[0] = team slot to take from
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessTakeItem(character, action[0], result)));

                break;
            }

            case GameAction.ActionType.Tile:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessTileInteract(character, result)));

                break;
            }

            case GameAction.ActionType.Attack:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessObjectInteract(character, result)));

                break;
            }

            case GameAction.ActionType.UseSkill:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessUseSkill(character, action[0], result)));

                break;
            }

            case GameAction.ActionType.UseItem:
            {
                //[0] = item slot to use (-1 for held item, -2 for the ground item)
                //[1] = who to use it on (-1 for the user)
                //others: which slot to delete,
                //which intrinsic to have, which team member/item to send in, etc.
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessUseItem(character, action[0], action[1], result)));

                break;
            }

            case GameAction.ActionType.Throw:
            {
                //[0] = item slot to use (-1 for held item, -2 for the ground item)
                yield return(CoroutineManager.Instance.StartCoroutine(ProcessThrowItem(character, action[0], result)));

                break;
            }

            case GameAction.ActionType.TeamMode:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(ToggleTeamMode(result)));

                break;
            }

            case GameAction.ActionType.ShiftTeam:
            {
                result.Success = ActionResult.ResultType.Success;

                SwitchTeam(action[0]);
                break;
            }

            case GameAction.ActionType.SetLeader:
            {
                yield return(CoroutineManager.Instance.StartCoroutine(MakeLeader(action[0], result)));

                break;
            }

            case GameAction.ActionType.SendHome:
            {
                result.Success = ActionResult.ResultType.Success;

                yield return(CoroutineManager.Instance.StartCoroutine(SendHome(action[0])));

                break;
            }

            case GameAction.ActionType.GiveUp:
            {
                result.Success = ActionResult.ResultType.Success;

                yield return(CoroutineManager.Instance.StartCoroutine(GameManager.Instance.EndSegment((GameProgress.ResultType)action[0])));

                break;
            }

            case GameAction.ActionType.Tactics:
            {
                result.Success = ActionResult.ResultType.Success;

                //saves all the settings to the characters
                for (int ii = 0; ii < ActiveTeam.Players.Count; ii++)
                {
                    int       choice = action[ii];
                    Character target = ActiveTeam.Players[ii];
                    AITactic  tactic = DataManager.Instance.GetAITactic(choice);
                    if (tactic.ID != target.Tactic.ID)
                    {
                        target.Tactic = new AITactic(tactic);
                    }
                    target.Tactic.Initialize(target);
                }
                break;
            }

            case GameAction.ActionType.SetSkill:
            {
                result.Success = ActionResult.ResultType.Success;

                Skill skill = ActiveTeam.Players[action[0]].Skills[action[1]].Element;
                skill.Enabled = !skill.Enabled;
                break;
            }

            case GameAction.ActionType.ShiftSkill:
            {
                result.Success = ActionResult.ResultType.Success;

                ActiveTeam.Players[action[0]].SwitchSkills(action[1]);
                break;
            }

            case GameAction.ActionType.SortItems:
            {
                result.Success = ActionResult.ResultType.Success;

                ActiveTeam.SortItems();
                break;
            }

            default:
            {
                throw new Exception("Undefined Command: " + action.Type);
            }
            }
        }