コード例 #1
0
        public GameScreen()
        {
            Paused        = false;
            currentCanvas = null;
            movementSpeed = 0.25;
            movementWait  = 0.0;
            translation   = Vector2.Zero;

            movementVectors = new Vector2[4]
            {
                new Vector2(0, 1),
                new Vector2(-1, 0),
                new Vector2(1, 0),
                new Vector2(0, -1)
            };

            if (GameManager.Instance.PlayerData == null)
            {
                GameManager.Instance.PlayerData = XmlManager.Instance.Load <Player>("Data/save" +
                                                                                    GameManager.Instance.GameSaveID.ToString() + ".xml");
            }

            player = GameManager.Instance.PlayerData;

            GameManager.Instance.LoadWorld(player.Location);
            world = GameManager.Instance.World;

            playerImage = new Image("Character/" + player.BodyType, new Rectangle(32, 0, 32, 32),
                                    Vector2.Zero, 64, 64);
            playerImage.AddEffect("AnimationSheetEffect");
            locationName       = new Text(world.Name, "Expression-pro-32px");
            locationName.Color = Color.White;
        }
コード例 #2
0
        void ChoosePlayer(GameTime gameTime)
        {
            if (playerMokepon == null)
            {
                if (currentCanvas == null)
                {
                    bool lost = true;
                    foreach (var pok in player.Mokepons)
                    {
                        if (pok.HP > 0)
                        {
                            lost = false;
                        }
                    }

                    if (lost)
                    {
                        currentState = BattleState.LOST;
                        return;
                    }

                    currentCanvas = new PlayerChooseMokeponCanvas(player.Mokepons);
                    currentCanvas.LoadContent();
                }

                currentCanvas.Update(gameTime);

                if ((currentCanvas as PlayerChooseMokeponCanvas).MokeponChosen == true)
                {
                    playerMokepon = player.Mokepons[(currentCanvas as PlayerChooseMokeponCanvas).Choice];

                    currentCanvas.UnloadContent();
                    currentCanvas = null;
                    GC.Collect();

                    Dialogues.AddText(string.Format("Go! {0}!", playerMokepon.Name));
                    Dialogues.DisplayNext();

                    playerMokeponImage = new Image("Mokepons/" + playerMokepon.DefaultName);
                    playerMokeponImage.LoadContent();
                    playerMokeponImage.MoveMid(new Vector2(Globals.ScreenWidth / 4, 3 * Globals.ScreenHeight / 4 - 100));
                    PulseEffect pulse = new PulseEffect(2f, 1.5);
                    playerMokeponImage.AddEffect("PulseEffect", ref pulse);
                    playerMokeponImage.ActivateEffect("PulseEffect");

                    playerStats = new MokeponBattleStats(ref playerMokepon, new Vector2(500, 400), true);
                    playerStats.LoadContent();
                    wait = 3.0;
                    SwitchState(BattleState.CHOOSE_ACTION);
                    return;
                }
            }
            else
            {
                SwitchState(BattleState.CHOOSE_ACTION);
                return;
            }
        }
コード例 #3
0
        public DemoScreen()
        {
            Images = new Dictionary <string, Image>();

            Image mainImage = new Image("MonoGameTools", new Vector2(10, 10),
                                        Vector2.One, centerOrigin: false);
            Image fadeImage = new Image("FadeEffect", new Vector2(30, 60),
                                        Vector2.One, false, centerOrigin: false);
            Image flashImage = new Image("FlashEffect", new Vector2(30, 110),
                                         Vector2.One, false, centerOrigin: false);
            Image zoomImage = new Image("ZoomEffect", new Vector2(30, 160),
                                        Vector2.One, false, centerOrigin: false);

            fadeImage.AddEffect <FadeEffect>("fadeEffect", new FadeEffect(
                                                 repeat: true));
            flashImage.AddEffect <FlashEffect>("flashEffect", new FlashEffect(
                                                   0.5f, minimumAlpha: .25f, repeat: true));
            zoomImage.AddEffect <ZoomEffect>("zoomEffect", new ZoomEffect(
                                                 new Vector2(0.25f, 0.25f), new Vector2(1.0f, 1.0f),
                                                 repeat: true));

            Images.Add("mainImage", mainImage);
            Images.Add("fadeImage", fadeImage);
            Images.Add("flashImage", flashImage);
            Images.Add("zoomImage", zoomImage);

            button = new Button(new Vector2(200, 25), new Vector2(400, 10),
                                "Test Button", Color.Black, "Arial", Color.White, new Border(Color.Black,
                                                                                             new Thickness(2)));
            button.TextAlignment = Alignment.MiddleCenter;

            cursor = new Cursor("cursor");

            button.Click      += button_Click;
            button.MouseEnter += button_MouseEnter;
            button.MouseLeave += button_MouseLeave;
        }
