public static void Fight(Character charA, Character charB) { int i = 1; while (charA.HP > 0 && charB.HP > 0) { DisplayStats(charA, charB); Console.WriteLine("\nRound " + i + "\n"); if (i % 2 == 0) { charB.Action(charA); if (charA.HP > 0) { charA.Action(charB); } } else { charA.Action(charB); if (charB.HP > 0) { charB.Action(charA); } } i++; if (charA.HP > 0 && charB.HP > 0) { Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("\n\nPress [Space] to continue..."); if (!Input(ConsoleKey.Spacebar, ConsoleKey.Escape)) { return; } } } DisplayStats(charA, charB); Console.ForegroundColor = ConsoleColor.Yellow;; if (charA.HP > 0) { Console.WriteLine("\n " + charA.name + " won !"); } else { Console.WriteLine("\n " + charB.name + " won !"); } Console.ForegroundColor = ConsoleColor.DarkGray; }
private IEnumerator LevelState() { gameOverPanel.DisableGameOverPanel(); startTextPanel.SetActive(true); yield return(WaitForPlayerInitialInput()); startTextPanel.SetActive(false); FindObjectOfType <AudioHandler>().PlayEffect(4); while (IsPlayerAlive() && !IsLevelFinished()) { if (!IsGamePaused()) { player.Action(); } yield return(new WaitForFixedUpdate()); } if (!IsPlayerAlive()) { musicHandler.ChangePitch(gameOverPitch); StartCoroutine(gameOverPanel.Appear()); } else if (IsLevelFinished()) { SaveAndLoad.FinishAndSaveLevel(collectedCoins == Coin.totalCoin, collectedCoins == 0); player.Stop(); yield return(new WaitForSeconds(player.timeToFinish)); endLevelPanel.SetActive(true); } Coin.ResetTotalCoin(); collectedCoins = 0; }
private List <List <int> > GenerateBattleData() { battleData = new List <List <int> >(); //根据速度得到行动顺序,0是动,1是对方动 //每次得到data之后都会取反 int isAttack = GetSpeed(); //下面两个变量记录双方当前行动单位的坐标 int[] myActionNum = { -1, 0 }; int[] opponentActionNum = { -1, 0 }; //模拟战斗,得到battledata while (true) { int[] myIndex = { -1 }; int[] opIndex = { -1 }; Character atkCharacter = null; //我方动 if (isAttack == 0) { atkCharacter = FindActionCharacter(isAttack, myActionNum); isAttack = 1; } //对方动 else { atkCharacter = FindActionCharacter(isAttack, opponentActionNum); isAttack = 0; } if (!flag) { //Debug.Log("ListLength: " + battleData.Count); return(battleData); } //没打完 List <int> list = atkCharacter.Action(this); //Debug.Log(list); battleData.Add(list); } }
//尝试另一种实现方式,生成battleData private List <List <int> > GenerateBattleData(List <Character> myList, List <Character> opList) { battleData = new List <List <int> >(); //根据速度得到行动顺序,0是动,1是对方动 //每次得到data之后都会取反 int isAttack = GetSpeed(); int[] myIndex = { -1 }; int[] opIndex = { -1 }; //模拟战斗,得到battledata while (true) { Character atkCharacter = null; //我方动 if (isAttack == 0) { atkCharacter = FindActionCharacter(myList, myIndex); isAttack = 1; } //对方动 else { atkCharacter = FindActionCharacter(opList, opIndex); isAttack = 0; } if (!flag) { //Debug.Log("ListLength: " + battleData.Count); return(battleData); } //没打完 List <int> list = atkCharacter.Action(this); //Debug.Log(list); battleData.Add(list); } }