Пример #1
0
        private void Rush()
        {
            if (changedir)
            {
                Hero.Hero hero         = GameManager.GetInstance().Player;
                var       temp         = FindHero(hero);
                Vector2   heroposition = new Vector2(temp.X, temp.Y);
                dir = heroposition - EnemySprite.Position;
                dir.Normalize();
                if (dir.X > 0)
                {
                    isTurnright = true;
                }
                else
                {
                    isTurnright = false;
                }

                changedir = false;
            }

            if (!_canUp)
            {
                if (dir.Y < 0)
                {
                    dir.Y = 0;
                }
            }
            if (!_canDown)
            {
                if (dir.Y > 0)
                {
                    dir.Y = 0;
                }
            }
            if (!_canLeft)
            {
                if (dir.X < 0)
                {
                    dir.X = 0;
                }
            }
            if (!_canRight)
            {
                if (dir.X > 0)
                {
                    dir.X = 0;
                }
            }



            EnemySprite.X += _speed * 5 * dir.X;
            EnemySprite.Y += _speed * 5 * dir.Y;
            UpdateRay(dir * 5 * _speed);
        }
Пример #2
0
        public override void Move()
        {
            Hero.Hero hero = GameManager.GetInstance().Player;
            var       temp = FindHero(hero);

            Vector2 heroposition = new Vector2(temp.X, temp.Y);
            Vector2 direction    = heroposition - EnemySprite.Position;

            if (direction.X > 0)
            {
                isTurnright = true;
            }
            else
            {
                isTurnright = false;
            }

            direction.Normalize();
            if (!_canUp)
            {
                if (direction.Y < 0)
                {
                    direction.Y = 0;
                }
            }
            if (!_canDown)
            {
                if (direction.Y > 0)
                {
                    direction.Y = 0;
                }
            }
            if (!_canLeft)
            {
                if (direction.X < 0)
                {
                    direction.X = 0;
                }
            }
            if (!_canRight)
            {
                if (direction.X > 0)
                {
                    direction.X = 0;
                }
            }

            EnemySprite.X += _speed * direction.X;
            EnemySprite.Y += _speed * direction.Y;

            UpdateRay(direction * _speed);
        }
Пример #3
0
        private void Attack(GameTime gametime)
        {
            firetimer += gametime.ElapsedGameTime.TotalSeconds;
            if (firetimer >= firetime)
            {
                firetimer = 0.0f;
                Hero.Hero hero = GameManager.GetInstance().Player;
                var       temp = FindHero(hero);

                Vector2 heroposition = new Vector2(temp.X, temp.Y);
                Vector2 direction    = heroposition - EnemySprite.Position;
                direction.Normalize();
                EnemyBulletObject.EnemyBullet1 bullet = new EnemyBulletObject.EnemyBullet1(EnemySprite.Position, 10, 10, new Vector2(direction.X * _bulletspeed, direction.Y * _bulletspeed), 0, new Vector2(0, 0), new Vector2(1, 1), Color.White, true);
                GameManager.GetInstance().AddEnemyBullet(bullet);
            }
        }
Пример #4
0
        public override void Equip(Hero.Hero hero)
        {
            var     temp         = hero.HeroSprite.Center;
            Vector2 tempPosition = new Vector2(temp.X, temp.Y + 50);

            WeaponSprite.Position = tempPosition;


            Vector2 tempVelocity = new Vector2(hero.HeroSprite.SpeedX, hero.HeroSprite.SpeedY);

            WeaponSprite.Velocity = tempVelocity;

            float tempRotation = hero.HeroSprite.Rotation;

            WeaponSprite.Rotation = tempRotation;
            WeaponSprite.IsLive   = true;
            WeaponSprite.Update();
        }
Пример #5
0
 public Vector2 FindHero(Hero.Hero hero)
 {
     return(hero.HeroSprite.Position);
 }
Пример #6
0
 public abstract void Equip(Hero.Hero hero);
Пример #7
0
 public void AddPlayer(Hero.Hero player)
 {
     _player = player;
 }