예제 #1
0
        public Player()
            : base(new Point(11, 12))
        {
            m_weapon = new IronSword();
            m_pots = new Queue<HealthPot>();

            m_moveSpeed = 2;
            m_life = 15;

            m_attackSpeed = 1;
            m_baseDamage = 1;
            m_movingDirection = MovingDirection.RIGHT;
        }
예제 #2
0
        public bool loot()
        {
            Field currField = GameManager.getInstance().getMap().getFieldAt(getPosition());

            // Does field exist?
            if (currField != null)
            {
                Loot currLoot = currField.getLoot();

                // Does loot exist?
                if (currLoot != null)
                {
                    // Is loot a weapon?
                    if (currLoot is Weapon)
                    {
                        // Does player already have a weapon? If not, loot weapon
                        if (getWeapon() == null)
                        {
                            // Set weapon
                            m_weapon = (Weapon)currLoot;
                            RenderManager.getInstance().playPickupSound();
                            // Looting successful
                            return true;
                        }
                        else
                        {
                            m_weapon = (Weapon)currLoot;
                            RenderManager.getInstance().playPickupSound();
                            return true;
                        }
                    }
                    else if (currLoot is HealthPot)
                    {
                        // Add health pot to queue
                        m_pots.Enqueue((HealthPot)currLoot);
                        RenderManager.getInstance().playPickupSound();
                        // Looting successful
                        return true;
                    }
                    else if(currLoot is Boost)
                    {
                        this.m_boosts.Add((Boost)currLoot);
                        RenderManager.getInstance().playPowerupSound();
                        return true;
                    }
                }
            }

            // Looting failed
            return false;
        }
예제 #3
0
        public bool loot(Loot inLoot)
        {
            if (inLoot is HealthPot)
                m_pots.Enqueue((HealthPot)inLoot);
            else if (inLoot is Weapon)
            {
                if (getWeapon() == null)
                {
                    // Equip weapon
                    m_weapon = (Weapon)inLoot;
                }
                else
                {
                    // A weapon is already equiped
                    return false;
                }
            }
            else if(inLoot is Boost)
                this.m_boosts.Add((Boost)inLoot);

            // Return looting success

            return true;
        }