示例#1
0
文件: Map.cs 项目: chasay2002/UATanks
        private void SpawnRemainingTiles(List <Tile> activeTiles)
        {
            int  currentIndex = activeTiles.Count - 1;
            Tile currentTile  = activeTiles[currentIndex];

            if (currentTile.IsInitialized)
            {
                activeTiles.RemoveAt(currentIndex);
                return;
            }

            Enums.CardinalDirection direction = currentTile.GetRandomUnintializedDirection();
            MapVector2 newTilePosition        = currentTile.TilePosition + direction.ToMapVector2();

            if (this.IsValidCoordinate(newTilePosition))
            {
                Tile neighbor = GetTile(newTilePosition);

                if (neighbor == null)
                {
                    neighbor = CreateTile(newTilePosition);
                    BuildConnector(currentTile, neighbor, direction);
                    activeTiles.Add(neighbor);
                }
                else
                {
                    BuildWall(currentTile, neighbor, direction);
                }
            }
            else
            {
                BuildWall(currentTile, null, direction);
            }
        }
示例#2
0
        //Enums.CardinalDirection direction;

        public void InitializeEdge(Tile thisTile, Tile otherTile, Enums.CardinalDirection direction)
        {
            this.thisTile  = thisTile;
            this.otherTile = otherTile;
            //this.direction = direction;

            thisTile.SetEdge(direction, this);
            this.transform.parent = thisTile.transform;
            this.name             = "Edge " + direction.ToString();
            switch (direction)
            {
            case Enums.CardinalDirection.North:
                this.transform.localPosition = new Vector3(0f, 1f, 75f);
                break;

            case Enums.CardinalDirection.East:
                this.transform.localPosition = new Vector3(75f, 1f, 75f);
                break;

            case Enums.CardinalDirection.South:
                this.transform.localPosition = new Vector3(75f, 1f, 0f);
                break;

            case Enums.CardinalDirection.West:
                this.transform.localPosition = new Vector3(0f, 1f, 0f);
                break;

            default:
                break;
            }
            this.transform.localRotation = direction.ToRotation();
        }
示例#3
0
文件: Map.cs 项目: chasay2002/UATanks
        private void BuildConnector(Tile tile1, Tile tile2, Enums.CardinalDirection direction)
        {
            TileEdge connector = Instantiate(Resources.Load <GameObject>("Blocks/Connector")).GetComponent <TileEdge>();

            connector.InitializeEdge(tile1, tile2, direction);

            connector = Instantiate(Resources.Load <GameObject>("Blocks/Connector")).GetComponent <TileEdge>();
            connector.InitializeEdge(tile2, tile1, direction.GetOpposite());
        }
示例#4
0
文件: Map.cs 项目: chasay2002/UATanks
        private void BuildWall(Tile tile1, Tile tile2, Enums.CardinalDirection direction)
        {
            TileEdge wall = Instantiate(Resources.Load <GameObject>("Blocks/Wall")).GetComponent <TileEdge>();

            wall.InitializeEdge(tile1, tile2, direction);

            if (tile2 != null)
            {
                wall = Instantiate(Resources.Load <GameObject>("Blocks/Wall")).GetComponent <TileEdge>();
                wall.InitializeEdge(tile2, tile1, direction.GetOpposite());
            }
        }
示例#5
0
 public static Quaternion ToRotation(this CardinalDirection direction)
 {
     return(cardinalRotations[(int)direction]);
 }
示例#6
0
 public static CardinalDirection GetOpposite(this CardinalDirection direction)
 {
     return(cardinalOpposites[(int)direction]);
 }
示例#7
0
 public static MapVector2 ToMapVector2(this CardinalDirection direction)
 {
     return(directionVectors[(int)direction]);
 }
示例#8
0
 public void SetEdge(Enums.CardinalDirection direction, TileEdge edge)
 {
     this.edges[(int)direction] = edge;
     this.initializedEdgeCount += 1;
 }
示例#9
0
 public TileEdge GetEdge(Enums.CardinalDirection direction)
 {
     return(this.edges[(int)direction]);
 }