public void Attack(ICanBeAttacked target) { target.Take(new Damage { Hitpoints = 1 }); }
public AttackMenuController(ICanBeAttacked obj, GameObject popupPrefab) { this.module = obj; if (AttackMenuController._popupPrefab == null && popupPrefab != null) { AttackMenuController._popupPrefab = popupPrefab; } this.gameController = GameControllerWrapper.GetGameController(); this.rootCanvas = (Canvas)GameObject.FindObjectOfType(typeof(Canvas)); this.texts = AttackMenuController.popupInstance.GetComponentsInChildren <Text>(); this.textContent = this.texts[0]; textContent.text = "Attack Menu"; this.CloseMenu(); // Hide the menu if it changes to the defender's turn GameEvents.OnTurnChange((turnChangeArgs) => { if (turnChangeArgs.State == GameState.DefenderTurn) { this.CloseMenu(); } }); }
public override List <GameAction> GetActions() { List <GameAction> res = new List <GameAction>(); ActionCommandMap.Clear(); GameAction done = new GameAction(-1, -1, "Done"); res.Add(done); int i = 0; foreach (Card attacker in MyGame.MyCombatHandler.AttackerToTargetMap.Keys) { ICanBeAttacked icba = MyGame.MyCombatHandler.AttackerToTargetMap[attacker]; Boolean isAttackingMe = false; if (icba is Card) { isAttackingMe = ((Card)icba).Controller.ID == MyPlayer.ID; } else { isAttackingMe = ((Player)icba).ID == MyPlayer.ID; } if (isAttackingMe) { IEnumerable <Card> creats = MyGame.GetCards(ZoneType.Battlefield, MyPlayer.Value(MyGame)).Where(x => { return(x.CurrentCharacteristics.CardTypes.Contains("Creature")); }); foreach (Card c in creats) { if (Utilities.CanBlockAttacker(c, attacker)) { GameAction blo = new GameAction(i++, c.ID, "Block " + attacker.ToString(MyGame) + " with this"); ActionCommandMap.Add(blo, new CommandAddBlocker(c.ID, attacker.ID)); res.Add(blo); } } } } foreach (Card attacker in MyGame.MyCombatHandler.AttackerToBlockersMap.Keys) { foreach (Card blocker in MyGame.MyCombatHandler.AttackerToBlockersMap[attacker]) { if (blocker.Controller.ID == MyPlayer.ID) { GameAction blorem = new GameAction(i++, blocker.ID, "Remove " + blocker.ToString(MyGame) + " from blocking."); ActionCommandMap.Add(blorem, new CommandRemoveBlocker(attacker.ID, blocker.ID)); res.Add(blorem); } } } return(res); }
public override void Do(Game g) { Card att = Attacker.Value(g); ICanBeAttacked ICBA = (ICanBeAttacked)g.GetGameObjectByID(Defender); if (g.MyCombatHandler.AttackerToTargetMap.ContainsKey(att)) { prev = g.MyCombatHandler.AttackerToTargetMap[att]; g.MyCombatHandler.AttackerToTargetMap[att] = ICBA; } else { g.MyCombatHandler.AttackerToTargetMap.Add(att, ICBA); } }
public override void DoPhaseEffects(Game g) { CombatHandler ch = g.MyCombatHandler; foreach (Card attacker in ch.AttackerToBlockersMap.Keys) { if (ch.AttackerToBlockersMap[attacker].Count == 0) { ICanBeAttacked ICBA = ch.AttackerToTargetMap[attacker]; g.MyExecutor.Do(new CommandSetIsTapped(attacker.ID, true)); g.MyExecutor.Do(new CommandDealDamage(ICBA.ID, attacker.CurrentCharacteristics.Power)); } } }
public void LogFight(ICanAttack attacker, ICanBeAttacked victim) { _logWindow.WriteLine(string.Format("{0} attacked {1}. {1} is now angry at {2} hp.", attacker.Name, victim.Name, victim.Hitpoints)); }