Пример #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            //draw select screen
            //also have to check if currentScreen isDone before moving to next screen which would be a surrounding if statement
            //within the surrounding if statement, set value of current screen to true
            if (currentScreen.isDone)
            {
                if (main == null && following == null)
                {
                    if (currentScreen.data.Equals("Gio") && currentScreen.data != null)
                    {
                        following = new FollowingSprite(emberCharacter, 500, 499);
                        main      = new MainSprite(gioCharacter, following, 500, 500);
                    }
                    else
                    {
                        following = new FollowingSprite(gioCharacter, 350, 349);
                        main      = new MainSprite(emberCharacter, following, 350, 350);
                    }
                }

                currentScreen.UnloadContent();
                //I don't think we need to loop through it?
                foreach (string entry in screens)
                {
                    Type screenType = Type.GetType("firstrate.screens." + entry);
                    currentScreen = (Screen)Activator.CreateInstance(screenType, Content);
                    break;
                }

                /*  Type screenType = Type.GetType("firstrate.screens." + screens[0]);
                 * currentScreen = (Screen)Activator.CreateInstance(screenType, Content);
                 */
                screens.RemoveAt(0);
            }


            currentScreen.Draw(spriteBatch);


            if (main != null)
            {
                if (following.y <= main.y)
                {
                    following.Draw(spriteBatch);
                    main.Draw(spriteBatch);
                }
                else
                {
                    main.Draw(spriteBatch);
                    following.Draw(spriteBatch);
                }
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
        private void LoadSprites(int spriteCount)
        {
            Random rand         = new Random();
            double canvasWidth  = HtmlCanvas1.ActualWidth;
            double canvasHeight = HtmlCanvas1.ActualHeight;

            // Remove the previous sprites, if any:
            HtmlCanvas1.Children.Clear();

            // Create the sprites:
            for (int i = 0; i < spriteCount; i += 1)
            {
                // Create a new sprite:
                var sprite = new MainSprite(i);

                // Set its position randomly:
                sprite.X = rand.Next((int)canvasWidth - (int)sprite.Width);
                sprite.Y = rand.Next((int)canvasHeight - (int)sprite.Height);

                // Set its velocity randomly:
                sprite.VelocityX = rand.Next(-10, 10);
                sprite.VelocityY = rand.Next(-10, 10);

                // Add the sprite to the HtmlCanvas:
                HtmlCanvas1.Children.Add(sprite);
            }
        }
Пример #3
0
        public override void Update(float gameTime, MainSprite main)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            if (oldState.IsKeyUp(Keys.D) && keyboardState.IsKeyDown(Keys.D))
            {
                selectorX = 356;
            }
            if (oldState.IsKeyUp(Keys.A) && keyboardState.IsKeyDown(Keys.A))
            {
                selectorX = 172;
            }
            if (oldState.IsKeyUp(Keys.Enter) && keyboardState.IsKeyDown(Keys.Enter))
            {
                if (selectorX == 356)
                {
                    data = "Ember";
                }
                else
                {
                    data = "Gio";
                }

                isDone = true;
            }
            oldState = keyboardState;
        }
Пример #4
0
 protected void Add <TSprite>(TSprite sprite)
     where TSprite : Sprite
 {
     sprite.Ready();
     sprites.Add(sprite);
     if (sprite is MainSprite)
     {
         mainSprite = (MainSprite)(object)sprite;
     }
 }
Пример #5
0
        public override void Update(float gameTime, MainSprite main)
        {
            //talking to dogs
            KeyboardState keyboardState = Keyboard.GetState();

            if (data.Equals("Dave"))
            {
                Console.WriteLine("You reached the exit");
                if (oldState.IsKeyUp(Keys.Enter) && keyboardState.IsKeyDown(Keys.Enter))
                {
                    //lock the character's animation and allow the dialog box to be drawn
                    drawDialog  = true;
                    main.locked = true;
                    dialogReader.nextLine();

                    //reset the dialog reader and unlock character animation once we've reached the end of the dialog
                    if (dialogReader.isDialogDone())
                    {
                        main.locked  = false;
                        drawDialog   = false;
                        dialogReader = new DialogReader();
                        dialogReader.getDialog(@"C:\Users\ember\source\repos\firstrate\Content\TestDialog.txt");
                    }
                }
            }

            if (drawDialog)
            {
                currentDialog = dialogReader.typeLine(animationTimer);
            }

            //check if they are at the exit
            if (data.Equals("Exit"))
            {
                // isDone = true;
                Console.WriteLine("You reached the exit"); //never reaching this point -- have to remember how data is set
            }


            //dog animation
            animationTimer += gameTime;
            if (animationTimer > 450)
            {
                daveAnimation.Update();
                animationTimer = 0;
            }

            oldState = keyboardState;
        }
Пример #6
0
 public virtual void Update(float gameTime, MainSprite main)
 {
 }