예제 #1
0
    // Update transform once per second
    private IEnumerator GameBuildingTransform()
    {
        while (true)
        {
            // update transform position rotation on save object
            gameBuilding.SetTransform(transform);

            yield return(new WaitForSeconds(1));
        }
    }
예제 #2
0
    public static BuildingScript ReplaceBuilding(BuildingScript toReplace, Building newBuilding)
    {
        // Copy all infos from toReplace to new Building
        GameBuilding toSpawn = new GameBuilding(newBuilding, toReplace.GridX, toReplace.GridY, toReplace.Orientation);

        toSpawn.noTaskCurrent     = toReplace.NoTaskCurrent;
        toSpawn.populationCurrent = toReplace.PopulationCurrent;
        toSpawn.resourceCurrent   = toReplace.StorageCurrent;
        toSpawn.nr    = toReplace.Nr;
        toSpawn.stage = toReplace.Stage;
        toSpawn.childBuildingStorage = toReplace.ChildBuildingStorage;
        toSpawn.childBuildingField   = toReplace.ChildBuildingField;
        toSpawn.SetTransform(toReplace.transform);

        // destroy old building and spawn new building
        //Destroy(toReplace.gameObject);
        BuildingScript newBs = SpawnBuilding(toSpawn);

        newBs.replacing = toReplace;
        return(newBs);
    }