Exemplo n.º 1
0
        private void ProcessKill(Monster killed, bool isFriendlyMonster)
        {
            MonsterPrefabs.Remove(killed);

            if (isFriendlyMonster)
            {
                FriendlyMonsters.Remove(killed);
            }
            else
            {
                EnemyMonsters.Remove(killed);
            }

            _isAnimationRunning = true;
            killed.SendMessage("OnLoseBattle", BattleSmoke);
        }
Exemplo n.º 2
0
        public override void UpdateGameState(int actionNumber, int subActionNumber, IDictionary <int, int> friendlyMonsterState, IDictionary <int, int> enemyMonsterState, bool isFullSync = false)
        {
            _actionNumber    = actionNumber;
            _subActionNumber = subActionNumber;

            foreach (int monsterTypeId in friendlyMonsterState.Keys)
            {
                if (FriendlyMonsters.All(m => m.MonsterTypeId != monsterTypeId))
                {
                    Monster monster = MonsterPrefabs.SingleOrDefault(m => m.MonsterTypeId == monsterTypeId);
                    monster.CurrentNode = GameGraph.Nodes[friendlyMonsterState[monsterTypeId]];
                    FriendlyMonsters.Add(monster);
                }
            }

            foreach (int monsterTypeId in enemyMonsterState.Keys)
            {
                if (EnemyMonsters.All(m => m.MonsterTypeId != monsterTypeId))
                {
                    Monster monster = MonsterPrefabs.SingleOrDefault(m => m.MonsterTypeId == monsterTypeId);
                    monster.CurrentNode = GameGraph.Nodes[enemyMonsterState[monsterTypeId]];
                    EnemyMonsters.Add(monster);
                }
            }

            foreach (Monster monster in FriendlyMonsters)
            {
                if (!friendlyMonsterState.ContainsKey(monster.MonsterTypeId))
                {
                    FriendlyMonsters.Remove(monster);
                    MonsterPrefabs.Remove(monster);
                }
                else if (monster.CurrentNode.Id != friendlyMonsterState[monster.MonsterTypeId])
                {
                    monster.CurrentNode = GameGraph.Nodes[friendlyMonsterState[monster.MonsterTypeId]];
                }
            }

            foreach (Monster monster in EnemyMonsters)
            {
                if (!enemyMonsterState.ContainsKey(monster.MonsterTypeId))
                {
                    EnemyMonsters.Remove(monster);
                    MonsterPrefabs.Remove(monster);
                }
                else if (monster.CurrentNode.Id != enemyMonsterState[monster.MonsterTypeId])
                {
                    monster.CurrentNode = GameGraph.Nodes[enemyMonsterState[monster.MonsterTypeId]];
                }
            }

            DisplayMonsters(FriendlyMonsters, EnemyMonsters);

            if (!isFullSync)
            {
                if (_actionNumber == 1 || _actionNumber == 3)
                {
                    SelectedMonster = null;
                }

                SelectedAttackNode   = null;
                SelectedMovementPath = null;
            }
        }
Exemplo n.º 3
0
        public virtual void UpdateGameState(int actionNumber, int subActionNumber, IDictionary <int, int> friendlyMonsterState, IDictionary <int, int> enemyMonsterState, bool isFullSync = false)
        {
            _actionNumber    = actionNumber;
            _subActionNumber = subActionNumber;

            foreach (Monster monster in FriendlyMonsters)
            {
                if (!friendlyMonsterState.ContainsKey(monster.MonsterTypeId))
                {
                    FriendlyMonsters.Remove(monster);
                    MonsterPrefabs.Remove(monster);
                }
                else if (monster.CurrentNode.Id != friendlyMonsterState[monster.MonsterTypeId])
                {
                    monster.CurrentNode = GameGraph.Nodes[friendlyMonsterState[monster.MonsterTypeId]];
                }
            }

            foreach (Monster monster in EnemyMonsters)
            {
                if (!enemyMonsterState.ContainsKey(monster.MonsterTypeId))
                {
                    EnemyMonsters.Remove(monster);
                    MonsterPrefabs.Remove(monster);
                }
                else if (monster.CurrentNode.Id != enemyMonsterState[monster.MonsterTypeId])
                {
                    monster.CurrentNode = GameGraph.Nodes[enemyMonsterState[monster.MonsterTypeId]];
                }
            }


            if (_actionNumber == 2 && !isFullSync)
            {
                foreach (BoardSpace space in BoardSpaces.Values)
                {
                    Node selectedNode = null;

                    if (SelectedMonster != null)
                    {
                        selectedNode = SelectedMonster.CurrentNode;
                        IEnumerable <BoardSpace> availableSpaces =
                            BoardSpaces.Values.Where(
                                s => FriendlyMonsters.Select(m => m.CurrentNode.Id).Contains(s.Node.Id)).ToList();
                        space.SendMessage("OnAvailableMonsters", availableSpaces.Select(s => s.Node.Id));
                    }
                    else
                    {
                        ClearSelectionMenu();
                        space.SendMessage("OnClearHighlighting");
                    }

                    space.SendMessage("OnClearHighlightingWithSelection", selectedNode);
                }
            }
            else if (!isFullSync)
            {
                foreach (BoardSpace space in BoardSpaces.Values)
                {
                    space.SendMessage("OnClearHighlighting");
                }

                if (_actionNumber == 1 || _actionNumber == 3)
                {
                    SelectedMonster = null;
                }

                SelectedAttackNode   = null;
                SelectedMovementPath = null;
            }

            if (_actionNumber == 3 || _actionNumber == 4)
            {
                ClearSelectionMenu();
            }

            Client.SendStateAck(GetAdjustedActionNumber(), _subActionNumber);
        }