/// <summary> /// 공격을 담당하는 코루틴 /// </summary> IEnumerator Attack() { while (true) { if (!isAtkPause) { bool isCheck = true; if (nowTarget == null) { isCheck = false; } else if (!nowTarget.activeInHierarchy) { isCheck = false; } //타겟이 있다면 공격 if (isCheck) { if (anim.GetBool("walking")) { anim.SetBool("walking", false); } anim.SetTrigger("attack"); Vector3 v = nowTarget.transform.position; v.y = 0; myMinion.transform.DOLookAt(v, 1); //공격하는 대상과 피격당하는 대상을 구분하여 처리 if (nowTarget.tag.Equals("Minion")) { if (myMinion.name.Contains("Melee")) { MinionBehavior minBehav = nowTarget.GetComponent <MinionBehavior>(); if (minBehav != null) { int viewID = minBehav.GetComponent <PhotonView>().viewID; myBehav.HitRPC(viewID); minBehav.HitMe(myBehav.stat.AttackDamage); } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion"))) { if (myMinion.name.Contains("Melee")) { ChampionBehavior champBehav = nowTarget.GetComponent <ChampionBehavior>(); if (champBehav != null) { int viewID = champBehav.GetComponent <PhotonView>().viewID; myBehav.HitRPC(viewID); champBehav.HitMe(myBehav.stat.AttackDamage, "AD", myMinion, myMinion.name); } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.tag.Equals("Tower")) { if (myMinion.name.Contains("Melee")) { TowerBehaviour towerBehav = nowTarget.GetComponent <TowerBehaviour>(); if (towerBehav != null) { string key = ""; char[] keyChar = towerBehav.gameObject.name.ToCharArray(); for (int i = 13; i < 16; ++i) { key += keyChar[i]; } myBehav.HitRPC(key); if (towerBehav.HitMe(myBehav.stat.AttackDamage)) { if (enemyColor.Equals("Red")) { TheInGameManager.blueTeamPlayer[0].GetComponent <PhotonView>().RPC("GlobalGold", PhotonTargets.All, "blue", 100); } else { TheInGameManager.redTeamPlayer[0].GetComponent <PhotonView>().RPC("GlobalGold", PhotonTargets.All, "red", 100); } enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.tag.Equals("Suppressor") || nowTarget.tag.Equals("Nexus")) { if (myMinion.name.Contains("Melee")) { SuppressorBehaviour supBehav = nowTarget.GetComponent <SuppressorBehaviour>(); if (supBehav != null) { string key = ""; char[] keyChar = supBehav.gameObject.name.ToCharArray(); if (nowTarget.tag.Equals("Nexus")) { key += keyChar[6]; } else { for (int i = 11; i < 14; ++i) { key += keyChar[i]; } } myBehav.HitRPC(key); if (supBehav.HitMe(myBehav.stat.AttackDamage)) { enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } } } //어택 딜레이타임을 1초로 설정 atkDelayTime = 1f; yield return(new WaitForSeconds(1)); } }
IEnumerator AtkMotion() { while (true) { if (!isAtkPause) { bool check = true; if (nowTarget == null) { check = false; } else if (!nowTarget.activeInHierarchy) { check = false; } if (check) { if (Anim.GetBool("walking")) { Anim.SetBool("walking", false); } Anim.SetTrigger("attack"); Vector3 v = nowTarget.transform.position; v.y = 0; myMinion.transform.DOLookAt(v, 1); if (nowTarget.tag.Equals("Minion")) { if (myMinion.name.Contains("Melee")) { MinionBehavior behav = nowTarget.GetComponent <MinionBehavior>(); if (behav != null) { int viewID = behav.GetComponent <PhotonView>().viewID; myBehav.HitRPC(viewID); if (behav.HitMe(myBehav.stat.Attack_Damage)) { enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.layer.Equals(LayerMask.NameToLayer("Champion"))) { if (myMinion.name.Contains("Melee")) { ChampionBehavior behav = nowTarget.GetComponent <ChampionBehavior>(); if (behav != null) { int viewID = behav.GetComponent <PhotonView>().viewID; myBehav.HitRPC(viewID); if (behav.HitMe(myBehav.stat.Attack_Damage, "AD", myMinion, myMinion.name)) { sysmsg.sendKillmsg("minion", behav.GetComponent <ChampionData>().ChampionName, myBehav.team.ToString()); enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.tag.Equals("Tower")) { if (myMinion.name.Contains("Melee")) { TowerBehaviour behav = nowTarget.GetComponent <TowerBehaviour>(); if (behav != null) { string key = ""; char[] keyChar = behav.gameObject.name.ToCharArray(); for (int i = 13; i < 16; ++i) { key += keyChar[i]; } myBehav.HitRPC(key); if (behav.HitMe(myBehav.stat.Attack_Damage)) { if (enemyColor.Equals("Red")) { inGameManager.blueTeamPlayer[0].GetComponent <PhotonView>().RPC("GlobalGold", PhotonTargets.All, "blue", 100); } else { inGameManager.redTeamPlayer[0].GetComponent <PhotonView>().RPC("GlobalGold", PhotonTargets.All, "red", 100); } enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } else if (nowTarget.tag.Equals("Suppressor") || nowTarget.tag.Equals("Nexus")) { if (myMinion.name.Contains("Melee")) { SuppressorBehaviour behav = nowTarget.GetComponent <SuppressorBehaviour>(); if (behav != null) { string key = ""; char[] keyChar = behav.gameObject.name.ToCharArray(); if (nowTarget.tag.Equals("Nexus")) { key += keyChar[6]; } else { for (int i = 11; i < 14; ++i) { key += keyChar[i]; } } myBehav.HitRPC(key); if (behav.HitMe(myBehav.stat.Attack_Damage)) { enemiesList.Remove(nowTarget); } } } else if (myMinion.name.Contains("Magician")) { float moveTime = 0.4f; myBehav.ArrowRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } else if (myMinion.name.Contains("Siege")) { float moveTime = 0.4f; myBehav.CannonballRPC(nowTarget.transform.position, moveTime); Invoke("ProjectileAtk", moveTime); } } } } atkDelayTime = 1f; yield return(new WaitForSeconds(1)); } }