public EnemySpawnManager(UniMapData data, Map map)
        {
            m_wavesActive = false;
            m_isSpawning  = false;
            m_waveTimer   = BASEWAVETIMER;
            m_currTime    = m_waveTimer;

            m_numberToSpawn1 = 5;
            m_num1           = m_numberToSpawn1;
            m_shortTime1     = 1;

            m_numberToSpawn2 = 2;
            m_num2           = m_numberToSpawn2;
            m_shortTime2     = 1;

            m_numberToSpawn3 = 0;
            m_num3           = m_numberToSpawn3;
            m_shortTime3     = 3.2f;

            m_map  = map;
            m_data = data;

            m_currWave = 1;

            m_sZones = new List <EnemySpawnZone>();

            // Loop through from the top of the map to the bottom.
            // If either the left most tile at this y coordinate or the right most tile at y coordinate is walkable, then create and add spawn zone.
            CreateSpawnZones(data);
        }
        public Map(UniMapData data, ContentManager content, string pathAndName, GraphicsDevice graphicsDevice)
        {
            m_data     = data;
            m_mapSizeX = m_data.WalkableGrid.GetLength(0);
            m_mapSizeY = m_data.WalkableGrid.GetLength(1);

            m_tiles = new MapTile[m_mapSizeX, m_mapSizeY];

            for (int y = 0; y < m_mapSizeY; y++)
            {
                for (int x = 0; x < m_mapSizeX; x++)
                {
                    m_tiles[x, y]       = new MapTile(content.Load <Texture2D>(pathAndName), new Vector2(18 + (x * 36), 18 + (y * 36)), Color.White, 4, 4, x, y, graphicsDevice);
                    m_tiles[x, y].Index = m_data.WalkableGrid[x, y];

                    // Setup bool values for tiles according to their index
                    if (m_data.WalkableGrid[x, y] <= 0)
                    {
                        m_tiles[x, y].IsWalkable  = true;
                        m_tiles[x, y].IsPlaceable = false;
                    }
                    else if (m_data.WalkableGrid[x, y] == 1)
                    {
                        m_tiles[x, y].IsWalkable  = false;
                        m_tiles[x, y].IsPlaceable = true;
                    }
                    else if (m_data.WalkableGrid[x, y] > 1)
                    {
                        m_tiles[x, y].IsWalkable  = false;
                        m_tiles[x, y].IsPlaceable = false;
                    }
                }
            }
        }
        private void CreateSpawnZones(UniMapData data)
        {
            for (int i = 0; i < data.WalkableGrid.GetLength(1); i++)
            {
                // Make Spawn zones on the left
                if (data.WalkableGrid[0, i] <= 0)
                {
                    EnemySpawnZone newZone = new EnemySpawnZone();
                    newZone.IsActive    = true;
                    newZone.PointCoords = new Point(0, i);
                    newZone.SpawnArea   = new Rectangle(-36 * 4 - 18, 36 * i - 18 + (36 * 4), 36 * 8, 36 * 8);
                    m_sZones.Add(newZone);
                }

                // Make spawn zones on the right
                if (data.WalkableGrid[data.WalkableGrid.GetLength(0) - 1, i] <= 0)
                {
                    EnemySpawnZone newZone = new EnemySpawnZone();
                    newZone.IsActive    = true;
                    newZone.PointCoords = new Point(data.WalkableGrid.GetLength(0) - 1, i);
                    newZone.SpawnArea   = new Rectangle((data.WalkableGrid.GetLength(0) - 1) * 36 + (-36 * 4 - 18), 36 * i - 18 + (36 * 4), 36 * 8, 36 * 8);
                    m_sZones.Add(newZone);
                }
            }
        }
示例#4
0
        private void FillMinimapPixels(ContentManager content, UniMapData data)
        {
            for (int y = 0; y < m_mapSizeY; y++)
            {
                for (int x = 0; x < m_mapSizeX; x++)
                {
                    m_mapPixels[x, y] = new CenteredStaticGraphic(content.Load <Texture2D>("Art\\PlaceholderArt\\GameplayGUI\\MiniMapPixel"), new Vector2(1920 - (240 - (x * 3)), 1080 - (135 - (y * 3))), Color.White, 1);

                    // Add colours to the pixels for colour coding
                    if (data.WalkableGrid[x, y] <= 0)
                    {
                        m_mapPixels[x, y].AltTints.Add(Color.White);
                        m_mapPixels[x, y].AltTints.Add(new Color(100, 255, 100));
                        m_mapPixels[x, y].AltTints.Add(Color.Blue);
                        m_mapPixels[x, y].AltTints.Add(Color.Yellow);
                        m_mapPixels[x, y].AltTints.Add(Color.Orange);
                        m_mapPixels[x, y].AltTints.Add(Color.Red);
                    }
                    else
                    {
                        m_mapPixels[x, y].AltTints.Add(Color.Black);
                        m_mapPixels[x, y].AltTints.Add(Color.Magenta);
                    }
                }
            }
        }
        public TileMerger(Map map, UniMapData data)
        {
            m_map  = map;
            m_data = data;

            m_sizeX = m_data.WalkableGrid.GetLength(0);
            m_sizeY = m_data.WalkableGrid.GetLength(1);
        }
        public PlacementManager(UniMapData data, ContentManager content, GraphicsDevice graphicsDevice)
        {
            m_tiles = new MapTile[data.WalkableGrid.GetLength(0), data.WalkableGrid.GetLength(1)];

            m_placingActive = false;

            // Create the grid of overlay tiles
            FillPlacementTiles(data, content, graphicsDevice);
        }
