示例#1
0
        public override void EnterState()
        {
            // If the player is out of units, defeat them
            if (map.Units(UnitTeam.player).Count() <= 0)
            {
                game.StartCoroutine(PlayerExt.PlayerLoses());
            }
            else
            {
                playerUnitCells = map.Units()
                                  .Where(x => (x.team == UnitTeam.player) && (x.ap > 0))
                                  .Select(map.UnitCell);

                AddShimmer(playerUnitCells);

                map.events.pointerEnter += PointerEnter;
                map.events.pointerExit  += PointerExit;
                map.events.pointerClick += PointerClick;

                ui.signal += GuiSignal;

                ui.endTurnButton.Activate();
            }

            base.EnterState();
        }
示例#2
0
        public override IEnumerator AnimationCoroutine()
        {
            // If the player is out of units, defeat them
            if (map.Units(UnitTeam.player).Count() <= 0)
            {
                game.StartCoroutine(PlayerExt.PlayerLoses());
            }
            else
            {
                // Stall for one frame to get out of transition
                yield return(null);

                // Find all movable units
                IEnumerable <MapUnit> movableUnits = map.Units(UnitTeam.enemy)
                                                     .Where(x => x.ap > 0);

                // If we have a unit to move
                if (movableUnits.Any())
                {
                    movableUnits.RandomPick().PickAction();
                }
                // No units to move
                else
                {
                    // Turn complete
                    game.ChangeState(new EndEnemyTurn());
                }
            }
        }
示例#3
0
        public override void EnterState()
        {
            // If the player is out of units, defeat them
            if (map.Units(UnitTeam.player).Count() <= 0)
            {
                game.StartCoroutine(PlayerExt.PlayerLoses());
            }
            else if (playerUnit.ap > 0)
            {
                Debug.Log("Selected " + playerUnit.name);

                pathFlood = playerUnit.Dijkstra();

                IEnumerable <MapCell> floodCells = pathFlood.Values
                                                   .Select(x => x.loc)
                                                   .Select(map.CellAt);
                IEnumerable <MapCell> threatCells = floodCells
                                                    .Where(x => playerUnit.InThreat(x));

                AddShimmer(floodCells);
                foreach (MapCell cell in threatCells)
                {
                    cell.tint = Color.Lerp(Color.red, Color.white, 0.25f);
                }

                map.events.pointerEnter += PointerEnter;
                map.events.pointerExit  += PointerExit;
                map.events.pointerClick += PointerClick;

                ui.signal += GuiSignal;

                game.mouseDown += MouseDown;

                ui.jumpButton.Activate();
            }
            else
            {
                Debug.Log("Tried to select " + playerUnit.name + ", no actions remaining.");
                game.StartCoroutine(ExitToSelectUnit());
            }

            base.EnterState();
        }
示例#4
0
        public override IEnumerator AnimationCoroutine()
        {
            // If the player is out of units, defeat them
            if (map.Units(UnitTeam.player).Count() <= 0)
            {
                game.StartCoroutine(PlayerExt.PlayerLoses());
            }
            else
            {
                // Display marquee
                ui.marqueeText.Activate();
                ui.marqueeText.text  = "Player Turn";
                ui.marqueeText.color = Color.white.Alpha(0.0f);

                for (float timePassed = 0.0f; timePassed < 1.0f; timePassed += Time.deltaTime)
                {
                    ui.marqueeText.color = Color.Lerp(Color.white.Alpha(0.0f), Color.blue, timePassed / 1.0f);
                    yield return(null);
                }

                for (float timePassed = 0.0f; timePassed < 1.0f; timePassed += Time.deltaTime)
                {
                    ui.marqueeText.color = Color.Lerp(Color.blue, Color.blue.Alpha(0.0f), timePassed / 1.0f);
                    yield return(null);
                }

                // Clear marquee
                ui.marqueeText.Deactivate();

                // Remove player threat
                foreach (MapUnit unit in map.Units(UnitTeam.player))
                {
                    foreach (MapCell cell in unit.GetThreatArea().Select(map.CellAt))
                    {
                        cell.RemoveThreat(unit);
                    }
                }

                // Begin player turn
                game.ChangeState(new PlayerSelectUnit());
            }
        }