コード例 #1
0
    void Start()
    {
        this.enabled = false;
        int playerCount = 1;

        GameObject[,] level = new GameObject[zSize, xSize];
        for (int z = 0; z < zSize; z++)
        {
            for (int x = 0; x < xSize; x++)
            {
                if (LevelGen[z, x] == (int)ObjectType.Wall_solid)
                {
                    level[z, x] = PlaceObject(Wall_solid, x, z, ObjectType.Wall_solid) as GameObject;
                }

                if (LevelGen[z, x] == (int)ObjectType.Crate)
                {
                    level[z, x] = PlaceObject(Crate, x, z, ObjectType.Crate) as GameObject;
                    Crate crate = level[z, x].GetComponent <Crate>();
                    crate.SetX(x);
                    crate.SetZ(z);
                }
                if (LevelGen[z, x] == (int)ObjectType.Player)
                {
                    level[z, x] = PlaceObject(Player[playerCount - 1], x, z, ObjectType.Player) as GameObject;
                    Character player = level[z, x].GetComponent <Character>();
                    player.SetPlayer(playerCount);
                    player.SetX(x);
                    player.SetZ(z);
                    playerCount++;
                    LevelGen[z, x] = 0;
                }
            }
        }
    }