示例#7
0
        public MiniMap(ContentManager content, UniMapData data, Camera cam)
        {
            m_mapSizeX = data.WalkableGrid.GetLength(0);
            m_mapSizeY = data.WalkableGrid.GetLength(1);

            m_mapPixels = new CenteredStaticGraphic[m_mapSizeX, m_mapSizeY];

            m_mapBox = new MotionGraphic(content.Load <Texture2D>("Art\\PlaceholderArt\\GameplayGUI\\MiniMapView"), new Vector2(1920 - 56, 1080 - 31), Color.White, Vector2.Zero, 0, 1 / cam.Zoom);

            FillMinimapPixels(content, data);
        }
        // Construct the grid of walkable and non-walkable nodes, using the universal map data generated by the path generator.
        public NodeGraph(UniMapData data)
        {
            m_pNodes = new PNode[data.WalkableGrid.GetLength(0), data.WalkableGrid.GetLength(1)];

            for (int y = 0; y < data.WalkableGrid.GetLength(1); y++)
            {
                for (int x = 0; x < data.WalkableGrid.GetLength(0); x++)
                {
                    m_pNodes[x, y] = new PNode(x, y, data.WalkableGrid[x, y]);
                }
            }
        }
        private void FillPlacementTiles(UniMapData data, ContentManager content, GraphicsDevice graphicsDevice)
        {
            for (int y = 0; y < m_tiles.GetLength(1); y++)
            {
                for (int x = 0; x < m_tiles.GetLength(0); x++)
                {
                    m_tiles[x, y] = new MapTile(content.Load <Texture2D>("Art\\PlaceholderArt\\Tiles\\TowerPlacementTiles"), new Vector2(18 + (x * 36), 18 + (y * 36)), Color.White, 1, 1, x, y, graphicsDevice);

                    // Check the tile "heights" to add tints for highlighting
                    // This gives the player visual aide when placing and moving towers
                    if (data.WalkableGrid[x, y] <= 0)
                    {
                        m_tiles[x, y].IsPlaceable = false;
                        m_tiles[x, y].AltTints.Add(Color.HotPink);
                        m_tiles[x, y].AltTints.Add(new Color(100, 100, 100));
                        m_tiles[x, y].Tint            = m_tiles[x, y].AltTints[1];
                        m_tiles[x, y].SourceRectangle = new Rectangle(0, 0, 36, 36);
                        m_tiles[x, y].Origin         += new Vector2(2, 2);
                    }
                    else if (data.WalkableGrid[x, y] == 1)
                    {
                        m_tiles[x, y].IsPlaceable = true;
                        m_tiles[x, y].AltTints.Add(Color.LightGreen);
                        m_tiles[x, y].AltTints.Add(Color.Gray);
                        m_tiles[x, y].Tint            = m_tiles[x, y].AltTints[1];
                        m_tiles[x, y].SourceRectangle = new Rectangle(0, 0, 36, 36);
                        m_tiles[x, y].Origin         += new Vector2(2, 2);
                    }
                    else if (data.WalkableGrid[x, y] > 1)
                    {
                        m_tiles[x, y].IsPlaceable = false;
                        m_tiles[x, y].AltTints.Add(Color.HotPink);
                        m_tiles[x, y].AltTints.Add(new Color(100, 100, 100));
                        m_tiles[x, y].Tint            = m_tiles[x, y].AltTints[1];
                        m_tiles[x, y].SourceRectangle = new Rectangle(0, 0, 36, 36);
                        m_tiles[x, y].Origin         += new Vector2(2, 2);
                    }
                }
            }
        }
