private bool OnSelectMove() { /*************THIS IS WHERE I WILL TOGGLE BUTTON TO SCROLL CODE, DISABLE INPUT BESIDES ENTER, * disable me1,2,3,4, enable scroll text button ***********/ if (aliveTeammateList[currentChar].checkMove(selectedMove)) //Always return true, but in what case wouldn't they be able to perform the move? not enough mana or something { MoveMessenger messenger = aliveTeammateList[currentChar].makeMove(selectedMove); print(messenger.toString()); messenger.setAttackedPlayer(attackedPlayer); // the messenger stores the attacked player messenger.setIndexOfAttackedPlayer(currentTarget); messenger.setIndexOfMove(selectedMove); print("Attacked Player: " + messenger.getAttackedPlayer()); FillMoveList(messenger); if (currentChar == (aliveTeammateList.Capacity - 1)) { needToPrint = false; StartCoroutine(StartBattling()); } else { currentChar++; print("CurrentChar after incrementation: " + currentChar); updateMovesForChar(); EventSystem.current.SetSelectedGameObject(meButtons[0]); } return(true); } return(false); }
private void FillMoveList(MoveMessenger m) { moveList.Add(m, allEntityList [currentChar].name); for (int i = 0; i < moveList.Count; i++) { MoveMessenger mm = (MoveMessenger)(moveList.GetKey(i)); print((i + 1) + " move(s) in list:" + " " + "Attacking Player: " + mm.getAttackingPlayer() + " " + "AttackedPlayer: " + mm.getAttackedPlayer() + " " + "Move Speed: " + mm.getSpeed() + " " + "Move Damage: " + mm.getRecalculatedDamage()); } }
public MoveMessenger makeMove(int a) { Debug.Log("Move: " + a); MoveMessenger mm = new MoveMessenger(); Debug.Log(mm); Debug.Log(moveList [a]); mm.recalculateDamage(moveList [a].getDamage()); mm.setSpeed(characterSpeedFactor * moveList [a].speed); mm.setAttackingPlayer(this); return(mm); }
//need to revamp it private object SelectAIMove() { System.Random rnd = new System.Random(); for (int i = 0; i < aliveEnemyList.Capacity; i++) { print("Called SelectAIMove()"); print("Current Enemy: " + aliveEnemyList[i].getName()); MoveMessenger messenger = aliveEnemyList[i].makeMove(enemyMove); print(messenger.toString()); int target = rnd.Next(0, aliveTeammateList.Capacity); print("Target is Teammate #: " + target); messenger.setAttackedPlayer(aliveTeammateList[target]); FillMoveList(messenger); currentChar++; } return(null); }
public int receiveDamage(MoveMessenger m) { int damage = m.getRecalculatedDamage(); return(health - damage); }
IEnumerator StartBattling() { for (int i = 0; i < 4; i++) { meButtons [i].SetActive(false); } battleLog.SetActive(true); playerTurn = false; currentChar++; print(new Time()); yield return(SelectAIMove()); print(new Time()); //MakeMoves (); method is under this print(pressedEnter); pressedEnter = false; for (int i = 0; i < moveList.Count && moveList[i] != null; i++) { print(i); MoveMessenger m = (MoveMessenger)(moveList.GetKey(i)); if (m.getAttackedPlayer().isAlive() != true) { updateBattleLog(m.getAttackingPlayer().getName() + "'s target was dead before move. Attacking next person in the enemy line"); yield return(chatEnter()); int newTarget = m.getIndexOfAttackedPlayer(); if (m.getAttackingPlayer().getTeam() == "team") { if (newTarget > aliveEnemyList.Capacity - 1) { newTarget = 0; } m.setAttackedPlayer(aliveEnemyList [newTarget]); } else { if (newTarget > aliveTeammateList.Capacity - 1) { newTarget = 0; } m.setAttackedPlayer(aliveTeammateList [newTarget]); } m.setIndexOfAttackedPlayer(newTarget); m.recalculateDamage(m.getAttackingPlayer().moveList [m.getIndexOfMove()].getDamage()); } updateBattleLog(m.getAttackingPlayer().getName() + " is attacking " + m.getAttackedPlayer().getName() + " with damage: " + m.getRecalculatedDamage()); updateBattleLog(m.getAttackedPlayer().getName() + "'s health before the move is: " + m.getAttackedPlayer().getHealth()); int health = m.getAttackedPlayer().receiveDamage((MoveMessenger)moveList.GetKey(i)); updateBattleLog(m.getAttackedPlayer().getName() + "'s health after the move is: " + health); yield return(chatEnter()); m.getAttackedPlayer().setHealth(health); if (health <= 0) { updateBattleLog(m.getAttackedPlayer().getName() + " has died"); if (m.getAttackedPlayer().team == "team") { aliveTeammateList.Remove(m.getAttackedPlayer()); } else //no need to check if he's enemy, because he will be { aliveEnemyList.Remove(m.getAttackedPlayer()); } yield return(chatEnter()); moveList [moveList.IndexOfValue(m.getAttackedPlayer().getName())] = null; //moveList.RemoveAt (moveList.IndexOfValue (m.getAttackedPlayer ().getName ())); //the line that causes skipped turns if (isBattleOver()) { updateBattleLog("Battle's over."); BattleOver(); } } } moveList.Clear(); print("MoveList cleared"); currentChar = 0; print("CurrentChar has been reset"); currentPageOfMovesOrTargets = 0; battleLog.SetActive(false); playerTurn = true; updateMovesForChar(); EventSystem.current.SetSelectedGameObject(meButtons[0]); needToPrint = true; }
private void relocateToDeadEnemyList(MoveMessenger m) { deadEnemyList.Add(m.getAttackedPlayer()); aliveEnemyList.Remove(m.getAttackedPlayer()); aliveEnemyList.TrimExcess(); }
IEnumerator StartBattling() { aliveTeammateList.TrimExcess(); aliveEnemyList.TrimExcess(); for (int i = 0; i < 4; i++) { meButtons [i].SetActive(false); } battleLog.SetActive(true); playerTurn = false; yield return(SelectAIMove()); //MakeMoves (); method is under this print(pressedEnter); //says its true because we hit enter for the final selection of target pressedEnter = false; for (int i = 0; i < moveList.Count; i++) { print("i is " + i); MoveMessenger m = (MoveMessenger)(moveList.GetKey(i)); if (m.getAttackingPlayer().getHealth() > 0) { if (m.getAttackedPlayer().isAlive() != true) { updateBattleLog(m.getAttackingPlayer().getName() + "'s target was dead before move. Attacking next person in the enemy line"); yield return(StartCoroutine(chatEnter())); int newTarget = m.getIndexOfAttackedPlayer(); if (m.getAttackingPlayer().getTeam() == "team") { if (newTarget > aliveEnemyList.Capacity - 1) { newTarget = 0; } m.setAttackedPlayer(aliveEnemyList [newTarget]); } else { if (newTarget > aliveTeammateList.Capacity - 1) { newTarget = 0; } m.setAttackedPlayer(aliveTeammateList [newTarget]); } m.setIndexOfAttackedPlayer(newTarget); m.recalculateDamage(m.getAttackingPlayer().moveList [m.getIndexOfMove()].getDamage()); } updateBattleLog(m.getAttackingPlayer().getName() + " is attacking " + m.getAttackedPlayer().getName() + " with damage: " + m.getRecalculatedDamage()); updateBattleLog(m.getAttackedPlayer().getName() + "'s health before the move is: " + m.getAttackedPlayer().getHealth()); int health = m.getAttackedPlayer().receiveDamage((MoveMessenger)moveList.GetKey(i)); updateBattleLog(m.getAttackedPlayer().getName() + "'s health after the move is: " + health); yield return(StartCoroutine(chatEnter())); m.getAttackedPlayer().setHealth(health); if (health <= 0) { updateBattleLog(m.getAttackedPlayer().getName() + " has died"); if (m.getAttackedPlayer().team == "team") { relocateToDeadTeammateList(m); } else //no need to check if he's enemy, because he will be { relocateToDeadEnemyList(m); } yield return(StartCoroutine(chatEnter())); //moveList.RemoveAt (moveList.IndexOfValue (m.getAttackedPlayer ().getName ())); //the line that causes skipped turns if (isBattleOver()) { yield return(StartCoroutine(chatEnter())); updateBattleLog("Switching back to movement scene..."); yield return(new WaitForSeconds(1f)); BattleOver(); } } } else { updateBattleLog(m.getAttackingPlayer().getName() + "'s hp was " + m.getAttackingPlayer().getHealth() + " so his turn is skipped."); yield return(StartCoroutine(chatEnter())); } } moveList.Clear(); print("MoveList cleared"); currentChar = 0; print("CurrentChar has been reset"); currentPageOfMovesOrTargets = 0; battleLog.SetActive(false); playerTurn = true; updateMovesForChar(); EventSystem.current.SetSelectedGameObject(meButtons[0]); needToPrint = true; }