コード例 #4
0
        /// <summary>
        /// Loads content for the active screen.
        /// </summary>
        /// <param name="contentManager">Content manager object.</param>
        public void LoadContent(ContentManager contentManager)
        {
            // Set content manager reference
            this.contentManager = contentManager;

            // Create texture for screen transitions
            Texture2D transitionTexture = new Texture2D(graphicsDevice, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height,
                                                        false, SurfaceFormat.Color);

            Color[] colors = new Color[transitionTexture.Width * transitionTexture.Height];
            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = Color.Black;
            }

            transitionTexture.SetData(colors);
            transitionTextureImage = new Image(transitionTexture);
            transitionTextureImage.LoadContent(contentManager);
            transitionTextureImage.Alpha = 0.0f;

            // Pulse effect used for fading during screen transitions
            PulseEffect pulseEffect = new PulseEffect();

            pulseEffect.MaxAlphaReached += transition_FadeFull;
            pulseEffect.MinAlphaReached += transition_Done;
            pulseEffect.PulseSpeed       = 2.0f;
            transitionTextureImage.AddEffect <PulseEffect>(ref pulseEffect, "PulseEffect");

            transitionTextureImage.DeactivateEffect("PulseEffect");

            // Load content for the current screen
            if (currentScreen != null)
            {
                currentScreen.LoadContent(contentManager);
            }
        }
コード例 #5
0
        void ChooseEnemy(GameTime gameTime)
        {
            if (enemyMokepon == null)
            {
                if (enemy.Mokepons.Count == 0)
                {
                    SwitchState(BattleState.WON);
                    return;
                }

                foreach (var mok in enemy.Mokepons)
                {
                    if (mok.HP > 0)
                    {
                        enemyMokepon = mok;
                        break;
                    }
                }

                Dialogues.AddText(string.Format(enemy.MokeponChoiceText, enemyMokepon.Name));
                Dialogues.DisplayNext();

                enemyMokeponImage = new Image("Mokepons/" + enemyMokepon.Name);
                enemyMokeponImage.LoadContent();
                enemyMokeponImage.MoveMid(new Vector2(3 * Globals.ScreenWidth / 4, Globals.ScreenHeight / 4));
                PulseEffect pulse = new PulseEffect(2f, 1.5);
                enemyMokeponImage.AddEffect("PulseEffect", ref pulse);
                enemyMokeponImage.ActivateEffect("PulseEffect");

                enemyStats = new MokeponBattleStats(ref enemyMokepon, new Vector2(450, 100));
                enemyStats.LoadContent();
                wait = 3.0;
            }

            SwitchState(BattleState.PLAYER_CHOICE);
        }
