public void Initialize() { var charactersList = GetAllGameCharacters(GameAuth.GetCurrentGame()); characters = new List <CharacterBlock>(); for (int i = 0; i < charactersList.Count; i++) { characters.Add(new CharacterBlock(charactersList[i], new Vector2(15, 15 + i * 150))); } foreach (CharacterBlock cb in characters) { cb.Initialize(); } bgPosition = Vector2.Zero; shopPosition = new Vector2(screenWidth / 3, screenHeight - 60); backPosition = new Vector2(shopPosition.X + screenWidth / 3, screenHeight - 60); shopString = "Shop"; backString = "Back"; shop = new Button(shopString, shopPosition); back = new Button(backString, backPosition); buttons = new List <Button>(); buttons.Add(shop); buttons.Add(back); shopScreen.Initialize(); }
public void Initialize() { moneyString = "Money: " + GameAuth.GetCurrentGame().Money; moneyPosition = new Vector2(30, screenHeight - 60); bagString = "Items in bag: " + GetItemsCount(GameAuth.GetCurrentGame()); bagPosition = new Vector2(300, screenHeight - 60); closeString = "Close"; closePosition = new Vector2(screenWidth - 100, screenHeight - 60); close = new Button(closeString, closePosition); items = new List <ShopItem>(); List <Item> shopItems = GetAllShopItems(); for (int i = 0, col = 0, row = 0; i < shopItems.Count; col++, i++) { if (col == 4) { row++; col = 0; } Vector2 position = new Vector2(30 + col * 200, 20 + row * 200); items.Add(new ShopItem(shopItems[i], position)); } foreach (ShopItem si in items) { si.Initialize(); } }
public void Update() { moneyString = "Money: " + GetAmountOfMoney(GameAuth.GetCurrentGame()); bagString = "Items in bag: " + GetItemsCount(GameAuth.GetCurrentGame()); foreach (ShopItem si in items) { si.Update(); } close.Update(); }
public void Initialize() { moneyWon = didWin ? "300" : "100"; fightResult = didWin ? "YOU WIN" : "YOU LOSE"; color = didWin ? Color.Black : Color.White; fightResultPos = didWin ? new Vector2(500, 50) : new Vector2(100, 220); moneyWonPos = didWin ? new Vector2(500, 100) : new Vector2(100, 270); highscoreMadePos = didWin ? new Vector2(500, 130) : new Vector2(100, 290); levelValue = GetTotalHighscore(GameAuth.GetCurrentGame(), fighter); levelUpString = "You leveled up - Level: " + levelValue; levelUpStringPos = didWin ? new Vector2(500, 150) : new Vector2(100, 310); escape = "Press Escape For Menu"; escapePos = didWin ? new Vector2(500, 170) : new Vector2(100, 330); }
public void Update() { prevMouseState = MouseState; MouseState = Mouse.GetState(); if (MouseState.X < pos.X || MouseState.Y < pos.Y || MouseState.X > pos.X + font.MeasureString(name).X || MouseState.Y > pos.Y + font.MeasureString(name).Y) { //The mouse is not hovering over the button color = new Color(255, 255, 255); if (StaticBooleans.IsShopOpen) { if (item != null && this.item.Price > GameAuth.GetCurrentGame().Money) { color = new Color(161, 161, 161); } else if (item != null && BagOver4(GameAuth.GetCurrentGame())) { color = new Color(161, 161, 161); } } } else { color = new Color(161, 161, 161); if (MouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released) { switch (name) { case "New Game": NewGame(); break; case "Load Game": StaticBooleans.SetLoadGamesBool(true); break; case "Statistics": StaticBooleans.SetStatBool(true); break; case "Fight": StartFight(this.character, GameAuth.GetCurrentGame()); break; case "Shop": StaticBooleans.SetOpenShopBool(true); break; case "Buy": BuyIfPossible(this.item, GameAuth.GetCurrentGame()); break; case "Close": StaticBooleans.SetOpenShopBool(false); break; case "Back": if (!StaticBooleans.IsShopOpen) { GameAuth.EndGame(); StaticBooleans.SetLoadGamesBool(false); StaticBooleans.SetStatBool(false); } break; default: LoadGame(this.game); break; } } } }
public void Initialize() { fight = FightAuth.GetCurrentFight(); character = new Character(); character = GetCharacterFromFight(fight); map.Initialize(); fighter = new Fighter(character); fighter.Initialize(); enemy = new Enemy(); enemy.Initialize(); drawNames = new DrawNames(fighter.Character, enemy.Character); drawNames.Initialize(); itemsInBag = new List <Item>(); itemsInBag = GetGameItems(GameAuth.GetCurrentGame()); gameItems = new List <GameItem>(); int offset = 0; foreach (Item i in itemsInBag) { gameItems.Add(new GameItem(i, new Vector2(210 + offset, screenHeight - 80))); offset += 110; } foreach (GameItem gi in gameItems) { gi.Initialize(); } control = new Control(fight, fighter, enemy, gameItems); control.Initialize(); InitializeBars(); attacks = new List <Components.Attack>(); basicAttack = new Components.Attack("Basic", new Vector2(340, 90), fighter.Character, fighter.BasicAttack, control); specialAttack = new Components.Attack("Special", new Vector2(410, 90), fighter.Character, fighter.SpecialAttack, control); attacks.Add(basicAttack); attacks.Add(specialAttack); //test playerHealth = control.PlayerHealth.ToString(); playerHealthPos = new Vector2(20, 25); playerMana = control.PlayerMana.ToString(); playerManaPos = new Vector2(20, 55); playerAtk = control.PlayerAtk.ToString(); playerAtkPos = new Vector2(20, 140); playerSpAtk = control.PlayerSpAtk.ToString(); playerSpAtkPos = new Vector2(20, 160); enemyHealth = control.EnemyHealth.ToString(); enemyHealthPos = new Vector2(420, 25); enemyMana = control.EnemyMana.ToString(); enemyManaPos = new Vector2(420, 55); enemyAtk = control.EnemyAtk.ToString(); enemyAtkPos = new Vector2(700, 140); enemySpAtk = control.EnemySpAtk.ToString(); enemySpAtkPos = new Vector2(700, 160); //test numberOne = "1"; numberTwo = "2"; numberThree = "3"; numberFour = "4"; positionOne = new Vector2(230, screenHeight - 30); positionTwo = new Vector2(340, screenHeight - 30); positionThree = new Vector2(450, screenHeight - 30); positionFour = new Vector2(560, screenHeight - 30); }
public void Update(GameTime gameTime, ContentManager Content) { if (hasFightEnded) { if (!hasEndBeenInitialized) { endFightScreen = new EndFightScreen(didWin, highscoreMade.ToString(), fighter); endFightScreen.Initialize(); endFightScreen.LoadContent(Content); hasEndBeenInitialized = true; } endFightScreen.Update(); } else { if (!endFight) { if (!changeTurn) { if (this.Turn == 0) { prevKeyState = keyState; keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.D1) && prevKeyState.IsKeyUp(Keys.D1)) { UseItem(gameItems[0]); gameItems[0].IsUsed = true; } if (keyState.IsKeyDown(Keys.D2) && prevKeyState.IsKeyUp(Keys.D2)) { UseItem(gameItems[1]); gameItems[1].IsUsed = true; } if (keyState.IsKeyDown(Keys.D3) && prevKeyState.IsKeyUp(Keys.D3)) { UseItem(gameItems[2]); gameItems[2].IsUsed = true; } if (keyState.IsKeyDown(Keys.D4) && prevKeyState.IsKeyUp(Keys.D4)) { UseItem(gameItems[3]); gameItems[3].IsUsed = true; } if (fighter.BasicAttack.Active) { FighterBasicAttack(gameTime); changeTurn = true; } else if (fighter.SpecialAttack.Active) { FighterSpecialAttack(gameTime); changeTurn = true; } } else { if (enemyMana >= enemySpAtk) { EnemySpecialAttack(gameTime); } else { EnemyBasicAttack(gameTime); } changeTurn = true; } } if (changeTurn) { Wait(gameTime); } } else { EndFightPause(gameTime); if (waitingDone) { SaveBagToDatabase(GameAuth.GetCurrentGame(), gameItems); if (didWin) { YouWin(gameTime); } else { YouLose(gameTime); } } } } }