示例#1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (currentState == gameState.overworld)
            {
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    Exit();
                }

                // TODO: Add your update logic here
                OUInput(gameTime);
                player.Update(gameTime);

                base.Update(gameTime);

                if (player.isCleared())
                {
                    Tiles = level1.map();
                    player.newLevel();
                    player.jumpRegardless(level1.getSpawn());
                    player.setExit(level1.getExit());
                    cPos      = new Vector2(spawn.X - (vPort.X / 2), spawn.Y - (vPort.Y / 2) + 1);
                    enemyList = level1.getEnemies();
                    FoW       = new int[Consts.mapWidth, Consts.mapHeight];
                    score    += 100;
                }

                if (!player.isMove)
                {
                    for (int i = 0; i < enemyList.Length; i++)
                    {
                        if (enemyList[i] != null)
                        {
                            if (player.TargetPosition / 10 == enemyList[i].GridPosition)
                            {
                                if (enemyList[i].hit(player.Dmg) <= 0)
                                {
                                    score       += (enemyList[i].SV);
                                    enemyList[i] = enemyDeath(enemyList[i]);
                                    continue;
                                }
                            }


                            //get next tile from brain.
                            //brain.Build(Tiles, enemyList[i], player);

                            int numAtks = enemyList[i].doMonsterTurn(player, Tiles);

                            if (numAtks != 0)
                            {
                                //replace with "go to combat screen for that enemy and player".
                                if (player.hit(enemyList[i].Atk * numAtks) <= 0)
                                {
                                    gameOver = true;
                                }
                            }
                        }
                    }
                    player.isMove = true;
                }

                clearFoW();
            }
            else if (currentState == gameState.combat)
            {
                //COMBAT UPDATE JUMPTO
            }
        }