void SendKnockDownEvent() { _eventKnockDown = AnimFSMEventKnockDown.pool.Get(); _eventKnockDown.fromWeapon = Agent.BlackBoard.attackerWeapon; _eventKnockDown.attacker = Agent.BlackBoard.Attacker; _eventKnockDown.impuls = Agent.BlackBoard.impuls; _eventKnockDown.lyingTime = Agent.BlackBoard.knockDownLyingTime; Agent.FSMComponent.SendEvent(_eventKnockDown); }
public override void Reset() { base.Reset(); _eventInjury = null; _eventKnockDown = null; _eventDeath = null; _attacker = null; _attackerRepeatCount = 0; _damageResultType = DamageResultType.NONE; }
void SendEvent() { switch (_damageResultType) { case DamageResultType.INJURY: if (_eventKnockDown != null) { _eventKnockDown.Release(); _eventKnockDown = null; } if (_eventDeath != null) { _eventDeath.Release(); _eventDeath = null; } SendInjuryEvent(); break; case DamageResultType.KNOCK_DOWN: if (_eventInjury != null) { _eventInjury.Release(); _eventInjury = null; } if (_eventDeath != null) { _eventDeath.Release(); _eventDeath = null; } SendKnockDownEvent(); break; case DamageResultType.DEATH: if (_eventKnockDown != null) { _eventKnockDown.Release(); _eventKnockDown = null; } if (_eventInjury != null) { _eventInjury.Release(); _eventInjury = null; } SendDeathEvent(); break; default: return; } }
public override void OnExit(Phenix.Unity.AI.WorldState ws) { if (_eventInjury != null) { _eventInjury.Release(); _eventInjury = null; } if (_eventKnockDown != null) { _eventKnockDown.Release(); _eventKnockDown = null; } if (_eventDeath != null) { _eventDeath.Release(); _eventDeath = null; } base.OnExit(ws); }
protected override void Initialize(FSMEvent ev = null) { _eventKnockDown = ev as AnimFSMEventKnockDown; string animName = Agent.AnimSet.GetKnockdowAnim(KnockdownState.Down, Agent.BlackBoard.weaponSelected); _startRotation = Agent.Transform.rotation; _startPosition = Agent.Transform.position; Vector3 dir = _eventKnockDown.attacker.Position - Agent.Transform.position; float angle = 0; if (dir.sqrMagnitude > 0.1f * 0.1f) { dir.Normalize(); angle = Vector3.Angle(Agent.Transform.forward, dir); } else { dir = Agent.Transform.forward; } _finalRotation.SetLookRotation(dir); _rotationTime = angle / 500.0f; _finalPosition = _startPosition + _eventKnockDown.impuls; _moveTime = Agent.AnimEngine[animName].length * 0.4f; _rotationOk = (_rotationTime == 0); _positionOK = (_moveTime == 0); _curRotationTime = 0; _curMoveTime = 0; Phenix.Unity.Utilities.Tools.PlayAnimation(Agent.AnimEngine, animName, 0.05f); _endOfStateTime = Time.timeSinceLevelLoad + Agent.AnimEngine[animName].length * 0.9f; _lyingEndTime = _endOfStateTime + _eventKnockDown.lyingTime; _status = KnockdownStatus.FALL_DOWN; }