public void TryAttack(GameObject target) { if (_hasAttackHit) { return; } if (_combatType == eCombatType.Ranged) { AutoAttackModel attack = GetCurrentAttack(); //EffectContext context = EffectContext.Create(); //context.Initialize(gameObject, target, this); //if (_currentAttackIndex == _attackSet.attacks.Count - 1) //{ // context["AttackLength"] = GetCurrentAttackEvent(eAnimationEvent.ResetCombo, AnimationLayer); //} //else //{ // context["AttackLength"] = GetCurrentAttackEvent(eAnimationEvent.InterruptCombo, AnimationLayer); //} //context.Muted = ShouldMuteAutoAttackSounds > 0; //attack.attackEffectModel.CreateAndCast(gameObject, target, context); } else { HitMelee(target); } SendEffectEvent(eEffectEvent.AutoAttackHit); _hasAttackHit = true; }
private void BeginCharging() { if (_targeting.AttackTarget == null) { _timeHeld = 0f; return; } _chargeStarted = true; _attack = _playerController.CharacterComponent.StartChargeAttack(_targeting.AttackTarget, this); }
public void StartChargeAttack(GameObject target) { AutoAttackModel attack = GetCurrentAttack(); //if (attack.startChargeEffectModel != null) //{ // EffectContext newContext = EffectContext.Create(); // newContext.Initialize(gameObject, target, this); // attack.startChargeEffectModel.CreateAndCast(gameObject, target, newContext); //} SendEffectEvent(eEffectEvent.ChargeAttackStart); }
private void HitMelee(GameObject target) { AutoAttackModel attack = GetCurrentAttack(); float attackLength = GetCurrentAttackEvent(eAnimationEvent.InterruptCombo); List <GameObject> meleeTargets = GetMeleeTargets(); foreach (GameObject enemy in meleeTargets) { //EffectContext context = EffectContext.Create(); //context.Initialize(gameObject, enemy, this); //context["AttackLength"] = attackLength; //context.Muted = ShouldMuteAutoAttackSounds > 0; //attack.attackEffectModel.CreateAndCast(gameObject, enemy, context); } }
public void ChargeAttack(GameObject target, float timeHeld) { if (_combatType == eCombatType.Ranged) { //EffectContext context = EffectContext.Create(); //context.Initialize(gameObject, target, this); AutoAttackModel attack = GetCurrentAttack(); timeHeld = Mathf.Min(timeHeld, attack.maxChargeTime); //context["ChargeTimeNormalized"] = timeHeld / attack.maxChargeTime; //context["ChargeTime"] = timeHeld; //attack.chargeEffectModel.CreateAndCast(gameObject, target, context); SendEffectEvent(eEffectEvent.ChargeAttackHit); } else { EB.Debug.LogWarning("Melee charge attacks are not implemented"); } }
public List <GameObject> GetMeleeTargets() { AutoAttackModel attack = GetCurrentAttack(); int maxVictims = attack.maxVictims; //maxVictims += (int)StatsComponent.ExtraAutoAttackTargets.Value; if (maxVictims == 0) { return(new List <GameObject>()); } #if DEBUG //GlobalEffectReceiver globalEffectReceiver = GlobalEffectReceiver.Instance; //if (globalEffectReceiver != null) //{ // globalEffectReceiver.AddDebugAOE(gameObject, 0.5f, transform.position, AttackRange, 0, _attackSet.coneWidthDegrees, transform.forward); //} #endif Collider[] hits = Physics.OverlapSphere(transform.position, AttackRange + _characterModel.rvoRadius, _attackLayerMask); //System.Array.Sort(hits, Effect.SortTargetCollider); List <GameObject> allHits = new List <GameObject>(); foreach (Collider entity in hits) { if (Vector3.Angle(transform.forward, entity.transform.position - transform.position) < _attackSet.coneWidthDegrees / 2.0f) { allHits.Add(entity.gameObject); } } int victimsSelected = 0; List <GameObject> victims = new List <GameObject>(); // Make sure the player's target is selected as a victim if it was hit by the GameObject currentTarget = GetCurrentTarget(); if (currentTarget != null && allHits.Contains(currentTarget)) { victims.Add(currentTarget); allHits.Remove(currentTarget); //if (currentTarget.GetComponent<BaseStatsComponent>().IsCountedAsTarget) //{ // victimsSelected++; //} } //IEnumerator<GameObject> iter = allHits.GetEnumerator(); //while (iter.MoveNext() && victimsSelected < maxVictims) //{ // victims.Add(iter.Current); //BaseStatsComponent baseStatsComponent = iter.Current.GetComponent<BaseStatsComponent>(); //if (baseStatsComponent == null) //{ // EB.Debug.LogError("Object " + iter.Current + " was marked for attackable layer, but has no stats componenet!"); //} //else //{ // if (iter.Current.GetComponent<BaseStatsComponent>().IsCountedAsTarget) // { // victimsSelected++; // } //} //} return(victims); }