コード例 #6
0
        void ChooseAction(GameTime gameTime)
        {
            if (!MoveChosen)
            {
                if (currentCanvas == null)
                {
                    Dialogues.AddText("What will " + playerMokepon.Name + " do?");
                    Dialogues.DisplayNext();
                    currentCanvas = new PlayerActionChoiceCanvas(player, playerMokepon);
                    currentCanvas.LoadContent();
                }

                currentCanvas.Update(gameTime);
            }
            else
            {
                if (currentCanvas.GetType() == typeof(PlayerActionChoiceCanvas))
                {
                    currentCanvas.UnloadContent();
                    currentCanvas = null;
                    GC.Collect();
                }

                if (PlayerMove == "Run")
                {
                    foreach (var pok in player.Mokepons)
                    {
                        pok.HP = 0;
                    }

                    Dialogues.AddText(player.Name + " has fled from the battle!");
                    Dialogues.AddText(player.Name + "\'s Mokepons have fainted!");
                    Dialogues.DisplayNext();
                    wait = 3.0;
                    SwitchState(BattleState.LOST);
                    return;
                }
                else if (PlayerMove == "SwitchMokepon")
                {
                    if (currentCanvas == null)
                    {
                        currentCanvas = new PlayerChooseMokeponCanvas(player.Mokepons, playerMokepon);
                        currentCanvas.LoadContent();
                    }

                    if ((currentCanvas as PlayerChooseMokeponCanvas).MokeponChosen == false)
                    {
                        currentCanvas.Update(gameTime);
                    }

                    if ((currentCanvas as PlayerChooseMokeponCanvas).MokeponChosen == true)
                    {
                        if (playerMokepon != null)
                        {
                            hideCanvas = true;
                            Dialogues.AddText(playerMokepon.Name + ", go back!");
                            Dialogues.DisplayNext();
                            playerMokepon = null;
                            playerMokeponImage.UnloadContent();
                            playerMokeponImage = null;
                            playerStats.UnloadContent();
                            playerStats = null;
                            GC.Collect();
                            wait = 3.0;
                            return;
                        }

                        playerMokepon = player.Mokepons[(currentCanvas as PlayerChooseMokeponCanvas).Choice];
                        currentCanvas.UnloadContent();
                        currentCanvas = null;
                        hideCanvas    = false;
                        GC.Collect();

                        playerMokeponImage = new Image("Mokepons/" + playerMokepon.DefaultName);
                        playerMokeponImage.LoadContent();
                        playerMokeponImage.MoveMid(new Vector2(Globals.ScreenWidth / 4, 3 * Globals.ScreenHeight / 4 - 100));
                        PulseEffect pulse = new PulseEffect(2f, 1.5);
                        playerMokeponImage.AddEffect("PulseEffect", ref pulse);
                        playerMokeponImage.ActivateEffect("PulseEffect");

                        playerStats = new MokeponBattleStats(ref playerMokepon, new Vector2(500, 400), true);
                        playerStats.LoadContent();

                        Dialogues.AddText(string.Format("Go! {0}!", playerMokepon.Name));
                        Dialogues.DisplayNext();
                        wait         = 3.0;
                        EnemyMove    = EnemyAI.ChooseMove(enemyMokepon, playerMokepon, enemy.AILevel);
                        enemyAbility = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + EnemyMove));
                        SwitchState(BattleState.USE_ABILITIES);
                        return;
                    }
                }
                else if (PlayerMove == "Wait")
                {
                    Dialogues.AddText(playerMokepon.Name + " decides to wait!");
                    Dialogues.DisplayNext();
                    wait         = 3.0;
                    EnemyMove    = EnemyAI.ChooseMove(enemyMokepon, playerMokepon, enemy.AILevel);
                    enemyAbility = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + EnemyMove));
                    SwitchState(BattleState.USE_ABILITIES);
                    return;
                }
                else if (PlayerMove.StartsWith("Item_"))
                {
                    string[] strings = PlayerMove.Split('_');
                    EnemyMove     = EnemyAI.ChooseMove(enemyMokepon, playerMokepon, enemy.AILevel);
                    enemyAbility  = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + EnemyMove));
                    playerAbility = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + strings[2]));
                    playerAbility.UsedWithItem = true;
                    playerAbility.ItemName     = strings[1];
                    SwitchState(BattleState.USE_ABILITIES);
                    return;
                }
                else
                {
                    EnemyMove     = EnemyAI.ChooseMove(enemyMokepon, playerMokepon, enemy.AILevel);
                    enemyAbility  = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + EnemyMove.Replace(" ", "")));
                    playerAbility = (Ability)Activator.CreateInstance(Type.GetType("MokeponGame.Gameplay.Abilities." + PlayerMove.Replace(" ", "")));
                    SwitchState(BattleState.USE_ABILITIES);
                    return;
                }
            }
        }