Пример #1
0
        public override IEnumerator AnimationCoroutine()
        {
            yield return(null);

            HexCoords oldLoc = map.WhereIs(unit);

            foreach (HexCoords newLoc in path)
            {
                yield return(unit.AnimateLinearMove(
                                 oldLoc,
                                 newLoc,
                                 timePer));

                // Move unit to be in the new cell
                map.UnplaceUnit(unit);
                map.PlaceUnit(unit, newLoc);

                // Update FoW
                map[newLoc].fog = CellFogOfWar.clear;

                // Check for random battles
                if (Random.Range(0.0f, 1.0f) > 0.75f)
                {
                    // If random battle, move to battle
                    game.ChangeState(new TransferToBattle());
                }

                // If no random battle, go to next step.
                oldLoc = newLoc;
            }

            // If we got to the end of our move, go back to idle.
            game.ChangeState(new Idle());
        }
Пример #2
0
        public override IEnumerator AnimationCoroutine()
        {
            game.PlaySound(unit.runSound);

            HexCoords oldLoc = map.WhereIs(unit);

            foreach (HexCoords newLoc in path)
            {
                yield return(unit.AnimateLinearMove(
                                 oldLoc,
                                 newLoc,
                                 timePer));

                map.UnplaceUnit(unit);
                map.PlaceUnit(unit, newLoc);
                oldLoc = newLoc;
            }

            unit.ap.Increment(-1);

            yield return(null);

            List <MapUnit> reactionList = new List <MapUnit>(
                map[oldLoc].threatSet.Where(x => x.team != unit.team));

            foreach (MapUnit enemyUnit in reactionList)
            {
                unit.TakeDamage(1);
                yield return(enemyUnit.AnimateMeleeAttack(unit));
            }

            if (map[oldLoc].threatSet.Any())
            {
                yield return(null);
            }

            if (unit.team == UnitTeam.player)
            {
                game.ChangeState(new PlayerGiveOrder(unit));
            }
            else if (unit.team == UnitTeam.enemy)
            {
                game.ChangeState(new EnemyTurnAI());
            }
        }