protected override void AutoPlayLogic() { if (m_AttackTarget != null) { if (m_AttackTarget.m_Character.m_Live == E_LIVE.DEAD) { m_AttackTarget.m_Hate = 0.0f; m_AttackTarget = null; return; } float distance = (m_AttackTarget.m_Character.transform.position - transform.position).magnitude; if (m_AttackRange >= distance) // 공격 { if (m_NavMeshController.IsUpdate()) { m_NavMeshController.ClearPath(); } transform.forward = m_AttackTarget.m_Character.transform.position - transform.position; SetStateAndAnimationNetwork(E_ANIMATION.ATTACK, 0.25f, 1.0f, 0.0f); //m_AttackTarget.m_Character.GiveToDamage(new float[] { m_AttackDamage }, new int[] { (int)m_AttackType }, this); } else // 추격 { if (m_State != E_STATE.MOVE) { SetStateAndAnimationNetwork(E_ANIMATION.RUN, 0.25f, 1.0f, 0.0f); } MoveToLocation(m_AttackTarget.m_Character.transform.position); } } else // 대기 { if (m_State != E_STATE.IDLE && !m_NavMeshController.IsUpdate()) { SetStateAndAnimationNetwork(E_ANIMATION.IDLE, 0.25f, 1.0f, 0.0f); } Character c = FindEnemyArea(this, this.transform.position, m_AutoSearchRadius); if (c) { HateTarget t = new HateTarget(c, 100.0f); m_DicHateTarget.Add(t.m_Character.gameObject.GetInstanceID(), t); m_AttackTarget = t; } } }
public bool AttackAttempt(Vector3 _Forward, float _Radius) { if (m_AttackDelayTimer > 0.0f) { return(false); } Character c = FindEnemyShape(this, this.transform.position, _Forward, m_AttackRange, 40.0f); if (c) { if (m_NavMeshController.IsUpdate()) { m_NavMeshController.ClearPath(); } if (c.m_Live == E_LIVE.DEAD) { return(true); } if (m_AttackTarget == null) { HateTarget target = new HateTarget(c, 1); m_AttackTarget = target; } else if (m_AttackTarget.m_Character != c) { HateTarget target = new HateTarget(c, 1); m_AttackTarget = target; } transform.forward = m_AttackTarget.m_Character.transform.position - transform.position; SetStateAndAnimationNetwork(E_ANIMATION.ATTACK, 0.25f, 1.0f, 0.0f); StartCoroutine(C_AttackStep(_Forward, m_AttackSpeed)); return(true); } return(false); }
protected override void DamageEvent(float[] _Damage, float[] _CalculateDamage, int[] _DamageType, float _CalculateFullDamage, bool _Critical, Character _Attacker) { base.DamageEvent(_Damage, _CalculateDamage, _DamageType, _CalculateFullDamage, _Critical, _Attacker); LifeTimerWithObjectPool effect = ObjectPool.GetObject <LifeTimerWithObjectPool>(((E_DAMAGETYPE)_DamageType[0]).ToString()); // 데미지 이팩트 if (effect) { effect.Initialize(); effect.transform.localScale = Vector3.one * (m_BodyCollider.radius * 2.0f); effect.transform.position = transform.position + new Vector3(0.0f, m_BodyCollider.center.y, 0.0f); effect.gameObject.SetActive(true); } float YOffset = 0.0f; for (int i = 0; i < _DamageType.Length; ++i) { Billboard b = ObjectPool.GetObject <Billboard>("DamageText"); if (b) { b.gameObject.SetActive(true); b.Initialize(_Critical ? ((int)_CalculateDamage[i]).ToString() + "!!" : ((int)_CalculateDamage[i]).ToString(), transform.position + new Vector3(0.0f, 1.0f + (m_BodyCollider.height * 0.5f + m_BodyCollider.center.y + YOffset), 0.0f), 2.0f); b.SetColor(Common.m_DamageColor[_DamageType[i]]); YOffset += 0.33f; } } if (m_Health <= 0.0f && m_PhotonView.IsMine) { SetStateAndAnimationNetwork(E_ANIMATION.DEAD, 0.15f, 1.0f, 0.0f); return; } if (m_PlayHitAnimation) { m_Animator.CrossFade("Hit", 0.1f); SetFreeze(0.5f); } if (m_IsAutoPlay) { float damage = 0.0f; for (int i = 0; i < _Damage.Length; ++i) { damage += _Damage[i]; } Character target = null; HateTarget t = null; target = _Attacker as Character; if (target != null) { if (m_DicHateTarget.TryGetValue(target.gameObject.GetInstanceID(), out t)) { t.m_Hate += damage; } else { m_DicHateTarget.Add(target.gameObject.GetInstanceID(), new HateTarget(target, damage)); } } } }
protected override void Update() { base.Update(); float deltatime = Time.deltaTime; if (m_AttackDelayTimer > 0.0f) { m_AttackDelayTimer -= deltatime; if (m_AttackDelayTimer <= 0.0f) { m_AttackDelayTimer = 0.0f; } } if (m_FreezeTimer > 0.0f) { m_FreezeTimer -= deltatime; if (m_FreezeTimer <= 0.0f) { m_FreezeTimer = 0.0f; } } if (m_AttackLevelConnetTimer > 0.0f) { m_AttackLevelConnetTimer -= deltatime; if (m_AttackLevelConnetTimer <= 0.0f) { m_AttackLevelConnetTimer = 0.0f; m_AttackAniNumber = 0; } } if (PhotonNetwork.InRoom && !m_PhotonView.IsMine) { return; } if (m_IsAutoPlay) { if (m_AttackTarget != null) { if (m_AttackTarget.m_Character == null || m_AttackTarget.m_Character.m_Live == E_LIVE.DEAD) { m_AttackTarget = null; m_NavMeshController.ClearPath(); } } if (m_DicHateTarget.Count > 0) { foreach (HateTarget h in m_DicHateTarget.Values) { h.m_Hate -= deltatime * (1.0f + h.m_Hate * 0.1f); } } if (m_DicHateTarget.Count > 0) { List <int> deletekeys = new List <int>(); foreach (HateTarget h in m_DicHateTarget.Values) { if (h.m_Hate <= 0.0f || h.m_Character == null || h.m_Character.m_Live == E_LIVE.DEAD) { deletekeys.Add(h.m_Key); continue; } if (m_AttackTarget == null) { m_AttackTarget = h; break; } else if (h.m_Hate > m_AttackTarget.m_Hate) { m_AttackTarget = h; } } if (deletekeys.Count > 0) { for (int i = 0; i < deletekeys.Count; ++i) { m_DicHateTarget.Remove(deletekeys[i]); } } } } if (m_Live == E_LIVE.DEAD) { return; } if (m_IsCharging) { return; } if (m_FreezeTimer > 0.0f) { return; } if (m_IsAutoPlay) { bool useskill = false; if (m_ListActiveSkill.Count > 0) { for (int i = 0; i < m_ListActiveSkill.Count; ++i) { if (m_ListActiveSkill[i].AutoPlayLogic()) { useskill = true; break; } } } if (useskill) { return; } m_AutoPlayLogic?.Invoke(); } if (m_State != E_STATE.IDLE) { if (m_AttackDelayTimer <= 0.0f && !m_NavMeshController.IsUpdate()) { m_State = E_STATE.IDLE; SetStateAndAnimationNetwork(E_ANIMATION.IDLE, 0.25f, 1.0f, 0.0f); } } m_NavMeshController.UpdateTransform(transform, m_MovePerSpeed, m_RotatePerSpeed); }