Example #1
0
 public void Update(Player player, GameOverlay gameOverlay)
 {
     for (int i = 0; i < sceneObjects.Count; i++)
     {
         GameObj obj = sceneObjects[i];
         if (player.collisionManager.IsColliding(((Item)obj).collisionManager.GetBounds()))
         {
             player.canPickup = ((Item)obj);
         }
     }
 }
Example #2
0
 public override void Update(GameObj gameObj)
 {
     position = gameObj.GetPosition();
     for (int i = 0; i < bullets.Count; i++)
     {
         bullets[i].Update();
         if (bullets[i].canBeDestroyed)
         {
             bullets.Remove(bullets[i]);
         }
     }
     fireCount++;
 }
Example #3
0
 public override void Update(GameObj e)
 {
     base.Update(e);
     enemy = (Enemy)e;
     if (enemy.IsCollidingHor())
     {
         enemy.SetYVelocity(0);
     }
     if (enemy.IsCollidingVer())
     {
         enemy.SetXVelocity(0);
     }
 }
Example #4
0
        public void AddObject(GameObj newObject)
        {
            int xPos = (int)Math.Round(newObject.GetPosition().X / tileMap.GetTileSize());
            int yPos = (int)Math.Round(newObject.GetPosition().Y / tileMap.GetTileSize());

            if (occupiedPlaces[xPos, yPos] == 0)
            {
                sceneObjects.Add(newObject);
                occupiedPlaces[xPos, yPos] = 1;
            }
            else
            {
                int checkWidth  = 1;
                int checkHeight = 1;
                while (occupiedPlaces[xPos, yPos] != 0)
                {
                    checkWidth  += 2;
                    checkHeight += 2;
                    if (xPos >= 1)
                    {
                        xPos--;
                    }
                    if (yPos >= 1)
                    {
                        yPos--;
                    }
                    for (int i = 0; i < checkWidth; i++)
                    {
                        for (int j = 0; j < checkHeight; j++)
                        {
                            if (occupiedPlaces[xPos + i, yPos + j] == 0)
                            {
                                xPos = xPos + i;
                                yPos = yPos + j;
                                break;
                            }
                        }
                        if (occupiedPlaces[xPos, yPos] == 0)
                        {
                            break;
                        }
                    }
                }
                newObject.SetXPosition(xPos * tileMap.GetTileSize());
                newObject.SetYPosition(yPos * tileMap.GetTileSize());
                sceneObjects.Add(newObject);
                occupiedPlaces[xPos, yPos] = 1;
            }
        }
Example #5
0
 public virtual void Update(GameObj gameObj)
 {
 }
Example #6
0
 public virtual void Update(GameObj gameObj)
 {
     bounds = new Rectangle((int)gameObj.GetPosition().X, (int)gameObj.GetPosition().Y, (int)gameObj.GetDimensions().X, (int)gameObj.GetDimensions().Y);
 }