示例#1
0
        public void DropItem()
        {
            PowerUp p = new WeaponPowerUp(WeaponPowerUp.WeaponType.Plasma);

            p.Position = Position;
            p.LoadContent();
            ObjectManager.PowerUpItems.Add(p);
            ObjectManager.GetCell(p.Position).Add(p);
        }
示例#2
0
        public static Weapon GetWeaponType(WeaponPowerUp p)
        {
            switch (p.Type)
            {
            case WeaponType.Shotgun:
                return(new Shotgun());

            case WeaponType.Rifle:
                return(new Rifle());

            case WeaponType.Plasma:
                return(new Plasma());

            case WeaponType.Repeater:
                return(new Repeater());

            default:
                return(new Shotgun());
            }
        }
示例#3
0
        //check collisions with things
        public void CheckCollisions(World _world)
        {
            //float nearestLength = float.MaxValue;
            DrawRedFlash = false;
            List <List <GameObject> > objectsToCheck = ObjectManager.GetCellsOfRectangle(Bounds);

            foreach (List <GameObject> gameObjectList in objectsToCheck)
            {
                foreach (GameObject ob in gameObjectList)
                {
                    if (ob is Player)
                    {
                        continue;
                    }
                    if (ob == null)
                    {
                        //need to handle null exeception here
                        gameObjectList.Remove(ob);
                        continue;
                    }
                    if (ob.m_Bounds.Intersects(this.m_Bounds))
                    {
                        if (ob is IEnemy && m_PlayerState != PlayerState.Damaged)
                        {
                            IEnemy enemy = ob as IEnemy;
                            //get the amount of time that should be removed from the enemy and remove it from the player
                            TimeToDeath -= enemy.GetDamageAmount();
                            //do collision should take care of removing the enemy
                            enemy.DoCollision(this);
                            if (TimeToDeath.TotalSeconds <= 0)
                            {
                                m_PlayerState = PlayerState.Dead;
                                return;
                            }
                            m_PlayerState = PlayerState.Damaged;
                            DrawRedFlash  = true;
                            continue;
                        }
                        if (ob is PowerUp)
                        {
                            if (m_PowerupPickupSound != null)
                            {
                                m_PowerupPickupSound.Stop();
                                m_PowerupPickupSound.Dispose();
                            }
                            m_PowerupPickupSound = ((PowerUp)ob).GetPickupSound();
                            m_PowerupPickupSound.Play();
                            //cheat powerups will always be instant now
                            if (ob is CheatPowerUp)
                            {
                                CheatPowerUp temp = ob as CheatPowerUp;
                                if (temp.CheatEffect is IInstant)
                                {
                                    IInstant instantEffect = temp.CheatEffect as IInstant;
                                    instantEffect.GetInstantEffect(this);
                                    WeaponSlot1Magic = null;
                                }
                                else
                                {
                                    CheatPowerUp cheat = ob as CheatPowerUp;
                                    WeaponSlot1Magic = cheat;
                                }
                            }
                            if (ob is WeaponPowerUp)
                            {
                                if (m_Weapons.Count < 4)
                                {
                                    Weapon weapon = WeaponPowerUp.GetWeaponType((WeaponPowerUp)ob);
                                    weapon.LoadContent();
                                    m_Weapons.Add(weapon);
                                }
                            }
                            ObjectManager.RemoveObject(ob);
                        }
                    }
                }
            }
        }