public void Move(int movement) { movement += modifier["移"]; var axis = Game.GetInstance().charaAxis; if (faceTo == Direction.Left) { axis[posInAxis] = null; for (int i = posInAxis - 1; i >= posInAxis - movement; i--) { if (i < 0 || i > 10) { break; } if (axis[i] != null) { Game.GetInstance().gameLog.Add($"{name}移动了{posInAxis - i + 1}格 "); Game.GetInstance().PutCharacter(this, i + 1); return; } } if (posInAxis - movement > 10 || posInAxis - movement < 0) { Game.GetInstance().gameLog.Add($"{name}移出了界限 "); return; } Game.GetInstance().PutCharacter(this, posInAxis - movement); Game.GetInstance().gameLog.Add($"{name}移动了{movement}格 "); } else { axis[posInAxis] = null; for (int i = posInAxis + 1; i <= posInAxis + movement; i++) { if (i < 0 || i > 10) { break; } if (axis[i] != null) { Game.GetInstance().gameLog.Add($"{name}移动了{i - posInAxis - 1}格 "); Game.GetInstance().PutCharacter(this, i - 1); return; } } if (posInAxis + movement > 10 || posInAxis + movement < 0) { Game.GetInstance().gameLog.Add($"{name}移出了界限 "); return; } Game.GetInstance().PutCharacter(this, posInAxis + movement); Game.GetInstance().gameLog.Add($"{name}移动了{movement}格 "); } }
public bool Attack(Character target, int damage) { damage += modifier["攻"]; if (target == null) { Game.GetInstance().gameLog.Add($"{name}前方没有目标 "); return(false); } target.BeHit(damage); Game.GetInstance().gameLog.Add($"{name}对{target.name}造成{damage}点伤害"); return(true); }
public bool BeHeal(int increment) { increment += +modifier["治"]; curHp += increment; if (curHp > maxHp) { curHp = maxHp; } Game.GetInstance().gameLog.Add($"{name}治疗了自己{increment}点生命值 "); return(true); }
public void Jump(int jump) { jump += modifier["跳"]; if (faceTo == Direction.Left) { int targetpos = posInAxis - jump; if (targetpos < 0 || targetpos > 10) { Game.GetInstance().gameLog.Add($"{name}跳出了界限 "); Game.GetInstance().charaAxis[posInAxis] = null; return; } start1: if (Game.GetInstance().getItemInAxisAt(targetpos) == null) { Game.GetInstance().charaAxis[posInAxis] = null; Game.GetInstance().PutCharacter(this, targetpos); Game.GetInstance().gameLog.Add($"{name}向前跳了{jump}格 "); } else { targetpos++; goto start1; } } else { int targetpos = posInAxis + jump; if (targetpos < 0 || targetpos > 10) { Game.GetInstance().gameLog.Add($"{name}跳出了界限 "); Game.GetInstance().charaAxis[posInAxis] = null; return; } start2: if (Game.GetInstance().getItemInAxisAt(targetpos) == null) { Game.GetInstance().charaAxis[posInAxis] = null; Game.GetInstance().PutCharacter(this, targetpos); Game.GetInstance().gameLog.Add($"{name}向前跳了{jump}格 "); } else { targetpos--; goto start2; } } }
public void UseCard(int i) { //if (GetHandCards().Count > 0) //{ // int count = 0; // foreach(var a in handCards) // { // if (i == count && a.inHand) // { // a.doer = Game.GetInstance().GetPlayer(); // if (!a.TakeAcion(a.doer)) // { // Game.GetInstance().gameLog.Add("AP不够 "); // return; // } // a.inHand = false; // a.inDiscard = true; // handCards.Remove(a); // break; // } // else if (a.inHand) // { // count++; // } // } //} if (handCards.Count != 0) { handCards[i].doer = Game.GetInstance().GetPlayer(); if (!handCards[i].TakeAcion(handCards[i].doer)) { Game.GetInstance().gameLog.Add("AP不够 "); return; } else { handCards[i].inHand = false; handCards[i].inDiscard = true; handCards.Remove(handCards[i]); } } Game.GetInstance().curPlayerAction = 0; }
public static Character CreateBoss() { Character monster = new Character(); monster.name = "鬼怪"; monster.curHp = 14; monster.maxHp = 14; monster.img = bossImg; monster.faceTo = Direction.Left; monster.type = CharacterType.Monster; monster.maction = Game.GetInstance().battle.BossAction; Game.GetInstance().gameLog.Add($"一个奇怪的生物出现了... "); Game.GetInstance().gameLog.Add($"-----------------------"); Game.GetInstance().gameLog.Add($"它似乎就是幕后黑手了 "); Game.GetInstance().gameLog.Add($"但是我们知道它的信息不多 "); Game.GetInstance().gameLog.Add($"不管怎样,干掉它! "); Game.GetInstance().gameLog.Add($"-----------------------"); return(monster); }
public void RunBattle() { if (Game.GetInstance().gameState == "GameOver" || Game.GetInstance().gameState == "Win") { return; } Game.GetInstance().gameDisplay.DrawGameState($" 回合:{turn} "); if (!CardChooser()) { monster.maction(); player.Shuffle(false); int count = player.handCards.Count; for (int i = 0; i < 4 - count; i++) { player.CardDraw_Once(false); } player.curAp = player.maxAp; turn++; } }
public Character GetForward() { Game game = Game.GetInstance(); if (faceTo == Direction.Left) { if (posInAxis - 1 > 10 || posInAxis - 1 < 0) { return(null); } return(game.getItemInAxisAt(posInAxis - 1)); } else { if (posInAxis + 1 > 10 || posInAxis + 1 < 0) { return(null); } return(game.getItemInAxisAt(posInAxis + 1)); } }
public void Push(int thrust) { thrust += modifier["推"]; Character target = GetForward(); if (target == null) { Game.GetInstance().gameLog.Add("你前方没有目标 "); return; } if (target.faceTo == faceTo) { target.Move(thrust); } else { target.Turn(); target.Move(thrust); target.Turn(); } Game.GetInstance().gameLog.Add($"{name}将{target.name}推了{thrust}格 "); }
public static Character CreateMonster1() { Character monster = new Character(); monster.name = "史莱姆"; monster.curHp = 5; monster.maxHp = 5; monster.img = monsterImg; monster.faceTo = Direction.Left; monster.type = CharacterType.Monster; monster.maction = Game.GetInstance().battle.MonsterAction1; Game.GetInstance().gameLog.Add($"史莱姆出现了! "); Game.GetInstance().gameLog.Add($"-----------------------"); Game.GetInstance().gameLog.Add($"史莱姆是会跳来跳去的怪物 "); Game.GetInstance().gameLog.Add($"但是绝对不会跳出边缘 "); Game.GetInstance().gameLog.Add($"掌握好节奏,就可以抓住它 "); Game.GetInstance().gameLog.Add($"-----------------------"); return(monster); }
void SuperMoveAction(Character doer) { Game.GetInstance().gameDisplay.DrawGameState(" 超级移动 "); choose: switch (Console.ReadKey(true).Key) { case ConsoleKey.LeftArrow: if (doer.faceTo == Direction.Left) { doer.Move(1); Game.GetInstance().gameDisplay.DrawGame(); goto choose; } else { doer.Turn(); doer.Move(1); Game.GetInstance().gameDisplay.DrawGame(); goto choose; } case ConsoleKey.RightArrow: if (doer.faceTo == Direction.Right) { doer.Move(1); Game.GetInstance().gameDisplay.DrawGame(); goto choose; } else { doer.Turn(); doer.Move(1); Game.GetInstance().gameDisplay.DrawGame(); goto choose; } case ConsoleKey.Enter: return; } }
public void MonsterAction2() { Game.GetInstance().gameDisplay.DrawGameState(" 怪物的回合 "); int move = random.Next(2, 3); if (monster.posInAxis - move < 0 && monster.faceTo == Direction.Left) { monster.Turn(); } if (monster.posInAxis + move > 10 && monster.faceTo == Direction.Right) { monster.Turn(); } System.Threading.Thread.Sleep(500); monster.Move(move); System.Threading.Thread.Sleep(500); if (monster.GetForward() != null) { monster.Attack(monster.GetForward(), 5); } System.Threading.Thread.Sleep(1000); }
public static Character CreateMonster2() { Character monster = new Character(); monster.name = "蜘蛛"; monster.curHp = 8; monster.maxHp = 8; monster.img = monsterImg1; monster.faceTo = Direction.Left; monster.type = CharacterType.Monster; monster.maction = Game.GetInstance().battle.MonsterAction2; Game.GetInstance().gameLog.Add($"蜘蛛出现了! "); Game.GetInstance().gameLog.Add($"-----------------------"); Game.GetInstance().gameLog.Add($"蜘蛛移动的速度不快 "); Game.GetInstance().gameLog.Add($"但是攻击高,血量多 "); Game.GetInstance().gameLog.Add($"万一它靠近了你 "); Game.GetInstance().gameLog.Add($"千万一定要小心谨慎! "); Game.GetInstance().gameLog.Add($"-----------------------"); return(monster); }
//todo: Multiple Actions public void MonsterAction1() { Game.GetInstance().gameDisplay.DrawGameState(" 怪物的回合 "); int jump = random.Next(3, 6); System.Threading.Thread.Sleep(500); if (monster.posInAxis - jump < 0 && monster.faceTo == Direction.Left) { monster.Turn(); } if (monster.posInAxis + jump > 10 && monster.faceTo == Direction.Right) { monster.Turn(); } System.Threading.Thread.Sleep(500); monster.Jump(jump); System.Threading.Thread.Sleep(500); if (monster.GetForward() != null) { monster.Attack(monster.GetForward(), 3); } System.Threading.Thread.Sleep(1000); }
public void Reset() { turn = 0; for (int i = 0; i < Game.GetInstance().charaAxis.Count; i++) { Game.GetInstance().charaAxis[i] = null; } Game.GetInstance().gameLog.RemoveRange(0, Game.GetInstance().gameLog.Count); Point pos = new Point(Game.GetInstance().gameDisplay.fieldWidth - 25, Game.GetInstance().gameDisplay.fieldHeight + 3); Game.GetInstance().gameDisplay.ClearRect(pos, 25, 19, ConsoleColor.Black); player.curHp = player.maxHp; player.curAp = player.maxAp; player.faceTo = Direction.Right; player.handCards.RemoveRange(0, player.handCards.Count); string[] keys = player.modifier.Keys.ToArray(); foreach (var i in keys) { player.modifier[i] = 0; } Game.GetInstance().gameState = "Normal"; }
bool CardChooser() { if (Game.GetInstance().gameState == "Next") { Console.ReadKey(true); return(true); } switch (Console.ReadKey(true).Key) { case ConsoleKey.LeftArrow: if (Game.GetInstance().curPlayerAction > 0) { Game.GetInstance().curPlayerAction--; } break; case ConsoleKey.RightArrow: if (Game.GetInstance().curPlayerAction < player.CountHand() - 1) { Game.GetInstance().curPlayerAction++; } break; case ConsoleKey.Enter: player.UseCard(Game.GetInstance().curPlayerAction); break; case ConsoleKey.Escape: return(false); case ConsoleKey.D: List <string> strs = new List <string>(); foreach (var a in player.cards) { if (a.inDiscard == true) { strs.Add($"{a.name}"); } } Game.GetInstance().gameDisplay.DrawHintDeck("弃牌堆", strs.ToArray()); break; case ConsoleKey.L: List <string> strs2 = new List <string>(); for (int count = 0; count < player.cards.Count; count++) { foreach (var a in player.cards) { if (a.deckId == count) { strs2.Add($"[{a.deckId}]{a.name}"); } } } int cardInfo = -1; bool flag = int.TryParse(Game.GetInstance().gameDisplay.DrawHintDeck("牌库", strs2.ToArray()), out cardInfo); if (flag && cardInfo >= 0 && cardInfo < player.cards.Count) { Game.GetInstance().gameDisplay.DrawActionCard( new Point(1, Game.GetInstance().gameDisplay.fieldHeight + 2) , player.GetCard(cardInfo), ConsoleColor.Blue); Console.ReadKey(true); Game.GetInstance().gameDisplay.ClearRect( new Point(1, Game.GetInstance().gameDisplay.fieldHeight + 2) , 12, 14, ConsoleColor.Black); } break; } return(true); }
public void Init() { if (Game.GetInstance().gameState == "Next") { Reset(); switch (Game.GetInstance().gameDisplay.DrawHint($"你赢了{monster.name}", "选择奖励吧", "", "", "[1]增加最大HP 5点", "[2]增加最大AP 2点", "[3]获得一张卡", "[...]跳过")) { case "1": player.maxHp += 5; player.curHp = player.maxHp; break; case "2": player.maxAp += 2; player.curAp = player.maxAp; break; case "3": int rand = random.Next(0, Game.GetInstance().actionArchive.Count - 1); int count = 0; foreach (var kvp in Game.GetInstance().actionArchive) { if (count == rand) { player.AddCard(kvp.Key); Game.GetInstance().gameLog.Add($"添加了卡牌{kvp.Key} "); break; } count++; } break; } battle += 1; } if (turn == 0) { if (player == null) { switch (playerJob) { case 1: player = Character.CreateFighterPlayer(); break; case 2: player = Character.CreateCoachPlayer(); break; case 3: player = Character.CreateProgrammerPlayer(); break; } } if (battle == 5) { monster = Character.CreateBoss(); } else { int a = random.Next(1, 10); if (a <= 6) { monster = Character.CreateMonster1(); } if (a > 6) { monster = Character.CreateMonster2(); } } Game.GetInstance().PutCharacter(player, 0); Game.GetInstance().PutCharacter(monster, 10); Game.GetInstance().GetPlayer().Shuffle(true); Game.GetInstance().GetPlayer().CardDraw_Once(false); Game.GetInstance().GetPlayer().CardDraw_Once(false); Game.GetInstance().GetPlayer().CardDraw_Once(false); Game.GetInstance().GetPlayer().CardDraw_Once(false); turn += 1; } }
void ResetAction(Character doer) { Game.GetInstance().battle.Reset(); }
public void BossAction() { Game.GetInstance().gameDisplay.DrawGameState(" BOSS的回合 "); List <int> blockPos = new List <int>(); foreach (var a in Game.GetInstance().charaAxis) { if (a.Value != null) { if (a.Value.type == CharacterType.Block) { blockPos.Add(a.Key); } } } if (blockPos.Count < 3) { int pos = 0; bool ok = false; while (!ok) { pos = random.Next(0, 10); if (pos != player.posInAxis && pos != monster.posInAxis && !blockPos.Contains(pos)) { ok = true; } } System.Threading.Thread.Sleep(500); Game.GetInstance().PutCharacter(Character.CreateBlock(), pos); Game.GetInstance().gameLog.Add("BOSS召唤了障碍物! "); System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(1000); } else { if (monster.GetForward() != null) { if (monster.GetForward().type == CharacterType.DefaultPlayer) { System.Threading.Thread.Sleep(500); monster.Attack(monster.GetForward(), 10); System.Threading.Thread.Sleep(500); return; } else { monster.Turn(); if (monster.GetForward() != null) { if (monster.GetForward().type == CharacterType.DefaultPlayer) { System.Threading.Thread.Sleep(500); monster.Attack(monster.GetForward(), 10); System.Threading.Thread.Sleep(500); return; } } } } System.Threading.Thread.Sleep(500); Game.GetInstance().charaAxis[monster.posInAxis] = null; int pos = 0; bool ok = false; while (!ok) { pos = random.Next(0, 10); if (pos != player.posInAxis && pos != monster.posInAxis && !blockPos.Contains(pos)) { ok = true; } } Game.GetInstance().PutCharacter(monster, pos); Game.GetInstance().gameLog.Add("BOSS瞬移了! "); System.Threading.Thread.Sleep(500); System.Threading.Thread.Sleep(1000); } }
public void Turn() { faceTo = faceTo == Direction.Left ? Direction.Right : Direction.Left; Game.GetInstance().gameLog.Add($"{name}转向了 "); }