Exemplo n.º 1
0
        private void DisplayMonsters(List <Monster> friendlyMonsters, List <Monster> enemyMonsters)
        {
            foreach (Monster monster in friendlyMonsters)
            {
                float yRotationAdjustment = Client.IsHost ? 0 : 180;

                Quaternion monsterQuaternion = Quaternion.Euler(monster.transform.localRotation.eulerAngles.x, yRotationAdjustment, monster.transform.localRotation.eulerAngles.z);
                Vector3    monsterPosition   = new Vector3(monster.CurrentNode.XPosition, 0, monster.CurrentNode.YPosition);

                monster.transform.localPosition = monsterPosition;
                monster.transform.localRotation = monsterQuaternion;

                monster.gameObject.SetActive(true);

                monster.BelongsToHost       = false;
                monster.YRotationAdjustment = yRotationAdjustment;
                monster.ShouldActivate();
                if (FriendlyMonsters.All(m => m.MonsterTypeId != monster.MonsterTypeId))
                {
                    FriendlyMonsters.Add(monster);
                }
            }

            foreach (Monster enemyMonster in enemyMonsters)
            {
                float yRotationAdjustment = Client.IsHost ? 180 : 0;

                Quaternion enemyMonsterQuaternion = Quaternion.Euler(enemyMonster.transform.localRotation.eulerAngles.x, yRotationAdjustment, enemyMonster.transform.localRotation.eulerAngles.z);
                Vector3    enemyMonsterPosition   = new Vector3(enemyMonster.CurrentNode.XPosition, 0, enemyMonster.CurrentNode.YPosition);

                enemyMonster.transform.localPosition = enemyMonsterPosition;
                enemyMonster.transform.localRotation = enemyMonsterQuaternion;

                enemyMonster.BelongsToHost       = true;
                enemyMonster.YRotationAdjustment = yRotationAdjustment;

                enemyMonster.ShouldActivate();
                if (EnemyMonsters.All(m => m.MonsterTypeId != enemyMonster.MonsterTypeId))
                {
                    EnemyMonsters.Add(enemyMonster);
                }
            }
        }
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;
            }
        }