protected override void Initialize(AgentAction _action) { base.Initialize(_action); SetFinished(false); State = E_State.E_Preparing; Owner.BlackBoard.MotionType = E_MotionType.Attack; Action = _action as AgentActionAttack; Action.IsHit = false; if (Action.Data == null) { Action.Data = null;//AnimSet Get } AnimAttackData = Action.Data; if (AnimAttackData == null) { Debug.LogError("AnimAttackData is null"); } StartPosition = Transform.position; StartRotation = Transform.rotation; float angle = 0; float distance = 0; if (Action.Target != null) { Vector3 dir = Action.Target.Position - Transform.position; distance = dir.magnitude; if (distance > 0.1f) { dir.Normalize(); angle = Vector3.Angle(Transform.forward, dir); //todo : add back logic } else { dir = Transform.forward; } FinalRotation.SetLookRotation(dir); if (distance < Owner.BlackBoard.WeaponRange) { FinalPosition = StartPosition; } else { FinalPosition = Action.Target.Transform.position - dir * Owner.BlackBoard.WeaponRange; } MoveTime = (FinalPosition - StartPosition).magnitude / 10.0f; RotationTime = angle / 720.0f; } else { FinalRotation.SetLookRotation(Action.AttackDir); RotationTime = Vector3.Angle(Transform.forward, Action.AttackDir) / 720.0f; MoveTime = 0; } PositionOk = MoveTime == 0; RotationOk = RotationTime == 0; CurrentMoveTime = 0; CurrentRotationTime = 0; }
void Awake() { AnimAttacksBow = new AnimAttackData("bowFire", null, -1, 2.95f, 3.0f, 10, 20, 1, E_CriticalHitType.None, false); Animation anims = GetComponent <Animation>(); anims["idle"].layer = 0; anims["idleBow"].layer = 0; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["rotateLeft"].layer = 0; anims["rotateRight"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injuryFront"].layer = 1; anims["injuryBack"].layer = 1; anims["bowFire"].layer = 0; //anims["showBow"].layer = 0; //anims["hideSword"].layer = 1; anims["knockdown"].layer = 0; anims["knockdownLoop"].layer = 0; anims["knockdownUp"].layer = 0; anims["knockdownDeath"].layer = 0; }
public IEnumerator ShowTrailDust(AnimAttackData data) { Color colorDust = new Color(1, 1, 1, 1); data.Dust.SetActiveRecursively(true); data.MaterialDust.SetColor("_TintColor", colorDust); data.AnimationDust["Anim_Dust"].speed = 2.0f; data.AnimationDust.Play(); while (colorDust.a > 0) { colorDust.a -= Time.deltaTime * 3; if (colorDust.a < 0) { colorDust.a = 0; } data.MaterialDust.SetColor("_TintColor", colorDust); yield return(new WaitForEndOfFrame()); } data.Dust.SetActiveRecursively(false); }
void Awake() { AnimAttacksSwordL = new AnimAttackData("attackA", null, 0.7f, 0.6f, 0.4f, 0.85f, 0.9f, 10, 20, 2.5f, E_CriticalHitType.None, 0, false, false, false, false); AnimAttacksSwordS = new AnimAttackData("attackB", null, 0.7f, 0.6f, 0.4f, 0.85f, 0.9f, 10, 20, 2.5f, E_CriticalHitType.None, 0, false, false, false, false); AnimRollAttack = new AnimAttackData("", null, 0, 0.5f, 1.5f, 30, 20, 3, E_CriticalHitType.None, false); Animation anims = GetComponent <Animation>(); anims["idleSword"].layer = 0; anims["walkSword"].layer = 0; /*anims["death01"].layer = 2; * anims["death02"].layer = 2; * anims["injuryFront01"].layer = 1; * anims["injuryFront02"].layer = 1; * anims["injuryFront03"].layer = 1; * anims["injuryFront04"].layer = 1; * anims["injuryBack"].layer = 1;*/ anims["attackRollLoop"].speed = 0.7f; anims["attackA"].layer = 0; // anims["attackRoll"].layer = 0; anims["idleTount"].speed = 1.5f; /* anims["blockStart"].layer = 0; * anims["blockLoop"].layer = 0; * anims["blockEnd"].layer = 0; * anims["blockFailed"].layer = 0; * anims["blockHit"].layer = 0;*/ // anims["blockStepLeft"].layer = 0; // anims["blockStepRight"].layer = 0; }
public override void Reset() { base.Reset(); target = null; animAttackData = null; attackDir = Vector3.zero; }
public void AddOrder(AgentOrder order) { Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type); switch (order.Type) { case AgentOrder.E_OrderType.E_GOTO: Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false); DesiredDirection = order.Direction; DesiredPosition = order.Position; MoveSpeedModifier = order.MoveSpeedModifier; break; case AgentOrder.E_OrderType.E_STOPMOVE: Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true); DesiredPosition = order.Position; break; case AgentOrder.E_OrderType.E_ATTACK: bool inRange = order.Target == null || (order.Target.Position - Owner.Position).magnitude <= WeaponRange; Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, inRange); DesiredTarget = order.Target; DesiredAttackType = order.AttackType; DesiredAttackPhase = order.AnimAttackData; break; default: break; } AgentOrderFactory.Return(order); }
public void Initialize(/*Agent owner*/) { if (attackType == AttackType.None) { return; } target = Owner.transform.GetComponent <BlackBoard>().desiredTarget;//Owner.transform.GetComponent<PlayerEnemyDecision>().GetBestTarget(); if (target == null) { attackDir = Owner.transform.forward; } ComboMgr comboMgr = Owner.transform.GetComponent <ComboMgr>(); if (comboMgr != null) { if (target != null && target.BlackBoard.IsKnockedDown) { data = Owner.AnimSet.GetFirstAttackAnim(Owner.BlackBoard.weaponSelected, AttackType.Fatality); attackType = AttackType.Fatality; comboMgr.Reset(); } else { data = comboMgr.ProcessCombo(attackType); } } else { data = Owner.GetComponent <AnimSet>().GetFirstAttackAnim(Owner.GetComponent <BlackBoard>().weaponSelected, attackType); } }
void Awake() { AnimAttacksSwordL = new AnimAttackData("attackPeasant", null, 0.8f, 0.68f, 0.55f, 0.75f, 0.8f, 5, 20, 1, E_CriticalHitType.None, 0, false, false, false, false); Animation anims = GetComponent <Animation>(); anims["idle"].layer = 0; anims["idleSword"].layer = 0; anims["run"].layer = 0; anims["runSword"].layer = 0; anims["runSwordBackward"].layer = 0; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["rotationLeft"].layer = 0; anims["rotationRight"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injuryFront01"].layer = 1; anims["injuryFront02"].layer = 1; anims["injuryFront03"].layer = 1; anims["injuryFront04"].layer = 1; anims["attackPeasant"].layer = 0; anims["attackPeasant"].speed = 1.1f; anims["showSword"].layer = 0; anims["hideSword"].layer = 1; // anims["spawn"].layer = 1; }
public void DoDamageFatality(Agent mainTarget, WeaponType byWeapon, AnimAttackData data) { if (mainTarget.BlackBoard.IsAlive == false || mainTarget.enabled == false) { return; } mainTarget.ReceiveDamage(this, byWeapon, 1000, data); }
public override void Reset(Agent agent) { base.Reset(agent); target = null; hit = false; attackPhaseDone = false; data = null; attackType = AttackType.None; }
public override void Reset() { base.Reset(); Target = null; Hit = false; AttackPhaseDone = false; Data = null; AttackType = E_AttackType.None; }
public override void Reset() { base.Reset(); target = null; attackDir = Vector3.zero; attackPhaseStart = false; attackPhaseDone = false; animAttackData = null; }
override protected void Initialize(ActionBase action) { base.Initialize(action); Action = action as ActionAttack; SetFinished(false); if (Action.Data == null) { Action.Data = Owner.AnimSet.GetFirstAttackAnim(Owner.BlackBoard.WeaponSelected, Action.AttackType); } AnimAttackData = Action.Data; StartRotation = Transform.rotation; Action.AttackPhaseDone = false; Action.Hit = false; float angle = 0; if (Action.Target != null) { Vector3 dir = Action.Target.Position - Transform.position; //float distance = dir.magnitude; if (dir.sqrMagnitude > 0.1f * 0.1f) { dir.Normalize(); angle = Vector3.Angle(Transform.forward, dir); } else { dir = Transform.forward; } FinalRotation.SetLookRotation(dir); RotationTime = angle / 180.0f; } else { //Debug.Log("attacking dir " + Action.AttackDir.ToString()); FinalRotation.SetLookRotation(Action.AttackDir); RotationTime = Vector3.Angle(Transform.forward, Action.AttackDir) / 1040.0f; } //Debug.Log("RT " + RotationTime + " MT " + MoveTime + " Angle " + angle); RotationOk = RotationTime == 0; CurrentRotationTime = 0; PlayAnim(); }
static void ReceiveBlockedHit(Agent1 agent, Agent1 attacker, WeaponType byWeapon, float damage, AnimAttackData data) { agent.BlackBoard.Attacker = attacker; agent.BlackBoard.attackerWeapon = byWeapon; //_goapMgr.WorldState.SetWSProperty(WorldStatePropKey.EVENT, EventTypes.BLOCK_BROKEN); bool fromBehind = Vector3.Dot(attacker.Forward, agent.Forward) > -0.1f; if (fromBehind) { //agent.BlackBoard.blockResult = BlockResult.FAIL; ReceiveDamage(agent, attacker, byWeapon, damage, data.hitMomentum);// block失败(扣血) //agent.BlackBoard.health = Mathf.Max(1, agent.BlackBoard.health - damage); //agent.BlackBoard.damageType = DamageType.BACK; //CombatEffectMgr.Instance.PlayBloodEffect(agent.Transform.position, -attacker.Forward); ParticleComponent.Instance.Play(ParticleType.BLOOD_AND_HIT_BLINK, agent.Transform.position, -attacker.Forward);; //SpriteEffectsManager.Instance.CreateBlood(Transform); SpriteComponent.Instance.CreateSprite(SpriteType.BLOOD, new Vector3(agent.transform.localPosition.x, agent.transform.localPosition.y + 0.5f, agent.transform.localPosition.z), new Vector3(90, Random.Range(0, 180), 0)); } else { // 如果满足破防几率 if (Random.Range(0, 100) < agent.BlackBoard.breakBlockChance) { // block失败(但不扣血) //agent.BlackBoard.blockResult = BlockResult.FAIL; AnimFSMEventBreakBlock eventBreakBlock = AnimFSMEventBreakBlock.pool.Get(); eventBreakBlock.attacker = attacker; eventBreakBlock.attackerWeapon = byWeapon; eventBreakBlock.success = false; agent.FSMComponent.SendEvent(eventBreakBlock); //if (attacker.isPlayer) // Game.Instance.NumberOfBreakBlocks++; //CombatEffectsManager.Instance.PlayBlockBreakEffect(Transform.position, -attacker.Forward); } else { // block成功 //agent.BlackBoard.blockResult = BlockResult.SUCCESS; AnimFSMEventBreakBlock eventBreakBlock = AnimFSMEventBreakBlock.pool.Get(); eventBreakBlock.attacker = attacker; eventBreakBlock.attackerWeapon = byWeapon; eventBreakBlock.success = true; agent.FSMComponent.SendEvent(eventBreakBlock); //if (attacker.isPlayer) // Game.Instance.NumberOfBlockedHits++; //CombatEffectMgr.Instance.PlayBlockHitEffect(agent.ChestPosition, -attacker.Forward); ParticleComponent.Instance.Play(ParticleType.BLOCK_SUCCESS, agent.ChestPosition, -attacker.Forward); } } }
//播放武器的拖拽效果 protected IEnumerator ShowTrail(AnimAttackData data, float speed, float delay, bool critical, float dustDelay) { Debug.Log("ShowTrail"); // Time.timeScale = 0.1f; if (data.Trail == null) { yield break; } if (dustDelay < 0) { dustDelay = 0; } //yield return new WaitForSeconds(delay); data.Parent.position = Transform.position + Vector3.up * 0.15f; data.Parent.rotation = Quaternion.AngleAxis(Transform.rotation.eulerAngles.y, Vector3.up); Debug.Log("data.Trail.SetActive(true);"); data.Trail.SetActive(true); if (data.Dust) { data.Dust.SetActive(false); } Color color = Color.white; data.Material.SetColor("_TintColor", color); if (data.Dust) { yield return(new WaitForSeconds(dustDelay)); Owner.StartCoroutine(ShowTrailDust(data)); } yield return(new WaitForSeconds(delay - dustDelay)); while (color.a > 0) { color.a -= Time.deltaTime * speed; if (color.a < 0) { color.a = 0; } data.Material.SetColor("_TintColor", color); yield return(new WaitForEndOfFrame()); } Debug.Log("data.Trail.SetActive(false);"); data.Trail.SetActive(false); }
public static void ShowTrail(Agent1 agent, AnimAttackData data, float trailTime) { if (agent.BlackBoard.showMotionEffect == false || data.trail == null) { return; } data.trailParenTrans.position = agent.Transform.position + Vector3.up * 0.15f; data.trailParenTrans.rotation = Quaternion.AngleAxis(agent.Transform.rotation.eulerAngles.y, Vector3.up); data.trail.SetActive(true); MaterialTools.Instance.FadeOut(data.renderer, "_TintColor", trailTime, data.renderer.gameObject); }
public void DoDamageToPlayer(Agent attacker, AnimAttackData data, float distance) { Agent mainTarget = Player.Instance.Agent; if (mainTarget.BlackBoard.MotionType != E_MotionType.Roll) { if ((mainTarget.Position - attacker.Position).sqrMagnitude < distance * distance) { mainTarget.ReceiveDamage(attacker, E_WeaponType.Body, data.HitDamage, data); attacker.Sound.PlayAttackHit(); } } }
void Awake() { AnimAttackX = new AnimAttackData("attackX", null, 0, 0.6f, 1.7f, 10, 60, 2, CriticalHitType.NONE, false); AnimAttackBerserk = new AnimAttackData("attackO", null, 0, 0.9f, 3.5f, 30, 30, 3.5f, CriticalHitType.NONE, false); AnimAttackInjury = new AnimAttackData("attackInjury", null, 0, 0.5f, 1.5f, 30, 180, 4, CriticalHitType.NONE, false); AddComboAttack(new Combo() { comboType = ComboType.SINGLE_SWORD, comboSteps = new ComboStep[] { new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("attackX", null, 0f, 0.6f, 1.7f, 10, 60, 2, CriticalHitType.NONE, false) }, new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("attackXX", null, 0f, 0.6f, 1.7f, 10, 60, 2, CriticalHitType.NONE, false) }, } }); AddComboAttack(new Combo() { comboType = ComboType.REVENGE, comboSteps = new ComboStep[] { new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("attackInjury", null, 0, 0.5f, 1.5f, 30, 180, 2, CriticalHitType.NONE, false) }, } }); AddComboAttack(new Combo() { comboType = ComboType.ATTACK_BERSERK, comboSteps = new ComboStep[] { new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("attackO", null, 0, 0.9f, 3.5f, 30, 30, 2f, CriticalHitType.NONE, false) } } }); }
void Awake() { AnimAttacksSword1 = new AnimAttackData("attackA", null, 1, 0.25f, 0.50f, 7, 20, 1, CriticalHitType.None, false); AnimAttacksSword2 = new AnimAttackData("attackAA", null, 1, 0.25f, 0.50f, 7, 20, 1, CriticalHitType.None, false); AnimAttackWhirl = new AnimAttackData("attackWhirl", null, 1, 0.25f, 0.40f, 7, 10, 1, CriticalHitType.None, false); Animation anims = GetComponent <Animation>(); anims["idle"].layer = 0; anims["idleSword"].layer = 0; anims["idleTaunt"].layer = 1; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["combatRunF"].layer = 0; anims["combatRunB"].layer = 0; anims["rotationL"].layer = 0; anims["rotationR"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injury01"].layer = 1; anims["injury02"].layer = 1; anims["injury03"].layer = 1; anims["injuryBack"].layer = 1; anims["attackA"].speed = 1.2f; anims["attackAA"].speed = 1.2f; anims["attackA"].layer = 0; anims["attackAA"].layer = 0; anims["attackWhirl"].layer = 0; // anims["attackA"].speed = 1.3f; //anims["attackAA"].speed = 1.3f; anims["knockdown"].layer = 0; anims["knockdownLoop"].layer = 0; anims["knockdownUp"].layer = 0; anims["knockdownDeath"].layer = 0; anims["showSword"].layer = 0; anims["hideSword"].layer = 1; // anims["spawn"].layer = 1; }
void Awake() { AnimAttacksSwordL = new AnimAttackData("attackA", null, 0.7f, 0.30f, 0.68f, 7, 20, 1, CriticalHitType.None, false); AnimAttacksSwordCounter = new AnimAttackData("attackCounter", null, 1.0f, 0.65f, 0.4f, 0.68f, 0.7f, 15, 25, 2, CriticalHitType.None, 0, false, false, false, false); Animation anims = GetComponent <Animation>(); anims["idle"].layer = 0; anims["idleSword"].layer = 0; anims["run"].layer = 0; anims["runSword"].layer = 0; anims["runSwordBackward"].layer = 0; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["rotationLeft"].layer = 0; anims["rotationRight"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injuryFront01"].layer = 1; anims["injuryFront02"].layer = 1; anims["injuryFront03"].layer = 1; anims["injuryFront04"].layer = 1; anims["blockStart"].layer = 0; anims["blockLoop"].layer = 0; anims["blockEnd"].layer = 0; anims["blockFailed"].layer = 0; anims["blockHit"].layer = 0; anims["blockStepLeft"].layer = 0; anims["blockStepRight"].layer = 0; anims["knockdown"].layer = 0; anims["knockdownLoop"].layer = 0; anims["knockdownUp"].layer = 0; anims["knockdownDeath"].layer = 0; anims["showSword"].layer = 0; anims["hideSword"].layer = 1; // anims["spawn"].layer = 1; }
void Awake() { AnimAttacksSwordL = new AnimAttackData("attackPeasant", null, 0.8f, 0.68f, 0.55f, 0.75f, 0.8f, 5, 20, 1, CriticalHitType.NONE, 0, false, false, false, false); Animation anims = GetComponent <Animation>(); anims.wrapMode = WrapMode.Once; anims["idle"].layer = 0; anims["idleSword"].layer = 0; anims["run"].layer = 0; anims["runSword"].layer = 0; anims["runSwordBackward"].layer = 0; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["rotationLeft"].layer = 0; anims["rotationRight"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injuryFront01"].layer = 1; anims["injuryFront02"].layer = 1; anims["injuryFront03"].layer = 1; anims["injuryFront04"].layer = 1; anims["attackPeasant"].layer = 0; anims["attackPeasant"].speed = 1.1f; anims["showSword"].layer = 0; anims["hideSword"].layer = 1; AddComboAttack(new Combo() { comboType = ComboType.SINGLE_SWORD, comboSteps = new ComboStep[] { new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("attackPeasant", null, 0.8f, 0.68f, 0.55f, 0.75f, 0.8f, 5, 20, 1, CriticalHitType.NONE, 0, false, false, false, false) } } }); }
void Awake() { AnimAttacksBow = new AnimAttackData("bowFire", null, -1, 2.95f, 3.0f, 10, 20, 1, CriticalHitType.NONE, false); Animation anims = GetComponent <Animation>(); anims["idle"].layer = 0; anims["idleBow"].layer = 0; anims["walk"].layer = 0; anims["combatMoveF"].layer = 0; anims["combatMoveB"].layer = 0; anims["combatMoveR"].layer = 0; anims["combatMoveL"].layer = 0; anims["rotateLeft"].layer = 0; anims["rotateRight"].layer = 0; anims["death01"].layer = 2; anims["death02"].layer = 2; anims["injuryFront"].layer = 1; anims["injuryBack"].layer = 1; anims["bowFire"].speed = 2; anims["bowFire"].layer = 0; //anims["showBow"].layer = 0; //anims["hideSword"].layer = 1; anims["knockdown"].layer = 0; anims["knockdownLoop"].layer = 0; anims["knockdownUp"].layer = 0; anims["knockdownDeath"].layer = 0; AddComboAttack(new Combo() { comboType = ComboType.BOW, comboSteps = new ComboStep[] { new ComboStep() { orderAttackType = OrderAttackType.NONE, data = new AnimAttackData ("bowFire", null, -1, 1.47f, 1.5f, 10, 20, 1, CriticalHitType.NONE, false) }, } }); }
public static void DoRollDamage(Agent1 agent, AnimAttackData data, float range) { if (agent == null || data == null) { return; } if (agent.BlackBoard.motionType != MotionType.ROLL) { return; } Vector3 attackerDir = agent.Forward; Vector3 dirToTarget = Vector3.zero; for (int i = 0; i < Game1.Instance.AgentMgr.agents.Count; i++) { Agent1 target = Game1.Instance.AgentMgr.agents[i]; if (target == null || target == agent || target.BlackBoard.IsAlive == false || target.BlackBoard.IsKnockedDown) { continue; } if (target.BlackBoard.invulnerable || (target.BlackBoard.damageOnlyFromBack && TransformTools.Instance.IsBehindTarget(agent.Transform, target.Transform) == false)) { // 攻击无效 ReceiveHitCompletelyBlocked(target, agent); HandleSound.PlaySoundBlocked(); continue; } dirToTarget = target.Position - agent.Position; if (dirToTarget.sqrMagnitude < range * range) { //if (data.useImpuls) //{ // ReceiveImpuls(target, agent, dirToTarget.normalized * data.hitMomentum); //} ReceiveDamage(target, agent, WeaponType.BODY, data.hitDamage, data.hitMomentum); HandleSound.PlaySoundHit(); } } }
public void DoMeleeDamage(Agent mainTarget, WeaponType byWeapon, AnimAttackData data, bool critical, bool knockdown) { if (mainTarget == null) { return; } if (isPlayer) { EnemiesRecvDamage(mainTarget, byWeapon, data, critical, knockdown); } else { bool hit = false; Vector3 dirToEnemy; Vector3 attackerDir = this.Forward; if (mainTarget.BlackBoard.invulnerable == false && mainTarget.BlackBoard.motionType != MotionType.ROLL) { dirToEnemy = mainTarget.Position - this.Position; float len = dirToEnemy.sqrMagnitude; if (len < this.BlackBoard.SqrWeaponRange) { dirToEnemy.Normalize(); if (len < 0.5f * 0.5f || data.hitAngle == -1 || Vector3.Angle(attackerDir, dirToEnemy) < data.hitAngle) { mainTarget.ReceiveDamage(this, byWeapon, data.hitDamage, data); hit = true; } } } //if (hit) //attacker.SoundPlayHit(); //else //attacker.SoundPlayMiss(); } }
public void ReceiveBlockedHit(Agent attacker, WeaponType byWeapon, float damage, AnimAttackData data) { BlackBoard.attacker = attacker; BlackBoard.attackerWeapon = byWeapon; //_goapMgr.WorldState.SetWSProperty(WorldStatePropKey.EVENT, EventTypes.BLOCK_BROKEN); bool fromBehind = Vector3.Dot(attacker.Forward, Forward) > -0.1f; if (fromBehind) { BlackBoard.blockResult = BlockResult.FAIL; BlackBoard.health = Mathf.Max(1, BlackBoard.health - damage); //BlackBoard.damageType = DamageType.BREAK_BLOCK; // 抵挡破防失败(扣血) CombatEffectMgr.Instance.PlayBloodEffect(Transform.position, -attacker.Forward); //SpriteEffectsManager.Instance.CreateBlood(Transform); } else { if (true /*data.breakBlock*/) // 如果对方招式有破防效果 { BlackBoard.blockResult = BlockResult.FAIL; //BlackBoard.damageType = DamageType.BREAK_BLOCK; // 抵挡破防失败(但不扣血) //if (attacker.isPlayer) // Game.Instance.NumberOfBreakBlocks++; //CombatEffectsManager.Instance.PlayBlockBreakEffect(Transform.position, -attacker.Forward); } else { BlackBoard.blockResult = BlockResult.SUCCESS; BlackBoard.damageType = DamageType.FRONT; // 抵挡破防成功 //if (attacker.isPlayer) // Game.Instance.NumberOfBlockedHits++; CombatEffectMgr.Instance.PlayBlockHitEffect(ChestPosition, -attacker.Forward); } } }
public void OrderAdd(AgentOrder order) { // Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type); if (IsOrderAddPossible(order.Type)) { Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, order.Type); switch (order.Type) { case AgentOrder.E_OrderType.E_STOPMOVE: Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true); DesiredPosition = Owner.Position; break; case AgentOrder.E_OrderType.E_GOTO: Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false); DesiredPosition = order.Position; DesiredDirection = order.Direction; MoveSpeedModifier = order.MoveSpeedModifier; break; case AgentOrder.E_OrderType.E_DODGE: DesiredDirection = order.Direction; // Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type); break; case AgentOrder.E_OrderType.E_USE: Owner.WorldState.SetWSProperty(E_PropKey.E_USE_WORLD_OBJECT, true); if ((order.Position - Owner.Position).sqrMagnitude <= 1) { Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, true); } else { Owner.WorldState.SetWSProperty(E_PropKey.E_AT_TARGET_POS, false); } DesiredPosition = order.Position; InteractionObject = order.InteractionObject; Interaction = order.Interaction; break; case AgentOrder.E_OrderType.E_ATTACK: if (order.Target == null || (order.Target.Position - Owner.Position).magnitude <= (WeaponRange + 0.2f)) { Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, true); } else { Owner.WorldState.SetWSProperty(E_PropKey.E_IN_WEAPONS_RANGE, false); } DesiredAttackType = order.AttackType; DesiredTarget = order.Target; DesiredDirection = order.Direction; DesiredAttackPhase = order.AnimAttackData; break; } // Debug.Log(Time.timeSinceLevelLoad + " order arrived " + order.Type); } else if (order.Type == AgentOrder.E_OrderType.E_ATTACK) { // Debug.Log(Time.timeSinceLevelLoad + " " +order.Type + " is nto allowed because " + currentOrder); } AgentOrderFactory.Return(order); }
public override void Reset() { base.Reset(); data = null; target = null; }
IEnumerator EnemiesRecvDamage(Agent attacker, Agent mainTarget, E_WeaponType byWeapon, AnimAttackData data, bool critical, bool knockdown) { bool hit = false; bool block = false; bool knock = false; Vector3 dirToEnemy; Vector3 center = attacker.Position; Vector3 attackerDir = attacker.Forward; Agent enemy; yield return(new WaitForEndOfFrame()); for (int i = 0; i < Enemies.Count; i++) { enemy = Enemies[i]; if (enemy.IsAlive == false || enemy.enabled == false || enemy.IsKnockedDown == true) { continue; } dirToEnemy = enemy.Position - center; float len = dirToEnemy.magnitude; dirToEnemy.Normalize(); if (enemy.IsInvulnerable || (enemy.BlackBoard.DamageOnlyFromBack && Vector3.Angle(attackerDir, enemy.Forward) > 80)) { // Debug.Log(enemy.name + " high angle " + Vector3.Angle(attackerDir, enemy.Forward)); enemy.ReceiveHitCompletelyBlocked(attacker); block = true; continue; } if (len > attacker.BlackBoard.WeaponRange) { if (data.HitAreaKnockdown == true && knockdown && len < attacker.BlackBoard.WeaponRange * 1.2f) { knock = true; enemy.ReceiveKnockDown(attacker, dirToEnemy * data.HitMomentum); } else if (data.UseImpuls && len < attacker.BlackBoard.WeaponRange * 1.4f) { enemy.ReceiveImpuls(attacker, dirToEnemy * data.HitMomentum); } continue; //too far } if (enemy.IsInvulnerable || (enemy.BlackBoard.DamageOnlyFromBack && Vector3.Angle(attackerDir, enemy.Forward) > 80)) { // Debug.Log(enemy.name + " high angle " + Vector3.Angle(attackerDir, enemy.Forward)); enemy.ReceiveHitCompletelyBlocked(attacker); block = true; continue; } if (len > 0.5f && Vector3.Angle(attackerDir, dirToEnemy) > data.HitAngle) { if (data.UseImpuls) { //Debug.Log(enemy.name + " impuls"); enemy.ReceiveImpuls(attacker, dirToEnemy * data.HitMomentum); } continue; } if (enemy.BlackBoard.CriticalAllowed && data.HitCriticalType != E_CriticalHitType.None && Vector3.Angle(attackerDir, enemy.Forward) < 45) // from behind { // Debug.Log(enemy.name + " critical from behind"); enemy.ReceiveCriticalHit(attacker, data.HitCriticalType); hit = true; } else if (enemy.IsBlocking) { //Debug.Log(enemy.name + " block "); enemy.ReceiveBlockedHit(attacker, byWeapon, data.HitDamage, data); block = true; } else if (enemy.BlackBoard.CriticalAllowed && critical && (mainTarget == enemy || (data.HitCriticalType == E_CriticalHitType.Horizontal && Random.Range(0, 100) < 30))) { // Debug.Log(enemy.name + " critical by chance"); enemy.ReceiveCriticalHit(attacker, data.HitCriticalType); hit = true; } else if (data.HitAreaKnockdown == true && knockdown) { //Debug.Log(Time.timeSinceLevelLoad + " " + enemy.name + " knockdown"); enemy.ReceiveKnockDown(attacker, dirToEnemy * (1 - (len / attacker.BlackBoard.WeaponRange) + data.HitMomentum)); knock = true; } else { // Debug.Log(enemy.name + " damage"); enemy.ReceiveDamage(attacker, byWeapon, data.HitDamage, data); hit = true; } yield return(new WaitForEndOfFrame()); } if (knock) { attacker.Sound.PlayKnockdown(); } else if (block) { attacker.Sound.PlayAttackBlock(); } else if (hit) { attacker.Sound.PlayAttackHit(); } else { attacker.Sound.PlayAttackMiss(); } }
public void DoDamageFatality(Agent attacker, Agent mainTarget, E_WeaponType byWeapon, AnimAttackData data) { if (mainTarget.IsAlive == false || mainTarget.enabled == false) { return; } mainTarget.ReceiveDamage(attacker, byWeapon, 1000, data); }
public void DoMeleeDamage(Agent attacker, Agent mainTarget, E_WeaponType byWeapon, AnimAttackData data, bool critical, bool knockdown) { if (attacker == Player.Instance.Agent) { StartCoroutine(EnemiesRecvDamage(attacker, mainTarget, byWeapon, data, critical, knockdown)); } else { bool hit = false; Vector3 dirToEnemy; Vector3 attackerDir = attacker.Forward; if (mainTarget == null) { mainTarget = Player.Instance.Agent; } if (mainTarget.IsInvulnerable == false && mainTarget.BlackBoard.MotionType != E_MotionType.Roll) { dirToEnemy = mainTarget.Position - attacker.Position; float len = dirToEnemy.sqrMagnitude; if (len < attacker.BlackBoard.sqrWeaponRange) { dirToEnemy.Normalize(); if (len < 0.5f * 0.5f || data.HitAngle == -1 || Vector3.Angle(attackerDir, dirToEnemy) < data.HitAngle) { if (Game.Instance.GameDifficulty == E_GameDifficulty.Hard) { mainTarget.ReceiveDamage(attacker, byWeapon, data.HitDamage * 1.2f, data); } else { mainTarget.ReceiveDamage(attacker, byWeapon, data.HitDamage, data); } hit = true; } } } if (hit) { attacker.Sound.PlayAttackHit(); } else { attacker.Sound.PlayAttackMiss(); } } }