// Update is called once per frame void Update() { //Debug.Log(gameType); if (gameType == GameType.InitialMenu) { KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: menu.Left(); break; case KeyCode.RightArrow: menu.Right(); break; case KeyCode.Return: if (menu.Select() == "Start Game") { // Debug.Log("This should run once start game"); //gameType = GameType.BattleSetup; menu.DestroyAll(); } break; } } prevCode = key; //Debug.Log(gameType + " here"); } else if (gameType == GameType.Battle) { if (GetPlayers().Count != 2) { menu = Menu.DeathMenu(totalScore).GetComponent <Menu>(); gameType = GameType.LoseMenu; int size = entities.Count; for (int i = 0; i < size; i++) { Kill(entities[0]); } } else if (entities.Count < 3) { AddToScore(30); currentPlayer.EndTurn(); gameType = GameType.PickACard; cardPile = CardPile.MakeCardPile(3); menu = Menu.PickACardMenu().GetComponent <Menu>(); } if (currentEntity is Player) { currentPlayer = (Player)currentEntity; currentPlayer.OrganizeCards(); // If the player should select a card if ((selectionType == SelectionType.SelectCardToPlay || selectionType == SelectionType.SelectCard) && currentPlayer.HasCards()) { int numCards = currentPlayer.GetHandSize(); if (numCardsHighlighted == 0 && numCards > 0) { currentPlayer.HighlightCard(0); numCardsHighlighted++; selectionIndex = 0; } KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: CardSelect(-1, numCards + 1); break; case KeyCode.RightArrow: CardSelect(1, numCards + 1); break; case KeyCode.Return: if (selectionType == SelectionType.SelectCardToPlay) { if (selectionIndex != numCards) { CardState c = currentPlayer.GetCard(selectionIndex).GetComponent <Card>().GetState(); if (c.GetCost() <= currentPlayer.GetEnergy()) { currentPlayer.ActivateCard(selectionIndex); numCardsHighlighted--; } } else { GameObject.FindWithTag("EndTurnButton").GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/button"); numCardsHighlighted = 0; NextTurn(); } } else { input = currentPlayer.GetCardObject(selectionIndex); currentPlayer.UnSelectAll(); } break; } } prevCode = key; // If The player is out of energy or cards and there are no running tasks if (selectionType == SelectionType.SelectCardToPlay && (currentPlayer.GetEnergy() <= 0 || numCards == 0) && !runningTasks) { numCardsHighlighted = 0; NextTurn(); } // If the Player should select an entity } else if (selectionType == SelectionType.SelectEntity) { int numEntities = entities.Count; if (NoEntitiesHighlighted()) { int enemyIndex; if (lastEnemySelectedIndex == -1 || lastEnemySelectedIndex >= numEntities - 2) { enemyIndex = 0; for (int i = 0; i < numEntities; i++) { if (entities[i] is Enemy) { enemyIndex = i; break; } } } else { enemyIndex = lastEnemySelectedIndex; } HighlightEntity(enemyIndex); selectionIndex = enemyIndex; } KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: selectionIndex = (selectionIndex - 1 + numEntities) % numEntities; HighlightEntity(selectionIndex); break; case KeyCode.RightArrow: selectionIndex = (selectionIndex + 1) % numEntities; HighlightEntity(selectionIndex); break; case KeyCode.Return: input = entities[selectionIndex].GetGameObject(); Entity.UnHighlightAll(); lastEnemySelectedIndex = selectionIndex; selectionIndex = 0; break; } } prevCode = key; // If the player should select from the card pile } else if (selectionType == SelectionType.CardPileSelect) { cardPile = GameObject.FindWithTag("CardPile").GetComponent <CardPile>(); KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: cardPile.Left(); break; case KeyCode.RightArrow: cardPile.Right(); break; case KeyCode.Return: input = cardPile.GetSelected(); break; } } prevCode = key; } } else if (currentEntity is Enemy) { currentEnemy = (Enemy)currentEntity; currentEnemy.ActivateEffect(); NextTurn(); } // Debug.Log(gameType + " here"); } else if (gameType == GameType.PickACard) { // Debug.Log(gameType + " here"); cardPile = GameObject.FindWithTag("CardPile").GetComponent <CardPile>(); KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: cardPile.Left(); break; case KeyCode.RightArrow: cardPile.Right(); break; case KeyCode.Return: (entities[rand.Next(2)]).AddCard(cardPile.GetSelected().GetComponent <Card>().GetState()); cardPile.DestroyAll(); menu.DestroyAll(); gameType = GameType.BattleSetup; break; } } prevCode = key; // Debug.Log(gameType + " here"); } else if (gameType == GameType.BattleSetup) { Debug.Log("top of battle setup"); //Debug.Log("This should only come up once"); // Create up to 2 enemies float[] positions = { 4.8F, 8.5F }; int count = entities.Count; for (int i = 0; i < (4 - count); i++) { //Debug.Log("This should run twice"); List <CardStateBuilder> c = new List <CardStateBuilder>(); for (int j = 0; j < 6; j++) { c.Add(AllCardStates[rand.Next(AllCardStates.Count)]); } enemyBuilder.SetState(1, c); entities.Add(enemyBuilder.CreateEnemy("Enemy", positions[i], 1)); } entities[2].SetHealthBar(e1HealthBar, e1HealthText); entities[3].SetHealthBar(e2HealthBar, e2HealthText); BeginFight(); gameType = GameType.Battle; // Debug.Log(gameType + " here"); } else if (gameType == GameType.LoseMenu) { totalScore = 0; KeyCode key = GetKey(); if (prevCode == UNUSED_KEY) { switch (key) { case KeyCode.LeftArrow: menu.Left(); break; case KeyCode.RightArrow: menu.Right(); break; case KeyCode.Return: if (menu.Select() == "Play Again?") { // Debug.Log("This should run once start game"); gameType = GameType.BattleSetup; menu.DestroyAll(); Awake(); Start(); } break; } } prevCode = key; //Debug.Log(gameType + " here"); } //Debug.Log("end of update"); }