public override void UpdateEffect(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo) { if (stateInfo.normalizedTime > DamageTiming && animator.GetBool(TransitionParameter.GrapplingHit.ToString())) { if (stateEffect.CharacterControl.CharacterData.GrapplingTarget != null && !stateEffect.CharacterControl.CharacterData.GrapplingTarget.CharacterData.IsDead) { stateEffect.CharacterControl.Animator.SetBool(TransitionParameter.GrapplingHit.ToString(), false); CharacterControl Target = stateEffect.CharacterControl.CharacterData.GrapplingTarget; //Target.Animator.SetFloat (TransitionParameter.SpeedMultiplier.ToString (), 1.0f); //Target.Animator.Play ("Idle"); if (!Target.CharacterData.IsStunned) { Target.TakeStun(Stun, this); } if (Target.CharacterData.IsStunned) { Target.TakeDamage(Target.CharacterData.HP, HitReactDuration, this); } else { Target.TakeDamage(Damage, HitReactDuration, this); } Vector3 dirVector = Target.transform.position - stateEffect.CharacterControl.transform.position; Vector3 hitVector = (new Vector3(dirVector.x, 0, dirVector.z)).normalized; Target.TakeKnockback(KnockbackForce * hitVector, KnockbackTime); Target.CharacterData.FormerAttackTarget = null; Target.FaceTarget = -hitVector; Target.TurnToTarget(0f, 0f); //int randomIndex = Random.Range (0, 3) + 1; //Target.Animator.Play ("HitReact" + randomIndex.ToString (), 0, 0f); } } }
private void ProcessDamage(AttackInfo info) { //Debug.Log ("HIT !!!"); info.Targets.Add(control); info.CurrentTargetNum++; Vector3 dirVector = gameObject.transform.position - info.Attacker.gameObject.transform.position; Vector3 hitVector = (new Vector3(dirVector.x, 0, dirVector.z)).normalized; if (info.IsAttackForward) { if (info.IsAOEAttackAttachToPlayer) { hitVector = info.Attacker.transform.forward; } else { hitVector = info.gameObject.transform.forward; } hitVector.y = 0f; } if (info.IsAOEAttackTowardsCenter && info.Type == AttackType.AOE) { hitVector = info.gameObject.transform.position - gameObject.transform.position; hitVector.y = 0f; //Debug.Log("AOE hit! " + Time.time.ToString()); } if (info.IsAOEAttackTowardsCenter && info.Type == AttackType.Projectile) { hitVector = info.gameObject.transform.position - gameObject.transform.position; hitVector.y = 0f; //Debug.Log("AOE hit! " + Time.time.ToString()); } control.FaceTarget = -hitVector; control.TurnToTarget(0f, 0f); if (info.FreezeFrames > 0) { control.FreezeForFrames(info.FreezeFrames); info.Attacker.FreezeForFrames(info.FreezeFrames); } //Debug.Log(hitVector); //Debug.DrawRay(gameObject.transform.position, hitVector * 5f, Color.red, 0.5f); bool CanBeBlocked = (control.CharacterData.IsGuarding && control.CharacterData.BlockCount >= info.Damage); //bool PreciselyBlocked = (control.CharacterData.IsGuarding && info.PreciselyBlockedFrame > control.CharacterData.FirstFramesOfBlock && control.CharacterData.FirstFramesOfBlock > 0); bool PreciselyBlocked = (control.CharacterData.IsGuarding && info.PreciselyBlockedFrame > control.CharacterData.FirstFramesOfBlock); if (PreciselyBlocked) { Debug.Log("Precisely blocked!"); } if (info.AttackSkill != null) { if (!control.CharacterData.IsStunned && !CanBeBlocked) { control.TakeStun(info.Stun, info.AttackSkill); } else if (info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.TakeStun(info.Stun * control.CharacterData.GuardStunReduction, info.AttackSkill); } if (control.CharacterData.IsStunned && info.IsLethalToStunnedEnemy) { control.TakeDamage(control.CharacterData.HP, info.HitReactDuration, info.AttackSkill); } else if (!CanBeBlocked && !PreciselyBlocked) { control.TakeDamage(info.Damage, info.HitReactDuration, info.AttackSkill); } else if (info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.TakeDamage(info.Damage * control.CharacterData.GuardDamageReduction, 0f, info.AttackSkill); } } else if (info.ProjectileSkill != null) { if (!control.CharacterData.IsStunned && !CanBeBlocked) { control.TakeStun(info.Stun, info.ProjectileSkill); } else if (info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.TakeStun(info.Stun * control.CharacterData.GuardStunReduction, info.ProjectileSkill); } if (!CanBeBlocked && !PreciselyBlocked) { control.TakeDamage(info.Damage, info.HitReactDuration, info.ProjectileSkill); } else if (info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.TakeDamage(info.Damage * control.CharacterData.GuardDamageReduction, 0f, info.ProjectileSkill); } } if (!control.CharacterData.IsSuperArmour) { if (!CanBeBlocked && !PreciselyBlocked) { control.TakeKnockback(info.KnockbackForce * hitVector, info.KnockbackTime); } else if (info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.TakeKnockback(info.KnockbackForce * hitVector * control.CharacterData.GuardKnockbackReduction, info.KnockbackTime); } } control.CharacterData.FormerAttackTarget = null; if (control.CharacterData.IsGuarding) { if (info.AttackSkill != null && info.AttackSkill.Type == AttackType.MustCollide) { if (CanBeBlocked && info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.Animator.SetTrigger(TransitionParameter.GetHitOnGuard.ToString()); } else if (PreciselyBlocked) { control.Animator.SetTrigger(TransitionParameter.GetHitOnGuardPrecisely.ToString()); //info.Attacker.CharacterData.GetHitTime = 0.4f; info.Attacker.CharacterData.GetHitTime = 0.7f; info.Attacker.Animator.Play("GetCountered"); info.Attacker.TakeKnockback((-30f) * hitVector, 0.1f); //info.Attacker.TakeStun (5f, 1.0f, null); info.Attacker.TakeStun(2.0f * info.Stun, null); //info.Attacker.TakeDamage (0f, 0.7f, null); /* * AIProgress AI = info.Attacker.GetComponent<AIProgress>(); * if(AI != null) * { * AI.ForceEndCurrentTask(); * } */ } } if (info.ProjectileSkill != null) { if (CanBeBlocked && info.PreciselyBlockedFrame <= control.CharacterData.FirstFramesOfBlock) { control.Animator.SetTrigger(TransitionParameter.GetHitOnGuard.ToString()); } else if (PreciselyBlocked) { control.Animator.SetTrigger(TransitionParameter.GetHitOnGuardPrecisely.ToString()); if (info.CanBeReflected) { Vector3 dir = info.Attacker.gameObject.transform.position - control.gameObject.transform.position; dir.y = 0f; ReflectProjectile(info, control.GetReflectProjSpawnPoint().position, dir.normalized); //info.IsFinished = true; } /* * info.ProjectileObject.Dead (); * GameObject obj = PoolManager.Instance.GetObject (PoolObjectType.AttackInfo); * AttackInfo reflectionInfo = obj.GetComponent<AttackInfo> (); * reflectionInfo.Init (null, info.ProjectileSkill, control); * obj.SetActive (true); * extraAttackInfo.Add (reflectionInfo); * //AttackManager.Instance.CurrentAttackInfo.Add(reflectionInfo); * reflectionInfo.Register (); * reflectionInfo.ProjectileSkill.Launch (reflectionInfo, control, control.GetReflectProjSpawnPoint ()); */ } } } //CameraManager.Instance.ShakeCamera (info.HitReactDuration); //control.Dead (); }