Exemplo n.º 1
0
        private void MapPayer(IPlayer player, bool newWorld = false)
        {
            if (!AllObjects.TryGetValue(player.Guid, out var item))
            {
                item = new AllObjectsDictionaryItem
                {
                    ItemFromServer = player
                };

                AllObjects.Add(player.Guid, item);

                item.Controller  = Instantiate(PlayerControllerBase, new Vector3(player.X, player.Y, 0), Quaternion.identity);
                PlayerController = item.Controller as PlayerController;
            }

            if (newWorld)
            {
                // ReSharper disable once PossibleNullReferenceException
                (item.Controller as PlayerController).UpdateFromServer(player);
            }
            else
            {
                Player.IsMoving      = player.IsMoving;
                Player.MoveToX       = player.MoveToX;
                Player.MoveToY       = player.MoveToY;
                Player.WorldGuid     = player.WorldGuid;
                Player.VisibleCities = player.VisibleCities;
            }


            item.Updated = true;
        }
Exemplo n.º 2
0
        private void MapCity(ICity city, IPlayer player)
        {
            if (!AllObjects.TryGetValue(city.Guid, out var item))
            {
                item = new AllObjectsDictionaryItem {
                    ItemFromServer = city
                };
                AllObjects.Add(city.Guid, item);
                item.Controller = Instantiate(CityControllerBase, new Vector3(city.X, city.Y, 0), Quaternion.identity);
            }

            // ReSharper disable once PossibleNullReferenceException
            (item.Controller as CityController).UpdateFromServer(city, player);
            item.Updated = true;
        }