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; }
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); }
public override Tile GetTile(int tileX, int tileY) { if (!ValidCoords(tileX, tileY)) { StackLog.Debug($"Invalid coords {tileX}-{tileY}"); return(null); } var tile = base.GetTile(tileX, tileY); if (tile == null) { StackLog.Debug($"Creating tile {tileX} {tileY}"); var chunk = base.GetTileChunk(tileX, tileY); tile = new ClientTile((ClientChunk)chunk, tileX, tileY); chunk.Tiles[tileX % GameWorld.CHUNK_SIZE, tileY % GameWorld.CHUNK_SIZE] = tile; } return(tile); }
public static WorldEntity InstantiateClientEntity(WorldEntity entity, ClientPlayer owner, ClientTile tile) { var knownEntity = owner.GetKnownEntity(entity.Id); if (entity is Party) { var party = (Party)entity; var clientParty = knownEntity==null ? new ClientParty(owner, party) : ((ClientParty)knownEntity).Update(party); owner.Parties[party.PartyIndex] = clientParty; clientParty.Id = party.Id; clientParty.GetGameObject().SetActive(true); owner.KnowAbout(clientParty); return clientParty; } else if (entity is Building) { var building = (Building)entity; var clientBuilding = knownEntity==null ?new ClientBuilding(building.SpecID, owner, tile) : (ClientBuilding)knownEntity; clientBuilding.Id = building.Id; tile.StaticEntity = clientBuilding; if (building.SpecID == StrategyGame.Specs.InitialBuilding && clientBuilding.IsMine()) CameraBehaviour.FocusOnTile(tile); clientBuilding.GetGameObject().SetActive(true); owner.KnowAbout(clientBuilding); return clientBuilding; } else if (entity is Dungeon) { var clientDungeon = knownEntity == null ? new ClientDungeon((Dungeon)entity, tile) : (ClientDungeon)knownEntity; tile.StaticEntity = clientDungeon; owner.KnowAbout(clientDungeon); clientDungeon.GetGameObject().SetActive(true); return clientDungeon; } else throw new Exception($"Entity Factory does not know how to instantiate {entity.GetType().Name}"); }