示例#10
0
        public PathGen(int sizeX, int sizeY, int maxLength)
        {
            m_data = new UniMapData(sizeX, sizeY);

            m_mapSizeX = sizeX;
            m_mapSizeY = sizeY;

            m_maxLength = maxLength;

            // Get a random number of paths to generate.
            m_pathNo = Game1.RNG.Next(3, 7);

            // For each path to be generated.
            for (int i = 0; i < m_pathNo; i++)
            {
                // This boolean is used to see if the generator has drawn the first path.
                // This will ensure that the first section made is not going up or down.
                bool hasDrawn = false;

                // Set the current X index to 0.
                m_currX = 0;

                // Set the current direction as forward.
                m_currDir = 3;
                m_newDir  = 1;

                // Pick a starting Y coordinate.
                m_currY = Game1.RNG.Next(1, sizeY - 1);

                // Checks to see if a path has already been generated next to this point. anything 0 or less is walkable, anything else is not.
                if (m_currY > 0 && m_currY < sizeY - 1)
                {
                    while (m_data.WalkableGrid[0, m_currY + 1] <= 0 || m_data.WalkableGrid[0, m_currY - 1] <= 0)
                    {
                        m_currY = Game1.RNG.Next(1, sizeY - 1);
                    }
                }

                m_data.WalkableGrid[0, m_currY] = 0;

                // It will generate path until it reaches the end.
                while (m_currX < sizeX - 1)
                {
                    if (hasDrawn)
                    {
                        m_newDir = Game1.RNG.Next(0, 3);
                    }

                    switch (m_newDir)
                    {
                    case 0:
                        GenerateUpward();
                        hasDrawn = true;
                        break;

                    case 1:
                        GenerateForward(sizeX);
                        hasDrawn = true;
                        break;

                    case 2:
                        GenerateDownward(sizeY);
                        hasDrawn = true;
                        break;

                    default:
                        // Try and get a new path direction.
                        m_newDir = Game1.RNG.Next(0, 3);
                        break;
                    }
                }
            }

            for (int y = 0; y < m_mapSizeY; y++)
            {
                for (int x = 0; x < m_mapSizeX; x++)
                {
                    MakeUnplaceableTiles(x, y);
                }
            }

            MakeFoliage();
        }
示例#11
0
        public EnemyChar(Texture2D txr, Vector2 position, Color tint, float scale, int fps, int framesX, int framesY, int maxHealth, float speed, float detectionRadius, float damage, float tickTime, Map map, UniMapData data, ContentManager content, int currentLevel, int currentWave)
            : base(txr, position, tint, scale, fps, framesX, framesY, maxHealth, speed, detectionRadius, damage, tickTime)
        {
            m_collisionCircle = new Circle(m_position.X, m_position.Y, 18);

            m_map    = map;
            m_graph  = new NodeGraph(data);
            m_search = new GBFsearch(m_graph, m_map);

            m_xCoords = (int)(position.X / 36);
            m_yCoords = (int)(position.Y / 36);

            m_vanishTimer = 2;

            m_baseFPS = m_fps;

            m_isShaded = false;

            // Truthfully, this was testing the idea of method chaining
            m_healthBar = new CharHealthBar("Art\\GameArt\\GameplayGUI")
                          .SetPosition(m_position)
                          .LoadShader(content, "Shaders\\HighlightEffect")
                          .LoadTextures(content, "\\EnemyHealthBarBorder", "\\EnemyHealthBar", "\\EnemyHealthBar", 0.5f)
                          .SetHpValues((int)m_health)
                          .SetColours(Color.White, Color.Yellow, Color.Red)
                          .SetParentOfBar(this)
                          .SetScaleBorder(0.5f)
                          .SetScaleBar(1)
                          .SetScaleBacking(1);
        }
示例#12
0
        // Class Constructor.
        public GuardChar(Texture2D txr, Vector2 position, Color tint, float scale, int fps, int framesX, int framesY, int maxHealth, float speed, float detectionRadius, float damage, float tickTime, UniMapData data, ContentManager content, Map map, Vector2 healthBarPosition)
            : base(txr, position, tint, 1, fps, framesX, framesY, maxHealth, speed, detectionRadius, damage, tickTime)
        {
            m_isSelected = false;
            m_isMoving   = false;
            m_isFighting = false;
            m_isShifting = false;
            m_isShaded   = true;
            m_velocity   = Vector2.Zero;
            m_map        = map;
            m_graph      = new NodeGraph(data);
            m_search     = new GBFsearch(m_graph, m_map);
            m_xCoords    = (int)(position.X / 36);
            m_yCoords    = (int)(position.Y / 36);

            m_path = new Queue <MapTile>();

            m_healthBar = new CharHealthBar("Art\\GameArt\\GameplayGUI")
                          .SetPosition(healthBarPosition)
                          .LoadShader(content, "Shaders\\SmallHighlightEffect")
                          .LoadTextures(content, "\\AllyHealthBarBorder", "\\AllyHealthBar", "\\AllyHealthBar", 1)
                          .SetHpValues((int)m_health)
                          .SetColours(Color.White, Color.Yellow, Color.Red)
                          .SetParentOfBar(this);
        }
        public AlienType3(Texture2D txr, Vector2 position, Color tint, float scale, int fps, int framesX, int framesY, int maxHealth, float speed, float detectionRadius, float damage, float tickTime, Map map, UniMapData data, ContentManager content, int currentLevel, int currentWave, int difficulty)
            : base(txr, position, tint, scale, fps, framesX, framesY, maxHealth, speed, detectionRadius, damage, tickTime, map, data, content, currentLevel, currentWave)
        {
            SetEnums();

            SetRewards(currentLevel, currentWave, 300, 1500, 100, 250, 30, 40);

            m_health    = (int)Math.Pow(500 + (250 * (difficulty - 1)) + (50 * currentLevel), 1 + (currentWave * (1 / 20)));
            m_maxHealth = m_health;

            m_srcBaseY = 322;
        }
 public SelectionManager(UniMapData map)
 {
     m_map = map;
 }