/// <summary>
        /// Constructor, initializes the manager
        /// </summary>
        public ScreenManager(Game game)
            : base(game)
        {
            base.Initialize();

            //Creates a new InputSystem
            inputSystem = new InputSystem();
            isInitialized = true;
        }
        public override void LoadContent()
        {
            this.input = ScreenManager.InputSystem;
            this.spriteBatch = ScreenManager.SpriteBatch;

            backgrounds = new Background[3];
            backgrounds[0] = new Background(content, "Backgrounds/Background0", 0.2f);
            backgrounds[1] = new Background(content, "Backgrounds/Background1", 0.5f);
            backgrounds[2] = new Background(content, "Backgrounds/Background2", 0.8f);

            //player
            player = new Player(new Vector2(180.0f, 500.0f), ScreenManager, content);

            //timeline
            timeLineTexture = content.Load<Texture2D>("GameAssets/floor");
            timeLineBorder = content.Load<Texture2D>("GameAssets/ProgressBar");

            //health
            arrayHealth[0] = content.Load<Texture2D>("Battery/bat1");
            arrayHealth[1] = content.Load<Texture2D>("Battery/bat2");
            arrayHealth[2] = content.Load<Texture2D>("Battery/bat3");
            arrayHealth[3] = content.Load<Texture2D>("Battery/bat4");
            arrayHealth[4] = content.Load<Texture2D>("Battery/bat5");

            //flag
            flag = new Flag(content, new Vector2(endPositionX, 240));

            //enemyhit
            jejehit = content.Load<Texture2D>("Sprites/jejehit");
        }
Example #3
0
        public void Update(GameTime gameTime, InputSystem input)
        {
            timerpress = true;
            // clock start and update
            if (clockIsRunning == false)
            {
                //count 10 seconds down
                start(2);
                mCurrentState = "Walking";
            }
            else
            {
                checkTime(gameTime);
            }

            PlayerKeysDown(gameTime, input);
            HandleCollision();

            if (isIdle)
            {
                if (sprite.Animation == avoidAnimation)
                {
                    isAvoid = true;
                    if (sprite.FrameIndex >= avoidAnimation.FrameCount - 1)
                    {
                        currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds; //Time passed since last Update()

                        if (currentTime >= countDuration)
                        {

                            currentTime = 0f;
                            sprite.PlayAnimation(idleAnimation);
                        }
                    }
                }

                if (sprite.Animation == attackAnimation)
                {
                    isDestroy = true;
                    if (sprite.FrameIndex >= attackAnimation.FrameCount - 1)
                    {
                        currentTime += (float)gameTime.ElapsedGameTime.TotalSeconds; //Time passed since last Update()

                        if (currentTime >= countDuration)
                        {

                            currentTime = 0f;
                            sprite.PlayAnimation(idleAnimation);
                        }
                    }
                }

            }
        }
Example #4
0
 public void PlayerKeysDown(GameTime gameTime, InputSystem input)
 {
     if (input.Avoid)
     {
         sprite.PlayAnimation(avoidAnimation);
         isIdle = false;
     }
     else if (input.Destroy)
     {
         sprite.PlayAnimation(attackAnimation);
         isIdle = false;
     }
     else
     {
         isAvoid = false;
         isDestroy = false;
         isIdle = true;
     }
 }
        //Moves to a different selected menu item and accepts an item
        public override void HandleInput()
        {
            //Grab a reference to the InputSystem object
            this.input = ScreenManager.InputSystem;

            //If we move up or down, select a different entry
            if (input.MenuUp)
            {
                //ScreenManager.Click.Play();
                selectedEntry--;
                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            if (input.MenuDown)
            {
                //ScreenManager.Click.Play();
                selectedEntry++;
                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // Increment menu state
            if (MenuRightSelect())
            {
                //ScreenManager.Click.Play();
                menuEntries[selectedEntry].Select();
            }

            // Decrement menu state
            if (MenuLeftSelect())
            {
                //ScreenManager.Click.Play();
                menuEntries[selectedEntry].Select();
            }

            //If we press the select button, call the MenuSelect method
            if (input.MenuSelect)
            {
                //ScreenManager.Click.Play();
                menuEntries[selectedEntry].Select();
            }

            //If we press the cancel button, call the MenuCancel method
            if (input.MenuCancel)
            {
                //ScreenManager.Click.Play();
                MenuCancel();
            }
        }