示例#1
0
    public static void UpdateBuildings()
    {
        List <Building> allBuildings = TerrainManager.instance.buildings;

        data.buildings = new List <SavedBuilding> ();
        buildingsByPos.Clear();
        foreach (Building building in allBuildings)
        {
            SavedBuilding savedBuilding = null;
            if (building is ProductionBuilding)
            {
                savedBuilding = new SavedProductionBuilding(building);
            }
            else if (building is TeleporterBuilding)
            {
                savedBuilding = new SavedTeleporterBuilding(building);
            }

            data.buildings.Add(savedBuilding);
            buildingsByPos.Add(TerrainManager.PosToV2(building.transform.position), savedBuilding);
        }

        //builds happen between turns
        GameManager.instance.SaveGame();
    }
示例#2
0
    public static void UpdateBuildingSupply(Building building)
    {
        Vector2 key = TerrainManager.PosToV2(building.transform.position);
        SavedProductionBuilding oldSavedBuilding = buildingsByPos [key] as SavedProductionBuilding;
        SavedProductionBuilding newSavedBuilding = new SavedProductionBuilding(building);

        data.buildings.Remove(oldSavedBuilding);
        data.buildings.Add(newSavedBuilding);
        buildingsByPos.Remove(key);
        buildingsByPos.Add(key, newSavedBuilding);

        GameManager.instance.SaveThisTurn();
    }