// **************************************** public static void AnimatorAttack() { CardBattle.PlayAudio("受伤"); // 攻击动画完成 Animator anim = attackMonster.origin.transform.FindChild("Monster").GetComponent <Animator>(); anim.SetBool("Attack", false); // **** 受伤计算 **** // 被攻击者 if (hurtMonster.state == Monster.State.Attack) { hurtMonster.SetHealth(hurtMonster.GetHealth() - attackMonster.GetValue()); } else { int value = hurtMonster.GetValue() - attackMonster.GetValue(); if (value >= 0) { hurtMonster.SetValue(Monster.State.Defend, value); } else { hurtMonster.SetValue(Monster.State.Defend, 0); hurtMonster.SetHealth(hurtMonster.GetHealth() + value); } // 被攻击者切换防御状态到攻击状态 hurtMonster.state = Monster.State.Attack; hurtMonster.SetValue(hurtMonster.GetValue()); } // 被攻击者更新卡牌信息 hurtMonster.UpdateCard(); // **** 受伤计算 **** // 攻击动画播放完毕攻击的怪物返回原位 attackMonster.origin.transform.DOMove(attackPosition, 1f).OnComplete(() => { attacking = false; attackPosition = Vector3.zero; attackMonster = null; hurtMonster = null; }); }
public void CallMonster(Player player, Monster.State state) { CardBattle.PlayAudio("召唤"); player.CallMonster(downView.handId, state); if (current == Round.Self) { self.BattleSort(new Vector3(200f, 0), true); enemy.BattleSort(new Vector3(200f, 0), true); } else { self.BattleSort(new Vector3(200f, 0), false); enemy.BattleSort(new Vector3(200f, 0), false); } player.HandSort(); // 当前回合召唤次数减1 --callCount; }
public void PlayAttack() { CardBattle.AnimatorAttack(); }
public void ButtonEndRound() { if (running) { if (current == Round.Self) { BattleDisplay(enemyHand, true); BattleDisplay(selfHand, false); self.HandDisplay(false); enemy.HandDisplay(true); self.BattleSort(new Vector3(200f, 0), false); enemy.BattleSort(new Vector3(200f, 0), false); enemy.ResetState(); self.HideState(); enemy.DrawACard(); enemy.HandSort(); int count = self.canAttackCount() - enemy.BattleCount(); if (count > 0) { enemy.health -= count; } current = Round.Enemy; } else { BattleDisplay(enemyHand, false); BattleDisplay(selfHand, true); self.HandDisplay(true); enemy.HandDisplay(false); self.BattleSort(new Vector3(200f, 0), true); enemy.BattleSort(new Vector3(200f, 0), true); self.ResetState(); enemy.HideState(); self.DrawACard(); self.HandSort(); int count = enemy.canAttackCount() - self.BattleCount(); if (count > 0) { self.health -= count; } current = Round.Self; } // 召唤次数为1 callCount = 1; CardBattle.PlayAudio("结束"); } // **** 胜利条件 **** if (self.health <= 0) { GameObject winObj = transform.parent.FindChild("Win").gameObject; winObj.transform.localRotation = Quaternion.Euler(0, 0, -180); winObj.SetActive(true); } else if (enemy.health <= 0) { GameObject winObj = transform.parent.FindChild("Win").gameObject; winObj.transform.localRotation = Quaternion.Euler(0, 0, 0); winObj.SetActive(true); } else { EventManager.PostEvent(TipSystem.DataType.ShowTip, "我方回合", current == Round.Self ? true : false); } // **** 胜利条件 **** }
private void CallMonster(Player player) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit rayHit; if (Physics.Raycast(ray, out rayHit)) { if (rayHit.collider.name == "BattleRage") { if (downMonster == null) { if (downView.type == CardModel.Type.Monster) { if (callCount > 0) { ShowStateSelect(); } else { EventManager.PostEvent(TipSystem.DataType.ShowTip, "不可召唤怪物,已到本回合抽取召唤上限", current == Round.Self ? true : false); } } } } else if (rayHit.collider.name == "Monster(Clone)") { if (downMonster != null) { if (downMonster.IsMine(current) && downMonster.canAttack) { Monster monster = rayHit.collider.GetComponent <Monster>(); if (((monster.isSelf && current == Round.Enemy) || (!monster.isSelf && current == Round.Self)) && !attacking) { attacking = true; hurtMonster = monster; attackMonster = downMonster; attackPosition = downMonster.origin.transform.position; downMonster.origin.transform.DOMove(monster.transform.position - new Vector3(0, monster.isSelf ? -15f : 15f), 1f).OnComplete(() => { // 播放攻击动画 **** 未完待续 **** Animator anim = attackMonster.origin.transform.FindChild("Monster").GetComponent <Animator>(); anim.SetBool("Attack", true); }); downMonster.SetState(false, false); } } } else { if (downView.type == CardModel.Type.Equip) { Monster monster = rayHit.collider.GetComponent <Monster>(); if ((monster.isSelf && current == Round.Self) || (!monster.isSelf && current == Round.Enemy)) { if (monster.equip.Equals(new Monster.MonsterEquip())) { CardBattle.PlayAudio("装备"); monster.AddEquip(int.Parse(downView.Health.text), int.Parse(downView.Attack.text), int.Parse(downView.Defend.text)); if (monster.isSelf) { self.RemoveEquip(downView.handId); } else { enemy.RemoveEquip(downView.handId); } monster.UpdateCard(); } else { EventManager.PostEvent(TipSystem.DataType.ShowTip, "当前怪物已有装备", current == Round.Self ? true : false); } } } } } } downMonster = null; }