Beispiel #1
0
        private IEnumerator CastGivenLabelSkill(Label label)
        {
            var newCastableSkills = new List <CastableSkill>();

            foreach (var skill in castableSkills)
            {
                CreatureController bot = Creatures[skill.creatureID];
                if (bot.NextSkill.labels.Contains(label))
                {
                    if (player.IsDeath)
                    {
                        break;
                    }
                    AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.red));
                    AnimationManager.Instance.AddAnimClip(new BaseAnimClip(AnimType.Delay, 0.5f));
                    bot.MoveToTile(skill.action.destination, bot.MoveCost);
                    bot.CastSkill(bot.NextCastSkillID, skill.action.castLocation);
                    SetNextSkillTarget(skill.creatureID);
                    if (player.IsDeath)
                    {
                        break;
                    }
                    AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.black));
                    yield return(null);
                }
                else
                {
                    newCastableSkills.Add(skill);
                }
            }
            castableSkills = newCastableSkills;
        }
Beispiel #2
0
        private IEnumerator DecisionMaking()
        {
            yield return(StartCoroutine(CastGivenLabelSkill(Label.Combo1st)));

            yield return(StartCoroutine(CastGivenLabelSkill(Label.Combo2rd)));

            yield return(StartCoroutine(CastGivenLabelSkill(Label.Combo3th)));

            // Cast left skills
            foreach (var skill in castableSkills)
            {
                CreatureController bot = Creatures[skill.creatureID];
                if (player.IsDeath)
                {
                    break;
                }
                AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.red));
                AnimationManager.Instance.AddAnimClip(new BaseAnimClip(AnimType.Delay, 0.5f));
                bot.MoveToTile(skill.action.destination, bot.MoveCost);
                bot.CastSkill(bot.NextCastSkillID, skill.action.castLocation);
                if (player.IsDeath)
                {
                    break;
                }
                AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.black));
                yield return(null);
            }

            // Consume spare action points
            foreach (var bot in Creatures)
            {
                int sparePoints = bot.ActionPoints + bot.ActionPointsPerTurn - bot.MaxActionPoints;
                if (sparePoints > 0)
                {
                    bool shouldMove = true;
                    foreach (var el in bot.NextSkill.GetEffectZone(bot.Loc))
                    {
                        if (el == bot.NextSkillTarget.Loc)
                        {
                            shouldMove = false;
                            break;
                        }
                    }
                    if (shouldMove)
                    {
                        bool finished = false;
                        foreach (var cp in bot.NextSkill.CastPattern)
                        {
                            foreach (var ep in bot.NextSkill.EffectPattern)
                            {
                                Location destination = bot.NextSkillTarget.Loc - cp - ep.loc;
                                if (destination.IsUnblocked())
                                {
                                    destination = bot.Loc.GetLocationWithGivenStep(destination, sparePoints);
                                    //Debug.Log("creature id: " + Creatures.IndexOf(bot) + "destination loc: " + destination.ToString() + ", spare points: " + sparePoints);
                                    AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.red));
                                    bot.MoveToTile(destination, bot.MoveCost);
                                    AnimationManager.Instance.AddAnimClip(new OutlineEntityAnimClip(bot.Hash, Color.black));
                                    finished = true;
                                    break;
                                }
                            }
                            if (finished)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }