Ejemplo n.º 1
0
 /// <summary>
 /// Method to pick up items
 /// </summary>
 /// <param name="item"></param>
 public void PickUpItem(Item item)
 {
     if (item != null)
     {
         if (!items.Contains(item))
         {
             items.Add(item);
             item.Holder = this;
             ActivateItem(touchedItem);
             GameWorld.RemoveGameObject(item);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Method to pick up weapons
 /// </summary>
 /// <param name="weapon"></param>
 public void PickUpWeapon(Weapon weapon)
 {
     if (weapon != null && weapon.Holder == null)
     {
         if (!weapons.Contains(weapon) && weapons.Count < 3)
         {
             weapons.Add(weapon);
             weapon.Holder = this;
             touchedWeapon = null;
             GameWorld.RemoveGameObject(weapon);
             CycleWeapons();
         }
     }
 }
Ejemplo n.º 3
0
        public override void OnCollision(GameObject otherObject)
        {
            if (shooter == null)
            {
                return;
            }
            if (this.shooter.GetType() == otherObject.GetType())
            {
                return;
            }
            else
            {
                Character c = otherObject as Character;
                if (c != null && c.IsAlive)
                {
                    c.UpdateHealth(1);
                    c.TakeDamage = true;
                    GameWorld.RemoveGameObject(this);
                }
            }

            //Projectile hit wall
            Wall w = otherObject as Wall;

            if (w != null)
            {
                if (!w.IsHidden)
                {
                    //Wall is visible.
                    GameWorld.RemoveGameObject(this);
                }
            }

            // Projectile hit closed door

            Door door = otherObject as Door;

            if (door != null && door.IsOpen == false)
            {
                GameWorld.RemoveGameObject(this);
            }
        }
Ejemplo n.º 4
0
        // TODO: Need to make the sword.range more universal if more swords are added
        public void SwingEffect(GameTime gameTime)
        {
            swingTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            //Normalizes movement of the swing, ensuring it moves in one direction
            if (movement != Vector2.Zero)
            {
                movement.Normalize();
            }

            //Gives the swing movement
            if (position.X < GameWorld.Player.Position.X + range &&
                position.Y < GameWorld.Player.Position.Y + range &&
                position.X > GameWorld.Player.Position.X - range &&
                position.Y > GameWorld.Player.Position.Y - range)
            {
                position += movement * movementSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (swingTime <= 0)
            {
                GameWorld.RemoveGameObject(this);
            }
        }
Ejemplo n.º 5
0
 public override void Die()
 {
     GameWorld.RemoveGameObject(this);
 }