コード例 #1
0
    void SpawnEnemy()
    {
        DefenseGameTile spawnPoint = board.GetSpawnPoint(Random.Range(0, board.SpawnPointCount));
        Enemy           enemy      = enemyFactory.Get();

        enemy.SpawnOn(spawnPoint);
        enemies.Add(enemy);
    }
コード例 #2
0
 public static void MakeNorthSouthNeighbors(DefenseGameTile north, DefenseGameTile south)
 {
     Debug.Assert(
         south.north == null && north.south == null, "Redefined neighbors!"
         );
     south.north = north;
     north.south = south;
 }
コード例 #3
0
 public static void MakeEastWestNeightbors(DefenseGameTile east, DefenseGameTile west)
 {
     Debug.Assert(
         west.east == null && east.west == null, "Redefined neightbors!"
         );
     west.east = east;
     east.west = west;
 }
コード例 #4
0
    void HandleTouch()
    {
        DefenseGameTile tile = board.GetTile(TouchRay);

        if (tile != null)
        {
            board.ToggleWall(tile);
        }
    }
コード例 #5
0
 DefenseGameTile GrowPathTo(DefenseGameTile neighbor, Direction direction)
 {
     Debug.Assert(HasPath, "No Path!");
     if (neighbor == null || neighbor.HasPath)
     {
         return(null);
     }
     neighbor.PathDirection = direction;
     neighbor.distance      = distance + 1;
     neighbor.nextOnPath    = this;
     // neighbor.ExitPoint=neighbor.transform.localPosition + direction.GetHalfVector();
     neighbor.ExitPoint =
         (neighbor.transform.localPosition + transform.localPosition) * 0.5f;
     return(neighbor.Content.Type != GameTileContentType.Wall?neighbor:null);
 }
コード例 #6
0
    void HandleAlternativeTouch()
    {
        DefenseGameTile tile = board.GetTile(TouchRay);

        if (tile != null)
        {
            if (Input.GetKey(KeyCode.LeftShift))
            {
                board.ToggleDestination(tile);
            }
            else
            {
                board.ToggleSpawnPoint(tile);
            }
        }
    }