public void CardBattle(CardController attacker, CardController defender) { Debug.Log("CardBattle"); Debug.Log("attacker HP : " + attacker.model.hp); Debug.Log("defender HP : " + defender.model.hp); attacker.Attack(defender); defender.Attack(attacker); Debug.Log("attacker HP : " + attacker.model.hp); Debug.Log("defender HP : " + defender.model.hp); attacker.CheckAlive(); defender.CheckAlive(); }
public void CardBattle(CardController attacker, CardController defender)//カード同士の戦いの処理 { Debug.Log("CardBattle"); Debug.Log("attacker HP:" + attacker.model.hp); Debug.Log("defender HP:" + defender.model.hp); attacker.Attack(defender); defender.Attack(attacker); DamageToHero(attacker, defender); ShowHeroHP(); Debug.Log("attacker HP:" + attacker.model.hp); Debug.Log("defender HP:" + defender.model.hp); attacker.CheckAlive(); defender.CheckAlive(); }
// カード同士で戦闘する。 public void CardBattle(CardController attacker) { // 四方に対して、カードが存在した場合に双方で攻撃を行う。 foreach (var pair in AllAroundDirection) { CardController defender = GetArroundCard(attacker, pair.Value); // カード自体が存在しない場合 if (defender == null) { continue; } // 敵でない場合 if (attacker.model.gameSide == defender.model.gameSide) { continue; } attacker.Attack(defender, pair.Key); defender.Attack(attacker, DirectionUtil.getReverse(pair.Key)); // attacker.RefreshView(); // defender.RefreshView(); // 死んでいたら、底にカードを置けるようにする。 // カードは死ぬ。 // 再度そこにカードを置けるようにする。 if (attacker.IsDeath()) { FieldGridController controller = attacker.GetComponentInParent <FieldGridController>(); controller.GetComponent <DropCardToFieldEvent>().enabled = true; attacker.Death(); // 死亡回数をカウントする。 GameManager.instance.IncrementDeathCount(GameSide.Player); } if (defender.IsDeath()) { FieldGridController controller = defender.GetComponentInParent <FieldGridController>(); controller.GetComponent <DropCardToFieldEvent>().enabled = true; defender.Death(); GameManager.instance.IncrementDeathCount(GameSide.Enemy); } } }
IEnumerator Attack(CardController attacker) { Transform originalTransform = new GameObject().transform; originalTransform.position = attacker.transform.position; originalTransform.rotation = attacker.transform.rotation; while (true) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(ray, out hit, 100.0f, LayerMask.GetMask("GameBoard")); Vector3 newPosition = originalTransform.position - .3f * (originalTransform.position - hit.point); attacker.transform.position = newPosition; attacker.transform.LookAt(transform); if (Physics.Raycast(ray, out hit)) { CardController attacked = hit.transform.gameObject.GetComponent <CardController>(); if (otherPlayer.cardsOnTheTable.Contains(attacked) && (Input.GetMouseButtonUp(1)) && attacked.layer == otherPlayer.getAttackLayer()) { Transform targetTransform = new GameObject().transform; targetTransform.position = attacked.gameObject.transform.position; targetTransform.LookAt(transform); yield return(StartCoroutine(Move(attacker.gameObject.transform, targetTransform))); attacker.Attack(attacked); GameObject.Destroy(targetTransform.gameObject); break; } else if (enemyCastle.hitCastle(hit.transform) && Input.GetMouseButtonUp(1)) { Debug.Log("Attacking castle"); yield return(StartCoroutine(Move(attacker.transform, enemyCastle.transform))); enemyCastle.TakeDamage(attacker.attack); break; } else if (Input.GetKeyUp(KeyCode.Escape)) { break; } } yield return(null); } yield return(null); // gives time fpr destruction of attacking card if (attacker != null) { Debug.Log("Attacker is not null"); yield return(StartCoroutine(Move(attacker.transform, originalTransform))); } GameObject.Destroy(originalTransform.gameObject); unblocked = true; }