Ejemplo n.º 1
0
        //Implement when working on enemy collision


        /// <summary>
        /// Whenever the player touches an active chicken, they "save" it (counter is incremented)
        /// </summary>
        public void UpdateChickenList(CapturedChicken chick)
        {
            collectedChickens.Add(chick);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds in the 2d textures to a 2d array of tiles then returns the array
        /// </summary>
        private Tile[,] LoadTiles(string[,] levelMap, List <Texture2D> textures)
        {
            //populate the array with whatever level map is being passed in
            for (int row = 0; row < VerticalTileCount; row++)
            {
                for (int column = 0; column < HorizontalTileCount; column++)
                {
                    Texture2D tempTexture   = textures[1];                       //create temp texture
                    int       textureNumber = GetTexture(levelMap[row, column]); //get told which texture to put in place from levelMap

                    //send the entities to a different array


                    //if the tile should be lowered, add its tile number to this list
                    if (textureNumber == 1 || textureNumber == 2 || textureNumber == 3)
                    {
                        screenTiles[row, column].Height -= (screenTiles[row, column].Height / 8) * 6;
                        screenTiles[row, column].Y      += (screenTiles[row, column].Height / 8) * 6;
                    }

                    //if it's the enemy tile, stretch it out
                    if (textureNumber == 23)
                    {
                        bool      doubleChecker = false;
                        Rectangle tempRect      = screenTiles[row, column].Hitbox;
                        tempRect.Height = 75;
                        tempRect.Width  = 75;
                        tempRect.X     += 75 / 2;
                        tempRect.Y     += 75;

                        Enemy tempE = new Enemy(tempRect, textures[23], 4, 1);

                        foreach (Enemy e in enemies)
                        {
                            if (e.X == tempE.X)
                            {
                                doubleChecker = true;
                            }
                        }

                        if (!doubleChecker)
                        {
                            enemies.Add(tempE);
                        }

                        //levelMap[row, column] = null;
                        //screenTiles[row, column] = null;
                        screenTiles[row, column].DefaultSprite = null;
                    }

                    //if it's the egg tile, drop one of those in
                    if (textureNumber == 24)
                    {
                        bool      doubleChecker = false;
                        Rectangle tempRect      = screenTiles[row, column].Hitbox;
                        tempRect.Height = 50;
                        tempRect.Width  = 50;
                        tempRect.X     += 60 / 2;
                        tempRect.Y     += 60;

                        CapturedChicken tempChicken = new CapturedChicken(0, textures[textureNumber], tempRect);

                        foreach (GameObject cc in gameObjs)
                        {
                            if (cc is CapturedChicken)
                            {
                                if (cc.X == tempChicken.X)
                                {
                                    doubleChecker = true;
                                }
                            }
                        }

                        if (!doubleChecker)
                        {
                            gameObjs.Add(tempChicken);
                            numOfChickens++;
                        }

                        //levelMap[row, column] = null;
                        //screenTiles[row, column] = null;
                        screenTiles[row, column].DefaultSprite = null;
                    }

                    //if it's a checkpoint tile, drop one of those in
                    if (textureNumber == 25)
                    {
                        bool      doubleChecker = false;
                        Rectangle tempRect      = screenTiles[row, column].Hitbox;
                        tempRect.Height = 75;
                        tempRect.Width  = 75;
                        tempRect.X     += 75 / 2;
                        tempRect.Y     += 60;

                        Checkpoint tempCheck = new Checkpoint(0, textures[textureNumber], tempRect, this);

                        foreach (GameObject c in gameObjs)
                        {
                            if (c is Checkpoint)
                            {
                                if (c.X == tempCheck.X)
                                {
                                    doubleChecker = true;
                                }
                            }
                        }

                        if (!doubleChecker)
                        {
                            gameObjs.Add(tempCheck);
                        }

                        //levelMap[row, column] = null;
                        //screenTiles[row, column] = null;
                        screenTiles[row, column].DefaultSprite = null;
                    }

                    //if it's an empty tile, set it to null in the 2d array
                    if (textureNumber == 0 || textureNumber == 23 || textureNumber == 24 || textureNumber == 25)
                    {
                        levelMap[row, column] = null;
                    }

                    //otherwise, set the tile's texture to it's ref in the texture list & add tags
                    else
                    {
                        tempTexture = textures[textureNumber];                       //set texture into temp
                        screenTiles[row, column].DefaultSprite = tempTexture;        //update the tile using temp

                        string tagTemp = TagTileSplit(levelMap[row, column], false); //pulls the tag for this tile
                        screenTiles[row, column].Type = tileTypeDict[tagTemp];       //updates screenTiles with the tag
                    }
                }
            }
            return(screenTiles); //return screentiles so it can be added to the collision check group
        }