protected override void Update(GameTime gameTime) { if (GameState == gameState.playing) { // Console.Clear(); StupidClass.StupidFunction(ref players, ref currentTurn, Content); if (currentTurn > 4) { currentTurn = 0; } foreach (Player item in players) { item.Update(gameTime, ref currentTurn); } StupidClass.StupidFunction(ref players, ref currentTurn, Content); LvlManager.Update(gameTime); KeyboardState keyState = Keyboard.GetState(); } }
private void moveAndDirection(GameTime gameTime, ref MouseState mouseState, ref KeyboardState keyboardState, ref int currentTurn) { if (!dead) { if (hero.hp <= 0) { dead = true; } if (keyboardState.IsKeyDown(Keys.Space)) { highlightTiles = true; } else { highlightTiles = false; } #region Highlight & Select Tiles if (highlightTiles) { short s = 10; mouseState = Mouse.GetState(); for (int i = 0; i < TileMap.mCells.GetLength(0); i++) { for (int c = 0; c < TileMap.mCells.GetLength(1); c++) { try { //Crashes if mouse goes outside the map while still inside the window. if (TileMap.mCells[Camera.ScreenToWorld(mouseRectangle).X / 64, Camera.ScreenToWorld(mouseRectangle).Y / 64] == TileMap.mCells[i, c]) { Console.WriteLine(TileMap.mCells[i, c].CodeValue); TileMap.mCells[i, c].Tcolor.R = 150; TileMap.mCells[i, c].Tcolor.G = 255; TileMap.mCells[i, c].Tcolor.B = 150; if (mouseState.LeftButton == ButtonState.Pressed) { if (TileMap.mCells[i, c] != tTile2) { tTile1 = TileMap.mCells[i, c]; } else { tTile1 = TileMap.mCells[i, c]; tTile2 = null; } } if (mouseState.RightButton == ButtonState.Pressed) { if (TileMap.mCells[i, c] != tTile1) { tTile2 = TileMap.mCells[i, c]; } else { tTile2 = TileMap.mCells[i, c]; tTile1 = null; } } } else { TileMap.mCells[i, c].Tcolor = Color.White; } } catch { break; } } } } else { foreach (MapSquare item in TileMap.mCells) { item.Tcolor = Color.White; } } #endregion //Mark targeted tile 1 if (tTile1 != null) { tTile1.Tcolor.R = 150; tTile1.Tcolor.G = 150; tTile1.Tcolor.B = 255; } //mark Ttile 2 if (tTile2 != null) { tTile2.Tcolor.R = 255; tTile2.Tcolor.G = 150; tTile2.Tcolor.B = 150; } if (StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this) { if (keyboardState.IsKeyDown(Keys.Up)) { Camera.Move(new Vector2(0, -8)); } if (keyboardState.IsKeyDown(Keys.Down)) { Camera.Move(new Vector2(0, 8)); } if (keyboardState.IsKeyDown(Keys.Left)) { Camera.Move(new Vector2(-8, 0)); } if (keyboardState.IsKeyDown(Keys.Right)) { Camera.Move(new Vector2(8, 0)); } /*Console.Clear(); * Console.WriteLine(hero); * Console.WriteLine("Level: " + hero.level + "\nExp: " + hero.experience + "/" + hero.maxExp); * Console.WriteLine("Hp: " + hero.hp + "/" + hero.maxHp); * Console.WriteLine("Ap: " + hero.ap + "/" + hero.maxAp); * Console.WriteLine("Chance to dodge: " + hero.dodgeChance); * Console.WriteLine("Damage: " + hero.damage); * Console.WriteLine("Range: " + hero.equipment[0].range);*/ } if (!isWizard) { #region Make tiles visible if (xPos > 0 && yPos > 0) { TileMap.mCells[xPos, yPos].visible = true; TileMap.mCells[xPos + 1, yPos].visible = true; TileMap.mCells[xPos - 1, yPos].visible = true; TileMap.mCells[xPos, yPos + 1].visible = true; TileMap.mCells[xPos, yPos - 1].visible = true; TileMap.mCells[xPos + 1, yPos + 1].visible = true; TileMap.mCells[xPos - 1, yPos - 1].visible = true; TileMap.mCells[xPos + 1, yPos - 1].visible = true; TileMap.mCells[xPos - 1, yPos + 1].visible = true; } #endregion //temp skip turn if (StupidClass.CurrentTurn < 5) { if (keyboardState.IsKeyDown(Keys.Escape) && StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0.0f) { hero.ap = 0; StupidClass.inputTimer = 5000; } if (StupidClass.players[StupidClass.CurrentTurn] == this) { ui.Update(ref hero.ap, mouseState, ref hero); } if (mouseState.LeftButton == ButtonState.Pressed && StupidClass.players[StupidClass.CurrentTurn] == this) { moveY = 0; moveX = 0; if (StupidClass.inputTimer <= 0.0f) { if (directionMode) { if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64)))) { hero.dir = 0; hero.Attack(hero, 0); directionMode = false; StupidClass.inputTimer = 4000; hero.ap--; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X - 64, WorldRectangle.Y, 64, 64)))) { hero.dir = 3; hero.Attack(hero, 0); directionMode = false; hero.ap--; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64)))) { hero.dir = 1; hero.Attack(hero, 0); directionMode = false; hero.ap--; StupidClass.inputTimer = 4000; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y + 64, 64, 64)))) { hero.dir = 2; hero.Attack(hero, 0); directionMode = false; hero.ap--; StupidClass.inputTimer = 4000; } } else if (showArrows) { if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64)))) { --moveY; stopStuff = true; stuff(gameTime); StupidClass.inputTimer = 4000; showArrows = false; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X - 64, WorldRectangle.Y, 64, 64)))) { --moveX; stopStuff = true; stuff(gameTime); StupidClass.inputTimer = 4000; showArrows = false; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64)))) { ++moveX; stopStuff = true; stuff(gameTime); StupidClass.inputTimer = 4000; showArrows = false; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y + 64, 64, 64)))) { ++moveY; stopStuff = true; stuff(gameTime); StupidClass.inputTimer = 4000; showArrows = false; } } else // Show move and attack buttons { if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X, WorldRectangle.Y - 64, 64, 64)))) { directionMode = false; showArrows = true; StupidClass.inputTimer = 3000; } else if (mouseRectangle.Intersects(Camera.WorldToScreen(new Rectangle(WorldRectangle.X + 64, WorldRectangle.Y, 64, 64)))) { // ATTACK BUTTON ACTIVATED showArrows = false; directionMode = true; StupidClass.inputTimer = 3000; } } } } else { stopStuff = true; } } if (StupidClass.inputTimer > 0 && StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this) { StupidClass.inputTimer -= 150; } if (stopStuff) { moveX = 0; moveY = 0; updateAnimation(gameTime); stopStuff = false; } if (hero.ap <= 0) { currentTurn++; hero.UpdateStats(); hero.TurnUpdate(); StupidClass.changeVTiles(); } } else//ADD WIZARD UPDATE HERE { foreach (Monster item in Wizard.units) { item.UpdateStats(); if (item.hp <= 0) { Wizard.units.Remove(item); foreach (Player player in StupidClass.players) { player.hero.experience += (short)(item.level * 2); } break; } } if (StupidClass.CurrentTurn < 5) { if (StupidClass.players[StupidClass.CurrentTurn] == this) { if (keyboardState.IsKeyDown(Keys.B)) { Wizard.ap += 1; } foreach (Monster item in Wizard.units) { item.Move(gameTime, ref mouseState); } } if (keyboardState.IsKeyDown(Keys.Escape) && StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0.0f) { StupidClass.inputTimer = 5000; foreach (Monster item in Wizard.units) { item.turnUpdate(); } currentTurn++; Wizard.endTurn(); StupidClass.changeVTiles(); } if (StupidClass.players[StupidClass.CurrentTurn] == this && StupidClass.inputTimer <= 0) { MouseState ms = Mouse.GetState(); WizardUI.Update(ref Wizard.ap, ms, tTile1, tTile2, Content); } if (StupidClass.inputTimer > 0 && StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this) { StupidClass.inputTimer -= 150; } } } } else if (StupidClass.CurrentTurn < 5 && StupidClass.players[StupidClass.CurrentTurn] == this) { currentTurn++; StupidClass.changeVTiles(); } else { xPos = 0; yPos = 0; } }