Beispiel #1
0
        public void Update(GameTime gameTime, ref Player player, ref EnergyStorageManager esm)
        {
            _time_counter += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (_time_counter > _diff)
            {
                var powerup = _powersup[_rnd.Next(0, _powersup.Count)];
                powerup.SetPosition(GetRandomLocation());
                powerup._isvalid = true;
                _time_counter    = 0;
            }
            foreach (var pu in _powersup)
            {
                pu.Update();

                if (pu._isvalid)
                {
                    var r = new Rectangle(
                        (int)pu._position.X,
                        (int)pu._position.Y,
                        pu._width,
                        pu._height
                        );
                    if (r.Contains(player._position))
                    {
                        pu._isvalid = false;
                        if (pu._type == PowerUpType.PUT_HP)
                        {
                            foreach (var EP in esm._energy_storages)
                            {
                                int add_hp = 200;
                                if (EP._health + 200 > EP._max_health)
                                {
                                    add_hp = EP._max_health - EP._health;
                                }
                                EP._health += add_hp;
                            }
                        }
                        else if (pu._type == PowerUpType.PUT_PWR)
                        {
                            player.IncStrength(10);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public EnemyManager
        (
            ref PortalManager portal_manager,
            ref EnergyStorageManager
            energy_manager,
            Texture2D texture,
            HealthBar hp,
            int w, int h,
            int strength, int health,
            int velocity,
            int animaction_count
        )
        {
            _EM     = energy_manager;
            _PM     = portal_manager;
            _roothp = hp;

            _rootEnemy = new Enemy(texture, w, h, health, strength, -Math.Abs(velocity), animaction_count);
            _rand      = new Random();
            Enemies    = new List <Enemy>();
        }