Beispiel #1
0
        protected override void Update(GameTime gameTime)
        {
            if (ControllerInput.Instance().GetButton(Buttons.A).Released || exit)
            {
                this.Exit();
            }


            Random rand = new Random(Utilities.Instance().ElapsedTime().Milliseconds);

            if (Utilities.Instance().ElapsedTime().Seconds >= rand.Next(1, 2))
            {
                Enemy barge = (new Enemy(5, 5, 5, Attributes.AttackType.Melee, "Red", Attributes.Weapons.Axe, 0, 5));

                barge.kinetics.position = new Vector2((float)rand.NextDouble() * 1024, (float)rand.NextDouble() * 768);
                LevelManager.Instance().getCurrentLevel().InsertGameObject(barge);
                SoundManager.Instance().AddSound(new SFX("SFX\\arrowhit"));
                Utilities.Instance().RestartWatch();
            }


            ControllerInput.Instance().Update();

            LevelManager.Instance().Update();
            LevelManager.Instance().getCurrentLevel().Collision();
            SoundManager.Instance().Update();
            Cam.Update();
            Vector2 displacement = (temp.kinetics.position - Avatar.Instance().kinetics.position) / 2.0f;
            Vector2 position     = Avatar.Instance().kinetics.position + displacement;

            Cam.SetTarget(position);
            spawner.Update();            base.Update(gameTime);
        }
Beispiel #2
0
        protected override void LoadContent()
        {
            ControllerInput.Instance();
            Avatar.Instance();
            Level level = new Level(10, 10, 60);

            level.InsertGameObject(Avatar.Instance());
            temp = new Shadow();
            level.InsertGameObject(temp);
            level.InsertGameObject(new Enemy(5, 5, 5, Attributes.AttackType.Melee, "Red", Attributes.Weapons.Axe, 0, 5));
            LevelManager.Instance().SetLevel(level);
            SoundManager.Instance();
            SoundManager.Instance().BGM(new SongTrack("BGM\\BossBattle"));
            SoundManager.Instance().BGM().Play();
            SoundManager.Instance().Volume(.1f);
            Utilities.Instance().StartWatch();
            exit       = false;
            background = content.Load <Texture2D>(@"Background\background-0");
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            graphics.ApplyChanges();


            Cam = new Camera(Avatar.Instance().kinetics.position, new Rectangle(0, 0, background.Width, background.Height));

            spriteBatch = new SpriteBatch(GraphicsDevice);
        }
Beispiel #3
0
        public override void Update()
        {
            float speed = 5;

            kinetics.velocity.X = ControllerInput.Instance().Sticks.Right.X *speed;
            kinetics.velocity.Y = -ControllerInput.Instance().Sticks.Right.Y *speed;

            if (ControllerInput.Instance().GetKey(Keys.Left).Held)
            {
                kinetics.velocity.X = -speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Right).Held)
            {
                kinetics.velocity.X = speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Down).Held)
            {
                kinetics.velocity.Y = speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Up).Held)
            {
                kinetics.velocity.Y = -speed;
            }

            Attack();

            LevelBoundingBox();

            kinetics.Update();

            if (Melee)
            {
                if (currentAnimation.Finished())
                {
                    currentAnimation = walk;
                    currentAnimation.Reset();
                    Melee = false;
                }
            }

            if (Magic)
            {
                if (currentAnimation.Finished())
                {
                    currentAnimation = walk;
                    currentAnimation.Reset();
                    Magic = false;
                }
            }

            currentAnimation.Update(kinetics);
            if (Vector2.Distance(kinetics.position, Avatar.Instance().kinetics.position) < 50)
            {
                Avatar.Instance().health.grow(.05f);
            }
        }
