예제 #1
0
    public void GenerateMap()
    {
        Vector3Int topLeftSpawnTileBottomTile   = StaticGridManager.GetSingleton().topLeftSpawnTile + Vector3Int.down;
        Vector3Int topLeftSpawnTileRightTile    = StaticGridManager.GetSingleton().topLeftSpawnTile + Vector3Int.right;
        Vector3Int topRightSpawnTileBottomTile  = StaticGridManager.GetSingleton().topRightSpawnTile + Vector3Int.down;
        Vector3Int topRightSpawnTileLeftTile    = StaticGridManager.GetSingleton().topRightSpawnTile + Vector3Int.left;
        Vector3Int bottomLeftSpawnTileTopTile   = StaticGridManager.GetSingleton().bottomLeftSpawnTile + Vector3Int.up;
        Vector3Int bottomLeftSpawnTileRightTile = StaticGridManager.GetSingleton().bottomLeftSpawnTile + Vector3Int.right;
        Vector3Int bottomRightSpawnTileTopTile  = StaticGridManager.GetSingleton().bottomRightSpawnTile + Vector3Int.up;
        Vector3Int bottomRightSpawnTileLeftTile = StaticGridManager.GetSingleton().bottomRightSpawnTile + Vector3Int.left;

        TileDef.TileType[,] tileTypes = new TileDef.TileType[StaticGridManager.GetSingleton().width, StaticGridManager.GetSingleton().height];

        for (int x = 0; x < StaticGridManager.GetSingleton().width; ++x)
        {
            for (int y = StaticGridManager.GetSingleton().height - 1; y >= 0; --y)
            {
                Vector3Int cellPosition = new Vector3Int(x, y, 0);
                if (!StaticGridManager.GetSingleton().collidableGroundTilemap.HasTile(cellPosition))
                {
                    Vector3 cellWorldPosition = StaticGridManager.GetSingleton().nonCollidableGroundTilemap.GetCellCenterWorld(cellPosition);

                    bool isSpawnTile =
                        cellPosition == StaticGridManager.GetSingleton().topLeftSpawnTile ||
                        cellPosition == StaticGridManager.GetSingleton().topRightSpawnTile ||
                        cellPosition == StaticGridManager.GetSingleton().bottomLeftSpawnTile ||
                        cellPosition == StaticGridManager.GetSingleton().bottomRightSpawnTile ||
                        cellPosition == topLeftSpawnTileBottomTile ||
                        cellPosition == topLeftSpawnTileRightTile ||
                        cellPosition == topRightSpawnTileBottomTile ||
                        cellPosition == topRightSpawnTileLeftTile ||
                        cellPosition == bottomLeftSpawnTileTopTile ||
                        cellPosition == bottomLeftSpawnTileRightTile ||
                        cellPosition == bottomRightSpawnTileTopTile ||
                        cellPosition == bottomRightSpawnTileLeftTile;
                    if (!isSpawnTile && Random.value <= bricksProbability)
                    {
                        networkManager.AddObject((int)CustomNetworkManager.SpawnPrefabs.BricksTile, cellWorldPosition);
                    }
                    else
                    {
                        Vector3Int       topCellPosition = new Vector3Int(x, y + 1, 0);
                        TileDef.TileType topTileType     = tileTypes[topCellPosition.x, topCellPosition.y];

                        if (topTileType == TileDef.TileType.Bricks)
                        {
                            networkManager.AddObject((int)CustomNetworkManager.SpawnPrefabs.GrassWithShadowTile, cellWorldPosition);
                        }
                        else
                        {
                            networkManager.AddObject((int)CustomNetworkManager.SpawnPrefabs.GrassTile, cellWorldPosition);
                        }

                        tileTypes[x, y] = TileDef.TileType.Grass;
                    }
                }
            }
        }
    }
    public void CmdAddProjectile()
    {
        Vector3 a_bit_behind = this.transform.position;
        float   offset       = 2;

        a_bit_behind = a_bit_behind - this.transform.forward * offset;
        networkManager.AddObject(4, a_bit_behind);
    }
 void CmdAddPumpkin()
 {
     networkManager.AddObject(3, Vector3.zero);
 }