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;
            }
        }