Exemple #1
0
        public ClientBuilding(byte id, ClientPlayer owner, ClientTile tile) : base(id, owner)
        {
            var prefab = Resources.Load("prefabs/buildings/" + id);

            StackLog.Debug("Instantiating BUILDING");
            _gameObject = MainBehaviour.Instantiate(prefab, ((ClientChunk)tile.Chunk).GetGameObject().transform) as GameObject;
        }
Exemple #2
0
        public static void BattleEffect(ClientTile t)
        {
            StopEffect(t);
            var prefab = Resources.Load("prefabs/BattleEffect");
            var obj    = MainBehaviour.Instantiate(prefab, t.GetGameObject().transform) as GameObject;

            _effects[t] = obj;
            obj.transform.localPosition = new Vector3(0, 0.2f, 0);
        }
Exemple #3
0
        private GameObject GetOrCreatePathLine(ClientTile tile, ClientPath clientPath)
        {
            var pooled = _pathlinesPool.FirstOrDefault(path => !path.activeInHierarchy);

            if (pooled == null)
            {
                Log.Debug("Created new path line");
                pooled = MainBehaviour.Instantiate(Resources.Load("prefabs/HalfPath")) as GameObject;
                _pathlinesPool.Add(pooled);
            }
            else
            {
                pooled.SetActive(true);
                pooled.transform.rotation = Quaternion.identity;
            }
            clientPath.Add(tile, pooled);
            return(pooled);
        }
Exemple #4
0
        public void AddToScene(byte tileID)
        {
            var tileSpec = StrategyGame.Specs.GetTileSpec(tileID);

            foreach (var art in tileSpec.Arts)
            {
                if (_gameObj == null)
                {
                    var prefab = Resources.Load("prefabs/tiles/" + art.Name);
                    var parent = ((ClientChunk)this.Chunk).GetGameObject().transform;
                    _gameObj      = MainBehaviour.Instantiate(prefab, parent) as GameObject;
                    _gameObj.name = $"Tile_{X}-{Y}";
                    _gameObj.transform.position = new Vector3(X, 0, Y);
                    var tileBhv = _gameObj.GetComponent <TileRandomizerBehaviour>();
                    base.TileId = tileID;
                    tileBhv.CreateTileDecoration(this);
                    return;
                }
            }
        }