Beispiel #4
0
        public override void Attack()
        {
            if (ControllerInput.Instance().GetButton(Buttons.X).Pressed&& !Magic ||
                ControllerInput.Instance().GetKey(Keys.X).Pressed&& !Magic)
            {
                DamageBox temp = new DamageBox(kinetics.position + kinetics.orientations.GetVecOrientation() * 100, Vector2.Zero, 3, true);
                LevelManager.Instance().getCurrentLevel().InsertGameObject(temp);
                SoundManager.Instance().AddSound(new SFX("SFX\\swing"));
                Melee            = true;
                currentAnimation = attack;
                currentAnimation.Reset();
            }

            if (ControllerInput.Instance().GetButton(Buttons.RightShoulder).Pressed)
            {
                still = !still;
            }

            if (still)
            {
                if (kinetics.velocity != Vector2.Zero)
                {
                    kinetics.orientations.SetOrientation(kinetics.velocity);
                    kinetics.velocity = Vector2.Zero;
                }
            }


            if (ControllerInput.Instance().GetButton(Buttons.RightTrigger).Held&& !Melee ||
                ControllerInput.Instance().GetKey(Keys.Z).Pressed&& !Melee)
            {
                still = true;
                if (timer > 15)
                {
                    FireBall fireBall = new FireBall(kinetics.position, kinetics.orientations.GetVecOrientation() * 30, 30, true);
                    LevelManager.Instance().getCurrentLevel().InsertGameObject(fireBall);
                    SoundManager.Instance().AddSound(new SFX("SFX\\fireball"));
                    Magic            = true;
                    currentAnimation = magic;
                    currentAnimation.Reset();
                    timer = 0;
                }
                else
                {
                    timer++;
                }
            }
            if (ControllerInput.Instance().GetButton(Buttons.RightTrigger).Released)
            {
                timer = 15;
                still = false;
            }
        }
Beispiel #5
0
        protected override void Update(GameTime gameTime)
        {
            if (ControllerInput.Instance().GetButton(Buttons.A).Released)
            {
                this.Exit();
            }

            if (ControllerInput.Instance().GetButton(Buttons.Y).Released ||
                ControllerInput.Instance().GetKey(Keys.Space).Released)
            {
                LevelManager.Instance().getCurrentLevel().InsertGameObject(new Enemy(5, 5, 5, Attributes.AttackType.Melee, "Red", Attributes.Weapons.Axe, 0, 5));
                SoundManager.Instance().AddSound(new SFX("SFX\\arrowhit"));
            }

            ControllerInput.Instance().Update();

            LevelManager.Instance().Update();
            LevelManager.Instance().getCurrentLevel().Collision();
            SoundManager.Instance().Update();
            Cam.Update();
            Cam.SetTarget(Avatar.Instance().kinetics.position);
            spawner.Update();            base.Update(gameTime);
        }
Beispiel #6
0
        public override void Attack()
        {
            if (ControllerInput.Instance().GetButton(Buttons.X).Pressed&& !Magic ||
                ControllerInput.Instance().GetKey(Keys.X).Pressed&& !Magic)
            {
                DamageBox temp = new DamageBox(kinetics.position + kinetics.orientations.GetVecOrientation() * 100, kinetics.orientations.GetVecOrientation(), Vector2.Zero, 3, true);
                LevelManager.Instance().getCurrentLevel().InsertGameObject(temp);
                SoundManager.Instance().AddSound(new SFX("SFX\\swing"));
                Melee            = true;
                currentAnimation = attack;
                currentAnimation.Reset();
            }

            if (ControllerInput.Instance().GetButton(Buttons.B).Pressed&& !Melee ||
                ControllerInput.Instance().GetKey(Keys.Z).Pressed&& !Melee)
            {
                FireBall fireBall = new FireBall(kinetics.position, kinetics.orientations.GetVecOrientation() * 30, 30, true);
                LevelManager.Instance().getCurrentLevel().InsertGameObject(fireBall);
                SoundManager.Instance().AddSound(new SFX("SFX\\fireball"));
                Magic            = true;
                currentAnimation = magic;
                currentAnimation.Reset();
            }
        }
Beispiel #7
0
        public override void Update()
        {
            float speed = 5;

            hurtTimer.Update();
            if (hurtTimer.Ready())
            {
                color = Color.White;
                hurtTimer.Reset();
                hurtTimer.Puase();
            }
            kinetics.velocity.X = ControllerInput.Instance().Sticks.Left.X *speed;
            kinetics.velocity.Y = -ControllerInput.Instance().Sticks.Left.Y *speed;

            if (ControllerInput.Instance().GetKey(Keys.Left).Held)
            {
                kinetics.velocity.X = -speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Right).Held)
            {
                kinetics.velocity.X = speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Down).Held)
            {
                kinetics.velocity.Y = speed;
            }

            if (ControllerInput.Instance().GetKey(Keys.Up).Held)
            {
                kinetics.velocity.Y = -speed;
            }

            Attack();

            LevelBoundingBox();

            kinetics.Update();

            if (Melee)
            {
                if (currentAnimation.Finished())
                {
                    currentAnimation = walk;
                    currentAnimation.Reset();
                    Melee = false;
                }
            }

            if (Magic)
            {
                if (currentAnimation.Finished())
                {
                    currentAnimation = walk;
                    currentAnimation.Reset();
                    Magic = false;
                }
            }

            currentAnimation.Update(kinetics);
        }