Beispiel #1
0
    //-------------------------------
    // Method for rebuild Player Cube

    private void RecreatePlayerCube(GameSector sector, PlayerCubesData cubeData)
    {
        // Create Player Cube according to loaded data about this
        var        cubePos   = cubeData.CubeCoords;
        GameObject newCubeGO = Instantiate(PlayerCubePfbs[cubeData.Endurance - 1],
                                           new Vector3(cubePos.x, cubePos.y, cubePos.z), Quaternion.identity) as GameObject;
        GameCube newCube = newCubeGO.GetComponent <GameCube>();

        newCubeGO.transform.parent = sector.transform;
        newCube.ParentSector       = sector.SectorCoords;
        sector.Cubes.Add(newCube);
    }
Beispiel #2
0
    //-------------------------------------
    // Method for Player made Cube Creation

    private void CreatePlayerCube(GameSector sector)
    {
        // Create Cube from relevant Prefab
        GameObject newCubeGO = Instantiate(PlayerCubePfbs[CubeIndex], new Vector3(NewCube.x, NewCube.y, NewCube.z),
                                           Quaternion.identity) as GameObject;
        GameCube newCube = newCubeGO.GetComponent <GameCube>();

        newCubeGO.transform.parent = sector.transform;
        newCube.ParentSector       = sector.SectorCoords;
        sector.Cubes.Add(newCube); // probably not needed
        SumPlayerCubes += 1;       // increase Total

        // Process Player Made list
        PlayerCube = PlayerMade.FindLast(n => n.sectorCoord == sector.SectorCoords);
        if (PlayerCube.CubeData == null) // no Player Cube data for Sector yet
        {
            PlayerCube.sectorCoord = sector.SectorCoords;
            PlayerCube.CubeData    = new List <PlayerCubesData>();
            PlayerCubesData cubedata = new PlayerCubesData
            {
                CubeCoords = NewCube,
                Endurance  = newCube.Endurance
            };
            PlayerCube.CubeData.Add(cubedata);
            PlayerMade.Add(PlayerCube);
        }
        else // only add new Player Cube to list
        {
            PlayerCubesData cubedata = new PlayerCubesData
            {
                CubeCoords = NewCube,
                Endurance  = newCube.Endurance
            };
            PlayerCube.CubeData.Add(cubedata);
        }
    }