Exemple #1
0
        public void LoadContent(string path, Vector2 position, float movespeed, int maxHealth, int baseMoney, float dps, Behaviour behaviour, bool isally = false)
        {
            base.LoadContent();

            _position      = position;
            Image.Path     = path;
            Image.Position = position;
            Image.LoadContent();
            Image.ActivateEffect("SpriteSheetEffect");
            Image.IsActive = true;
            Image.SpriteSheetEffect.AmountOfFrames = new Vector2(3, 1);
            Image.SpriteSheetEffect.SwitchFrame    = 100;

            _dimensions = new Vector2(Image.SourceRect.Width, Image.SourceRect.Height);
            _baseMoney  = baseMoney;

            this.HitBox = new RectangularHitBox(position, (int)_dimensions.X, (int)_dimensions.Y);

            _moveSpeed  = movespeed;
            _maxHealth  = _health = maxHealth;
            _behaviour  = behaviour;
            _moving     = true;
            _dps        = dps;
            this.IsAlly = isally;

            PhysicsManager.Instance.AddUnit(this);
        }
Exemple #2
0
        public void Update(GameTime gameTime)
        {
            if (locationName != null)
            {
                UpdateLocationName(gameTime);
            }

            if (Paused && currentCanvas != null)
            {
                currentCanvas.Update(gameTime);
            }
            else if (!Paused)
            {
                if (InputManager.Instance.KeysPressed(Keys.Escape))
                {
                    ChangeCanvas("EscapeMenu");
                    return;
                }

                if (InputManager.Instance.KeysPressed(Keys.Enter))
                {
                    int nextX = player.PositionX + (int)movementVectors[player.Direction].X;
                    int nextY = player.PositionY + (int)movementVectors[player.Direction].Y;

                    world.TriggerActions(nextX, nextY);
                    return;
                }

                if (InputManager.Instance.KeysPressed(Keys.Tab))
                {
                    ChangeCanvas("TabMenu");
                    return;
                }

                if (movementWait > 0)
                {
                    movementWait -= gameTime.ElapsedGameTime.TotalSeconds;
                    translation  -= (float)(gameTime.ElapsedGameTime.TotalSeconds / movementSpeed) * movementVectors[player.Direction];
                    playerImage.ActivateEffect("AnimationSheetEffect");

                    if (movementWait <= 0)
                    {
                        playerImage.DeactivateEffect("AnimationSheetEffect");
                        translation       = Vector2.Zero;
                        player.PositionX += (int)(movementVectors[player.Direction].X);
                        player.PositionY += (int)(movementVectors[player.Direction].Y);

                        world.TriggerStepped(player.PositionX, player.PositionY);
                    }
                }

                if (movementWait <= 0)
                {
                    CheckMovement();
                }

                world.Update(gameTime);
                playerImage.Update(gameTime);
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
0
 /// <summary>
 /// Handles a screen changes
 /// </summary>
 /// <param name="screenName">name of the class to load</param>
 public void ChangeScreens(ScreenType type)
 {
     _newScreen                 = _screens[(int)type];
     _image.IsActive            = true;
     _image.FadeEffect.Increase = true;
     _image.Alpha               = 0.0f;
     _image.ActivateEffect("FadeEffect");
     IsTransitioning = true;
 }
Exemple #5
0
        /// <summary>
        /// Changes to another game screen.
        /// </summary>
        /// <param name="newScreen">Name of the screen to change to.</param>
        public void ChangeScreen(string newScreen)
        {
            if (currentScreen != null)
            {
                this.newScreen = newScreen;
                transitioning  = true;

                transitionTextureImage.Alpha = 0.0f;
                transitionTextureImage.ActivateEffect("PulseEffect");
            }
            else
            {
                setNewScreen(newScreen);
            }
        }
Exemple #6
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);
        }
Exemple #7
0
 public void LoadContent()
 {
     Image.LoadContent();
     Image.ActivateEffect("SpriteSheetEffect");
 }
Exemple #8
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;
                }
            }
        }