Beispiel #1
0
        public override ArrayList getAttacks(Vector2 playerPos)
        {
            float dx   = position.X - playerPos.X;
            float dy   = position.Y - playerPos.Y;
            float dist = (float)Math.Sqrt(dx * dx + dy * dy);

            if ((!attacking) && (dist <= actiondistance || life < startinglife))
            {
                ArrayList attacks   = new ArrayList();
                EnemyShot theattack = new EnemyShot();

                theattack.position   = this.position;
                theattack.velocity.X = -dx / dist * attackvelocity;
                theattack.velocity.Y = -dy / dist * attackvelocity;
                theattack.setTextures(shotTex);

                attacks.Add(theattack);

                attacking   = true;
                attacktimer = 0;

                return(attacks);
            }
            return(null);
        }
Beispiel #2
0
        public override ArrayList getAttacks(Vector2 playerPos)
        {
            ArrayList attacks = new ArrayList();
            //Create shots for shots attack
            float dx = position.X - playerPos.X;

            if (currentstate == BossState.shots)
            {
                EnemyShot attack  = new EnemyShot();
                EnemyShot attack2 = new EnemyShot();
                EnemyShot attack3 = new EnemyShot();
                attack.setTextures(shotTex);
                attack2.setTextures(shotTex);
                attack3.setTextures(shotTex);
                //set shots X axis data
                if (dx > 0)
                {
                    attack.velocity.X  = -shotvx;
                    attack.position.X  = bbox.Center.X - (attack.bbox.Width / 2);
                    attack2.velocity.X = -shotvx;
                    attack2.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                    attack3.velocity.X = -shotvx;
                    attack3.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                }
                else
                {
                    attack.velocity.X  = shotvx;
                    attack.position.X  = bbox.Center.X - (attack.bbox.Width / 2);
                    attack2.velocity.X = shotvx;
                    attack2.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                    attack3.velocity.X = shotvx;
                    attack3.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                }
                //set shots Y axis data
                attack2.velocity.Y = -shotvy;
                attack3.velocity.Y = shotvy;
                attack.position.Y  = bbox.Center.Y - (attack.bbox.Width / 2);
                attack2.position.Y = bbox.Center.Y - (attack.bbox.Width / 2);
                attack3.position.Y = bbox.Center.Y - (attack.bbox.Width / 2);

                //add shots
                attacks.Add(attack);
                attacks.Add(attack2);
                attacks.Add(attack3);
                fired = true;
                return(attacks);
            }
            else if (currentstate == BossState.volley)
            {
                EnemyShot attack  = new EnemyShot();
                EnemyShot attack2 = new EnemyShot();
                EnemyShot attack3 = new EnemyShot();
                attack.setTextures(shotTex);
                attack2.setTextures(shotTex);
                attack3.setTextures(shotTex);
                //set shots X axis data
                if (dx > 0)
                {
                    attack.velocity.X  = -volleyvx;
                    attack.position.X  = bbox.Center.X - (attack.bbox.Width / 2);
                    attack2.velocity.X = -(volleyvx + 50);
                    attack2.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                    attack3.velocity.X = -(volleyvx - 50);
                    attack3.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                }
                else
                {
                    attack.velocity.X  = volleyvx;
                    attack.position.X  = bbox.Center.X - (attack.bbox.Width / 2);
                    attack2.velocity.X = (volleyvx + 50);
                    attack2.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                    attack3.velocity.X = (volleyvx - 50);
                    attack3.position.X = bbox.Center.X - (attack.bbox.Width / 2);
                }
                //set shots Y axis data
                attack.velocity.Y      = -volleyvy;
                attack2.velocity.Y     = -volleyvy;
                attack3.velocity.Y     = -volleyvy;
                attack.acceleration.Y  = volleyacc;
                attack2.acceleration.Y = volleyacc;
                attack3.acceleration.Y = volleyacc;
                attack.position.Y      = bbox.Center.Y - (attack.bbox.Width / 2);
                attack2.position.Y     = bbox.Center.Y - (attack.bbox.Width / 2);
                attack3.position.Y     = bbox.Center.Y - (attack.bbox.Width / 2);

                //add shots
                attacks.Add(attack);
                attacks.Add(attack2);
                attacks.Add(attack3);
                fired = true;
                return(attacks);
            }

            return(null);
        }