Exemple #1
0
 /// <summary>
 /// Adds the enemy to list.
 /// </summary>
 /// <param name="enemy">Enemy.</param>
 public void AddEnemyToList(EnemyController enemy)
 {
     managerImpl.AddEnemyToList(enemy);
 }
Exemple #2
0
        /// <summary>
        /// Processes the changes received from the room.
        /// </summary>
        /// <param name="changes">Changes in item state to proces.</param>
        internal void ProcessChanges(List <ItemState> changes)
        {
            Debug.Log("Processing " + changes.Count + " changes!");
            foreach (ItemState item in changes)
            {
                Debug.Log("---> " + item.Name);
                GameObject obj = owner.LevelManager.Find(item.Name);
                if (obj != null)
                {
                    // use the moving object so we get smooth movement.
                    MovingObject moving = obj.GetComponent <MovingObject>();

                    if (moving != null && !moving.BroadcastMovement)
                    {
                        moving.MoveTo(item.Position);
                    }
                    else
                    {
                        obj.transform.position = item.Position;
                    }

                    obj.transform.rotation = item.Rotation;

                    // handle enemies in a clever way to get the animation.
                    EnemyController enemy = obj.GetComponent <EnemyController>();
                    if (enemy != null && obj.activeSelf && obj.activeSelf != item.Enabled)
                    {
                        enemy.Explode();
                    }
                    else
                    {
                        obj.SetActive(item.Enabled);
                    }
                }
                else if (item.Name == GameManager.PlayerTurnFlagName)
                {
                    // toggle the turn flag.
                    if (item.Enabled)
                    {
                        foreach (PlayerInfo p in PlayerInfo.AllPlayers)
                        {
                            if (p.IsLocal)
                            {
                                p.Moved = false;
                            }
                        }
                    }
                }
                else if (item.Name.StartsWith(GameManager.ScoreChangedItemName))
                {
                    // update the scores
                    PlayerInfo p = PlayerInfo.GetPlayer(item.TileSetName);
                    if (p != null)
                    {
                        p.Score = (p.Score > item.PrefabIndex) ? p.Score : item.PrefabIndex;
                    }
                }
                else
                {
                    // create new objects that showed up
                    // since the scene was initialized.
                    Debug.Log("Creating " + item.Name);
                    GameObject newObj = owner.LevelManager.CreateItem(item);
                    if (newObj.GetComponent <PlayerController>() != null)
                    {
                        string     devId = newObj.name.Replace(ItemState.PlayerTileSet, string.Empty);
                        PlayerInfo p     = PlayerInfo.GetPlayer(devId);
                        if (p != null)
                        {
                            if (newObj.GetComponent <PlayerController>().Player == null)
                            {
                                newObj.GetComponent <PlayerController>().Player            = p;
                                newObj.GetComponent <PlayerController>().BroadcastMovement = p.IsLocal;
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
 public void AddEnemyToList(EnemyController enemy)
 {
     // nothing
 }
 /// <summary>
 /// Adds the enemy to list. so we can keep track of enemies that
 /// need to move.
 /// </summary>
 /// <param name="enemy">Enemy.</param>
 public void AddEnemyToList(EnemyController enemy)
 {
     enemy.BroadcastMovement = true;
     this.enemies.Add(enemy.gameObject.name, enemy);
 }