Beispiel #1
0
        private void Move()
        {
            //Do this for first 0.5 seconds of life
            if (tiBirth.ElapsedSoFar < 0.5)
            {
                RotationHelper.VelocityInThisDirection(this, direction, 500);
            }
            //Then do this
            else
            {
                RotationVelocity = 45f;
            }

            //For shooting
            //Every 5 seconds
            if (tiBirth.ElapsedSoFar > 2.5)
            {
                if (GM.eventM.Elapsed(tiShootCooldown))
                {
                    Vector3 front3d  = Position + RotationHelper.MyDirection(this, 0);
                    Vector3 bottom3d = Position + RotationHelper.MyDirection(this, 180);
                    Vector2 front    = new Vector2(front3d.X, front3d.Y);
                    Vector2 bottom   = new Vector2(bottom3d.X, bottom3d.Y);


                    new Missile(Position2D, front, this, GameSetup.PlayerChar, 500, 500, 20, 20);
                    new Missile(Position2D, bottom, this, GameSetup.PlayerChar, 500, 500, 20, 20);
                    new Bullet(this, bottom, 1500f, 2);
                }
            }

            //Every 10 seconds
            if (tiBirth.ElapsedSoFar >= 10)
            {
                GM.eventM.AddEventRaiseOnce(tiBirth = new Event(10f, "Birth timer"));

                direction = Vector3.Zero;

                if (Position.X <= GM.screenSize.Center.X)
                {
                    direction.X += 1;
                }
                else
                {
                    direction.X -= 1;
                }
                if (Position.Y <= GM.screenSize.Center.Y)
                {
                    direction.Y += 1;
                }
                else
                {
                    direction.Y -= 1;
                }
                direction.Normalize();
            }
        }
Beispiel #2
0
        public SmokeParticle(Vector2 spawnPos, Vector3 spawnVel, Vector2 spawnRot, float lifetime)
        {
            GM.eventM.AddEvent(tiLifetime = new Event(lifetime, "Lifetime Counter"));

            GM.engineM.AddSprite(this);
            Frame.Define(Tex.SingleWhitePixel);
            ScaleBoth = 10;
            Wash      = Color.WhiteSmoke;

            float xRan = GM.r.FloatBetween(-10, 10);
            float yRan = GM.r.FloatBetween(-10, 10);

            RotationHelper.VelocityInThisDirection(this, new Vector3(spawnVel.X + xRan, spawnVel.Y + yRan, 0), 100);

            float rotRan = GM.r.FloatBetween(-10, 10);

            RotationHelper.FaceDirection(this, spawnRot, DirectionAccuracy.free, rotRan);

            Position2D = spawnPos;

            UpdateCallBack += LifeCountdown;
        }
Beispiel #3
0
        private void Move()
        {
            //For gunSprite
            Vector2 playerPos = GameSetup.PlayerChar.Position2D;
            Vector2 direction = playerPos - Position2D;

            direction = Vector2.Normalize(direction);
            RotationHelper.FaceDirection(gunSprite, direction, DirectionAccuracy.free, 0);
            gunSprite.Position2D = Position2D + (direction * 15);
            Vector2 currentPosition = Position2D;

            //For movement:
            float distanceFromPlayer = Vector2.Distance(Position2D, playerPos);

            if (distanceFromPlayer > 200)
            {
                //Move towards player
                RotationHelper.FacePosition(this, GameSetup.PlayerChar.Position, DirectionAccuracy.free, 0, false);
                RotationHelper.VelocityInCurrentDirection(this, 500, 0);
            }
            if (distanceFromPlayer < 400)
            {
                //Switch strafe direction after 2 seconds
                int dirMultiplier = 1;
                if (tiSwitchDirection.ElapsedSoFar > 2)
                {
                    dirMultiplier = -1;
                }
                RotationHelper.VelocityInThisDirection(this, RotationHelper.MyDirection(this, dirMultiplier * 60), 250);

                //For firing
                if (GM.eventM.Elapsed(tiShootCooldown))
                {
                    //create bullet and pass reference to player and angle
                    new Bullet(this, playerPos, 1000f, 10);
                }
            }
        }
Beispiel #4
0
        private void Move()
        {
            //Do this for first 0.5 seconds of life
            if (tiBirth.ElapsedSoFar < 0.5)
            {
                RotationHelper.VelocityInThisDirection(this, direction, 500);
            }
            //Then do this
            else
            {
                if (fourBeams)
                {
                    RotationVelocity = 22.5f;
                }
                else
                {
                    RotationVelocity = 45f;
                }
            }

            //For shooting
            //Every 5 seconds
            if (tiBirth.ElapsedSoFar > 2.5)
            {
                if (GM.eventM.Elapsed(tiShootCooldown))
                {
                    //1 laser
                    Vector3 front3d  = Position + RotationHelper.MyDirection(this, 0);
                    Vector3 bottom3d = Position + RotationHelper.MyDirection(this, 180);
                    Vector2 front    = new Vector2(front3d.X, front3d.Y);
                    Vector2 bottom   = new Vector2(bottom3d.X, bottom3d.Y);


                    new Bullet(this, front, 1500f, 2);
                    new Bullet(this, bottom, 1500f, 2);
                    //4 lasers
                    if (fourBeams)
                    {
                        Vector3 left3d  = Position + RotationHelper.MyDirection(this, 90);
                        Vector3 right3d = Position + RotationHelper.MyDirection(this, 270);
                        Vector2 left    = new Vector2(left3d.X, left3d.Y);
                        Vector2 right   = new Vector2(right3d.X, right3d.Y);

                        new Bullet(this, left, 1000f, 2);
                        new Bullet(this, right, 1000f, 2);
                    }
                }
            }

            //Every 10 seconds
            if (tiBirth.ElapsedSoFar >= 10)
            {
                GM.eventM.AddEventRaiseOnce(tiBirth = new Event(10f, "Birth timer"));

                direction = Vector3.Zero;

                if (Position.X <= GM.screenSize.Center.X)
                {
                    direction.X += 1;
                }
                else
                {
                    direction.X -= 1;
                }
                if (Position.Y <= GM.screenSize.Center.Y)
                {
                    direction.Y += 1;
                }
                else
                {
                    direction.Y -= 1;
                }
                direction.Normalize();
            }
        }