public void HandleAction(AgentAction action) { //if(Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + gameObject.name + " handle action " + action.ToString()); if (enabled == false || action.IsFailed()) { return; } if (action is AgentActionWeaponChange) { if (Owner.IsAlive) { StartCoroutine(SwitchWeapon(action as AgentActionWeaponChange)); } return; } /* //THROW_RUN_2 * if (action is AgentActionUseItem) * { * StartCoroutine( ThrowItem(action as AgentActionUseItem) ); * return; * } */ if (FSM.DoAction(action) == false) { action.SetFailed(); } }
override public bool HandleNewAction(AgentAction action) { if (action as AgentActionBlock != null) { Debug.LogError("obsolete AgentActionBlock arrived"); action.SetFailed(); return(true); } if (action as AgentActionDamageBlocked != null) { ActionDamageBlocked = action as AgentActionDamageBlocked; //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " Handle new action " + action.ToString()); if (ActionDamageBlocked.BreakBlock == true) { InitializeBlockFailed(); } else { InitializeBlockSuccess(); } return(true); } return(false); }
void InitializeNext(AgentAction action) { if (CurrentPhase + 1 == MaxPhases) {/// no more phases action.SetFailed(); return; } if (Action != null) { Action.SetSuccess(); } SetFinished(false); // just for sure CurrentPhase++; Action = action as AgentActionInjury; // play owner anims string animName = Owner.AnimSet.GetInjuryPhaseAnim(CurrentPhase); CrossFade(animName, 0.1f); //end of state EndOfStateTime = AnimEngine[animName].length + Time.timeSinceLevelLoad; Owner.BlackBoard.MotionType = E_MotionType.None; }
public override bool HandleNewAction(AgentAction action) { if (action as AgentActionKnockdown != null) { Debug.LogError("obsolete AgentActionKnockdown arrived"); action.SetFailed(); return(true); } else if (action as AgentActionInjury != null) { action.SetSuccess(); return(true); } /*else if (action as AgentActionDeath != null) * { * ActionDeath = action as AgentActionDeath; * //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " Handle new action " + action.ToString()); * * * InitializeDeath(); * * return true; * }*/ return(false); }
override public bool HandleNewAction(AgentAction action) { if (action as AgentActionAttackRoll != null) { action.SetFailed(); return(true); } return(false); }
override public bool HandleNewAction(AgentAction action) { if (action is AgentActionDeath) { action.SetFailed(); return(true); } return(false); }
public override bool HandleNewAction(AgentAction action) { if (action is AgentActionPlayAnim) { if (Action != null) { action.SetFailed(); } } return(false); }
override public bool HandleNewAction(AgentAction action) { if (action is AgentActionUseLever) { if (Action != null) { action.SetFailed(); } } return(false); }
public override bool HandleNewAction(AgentAction action) { if (action is AgentActionCoverLeave) { if (Action != null) { Debug.LogError(ToString() + ": Second action is not allowed"); action.SetFailed(); return(true); } Initialize(action); return(true); } return(false); }
public override bool HandleNewAction(AgentAction action) { if (action is AgentActionCoverFire) { Debug.LogError(ToString() + ": Second action is not allowed"); action.SetFailed(); return(true); } if (action is AgentActionCoverFireCancel) { ActionCancel = action as AgentActionCoverFireCancel; StartEnd(); return(true); } if (action is AgentActionInjury) { PlayInjuryAnimation(action as AgentActionInjury); return(true); } if (action is AgentActionAttack) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire); Animation[s].blendMode = AnimationBlendMode.Additive; Animation[s].layer = 2; if (Animation.IsPlaying(s)) { Animation[s].time = 0; } else { Blend(s, 0.05f); } action.SetSuccess(); return(true); } return(false); }
public override bool HandleNewAction(AgentAction action) { // Debug.Log ("DIE: AnimStateDeath.HandleNewAction(), agent=" + Owner.name + ", action.Type=" + action.Type + ", time=" + Time.timeSinceLevelLoad); //FAIL any action which comes during death. //This is to fix the ocassional 'stand up' after death. action.SetFailed(); return(true); /* // * if (action is AgentActionDeath) * { * action.SetFailed(); * return true; * } * * return false; */ }
override public bool HandleNewAction(AgentAction action) { if (action as AgentActionKnockdown != null) { Debug.LogError("obsolete AgentActionBlock arrived"); action.SetFailed(); return(true); } if (action as AgentActionDeath != null) { ActionDeath = action as AgentActionDeath; //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " Handle new action " + action.ToString()); InitializeDeath(); return(true); } return(false); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action; if (Action is AgentActionPlayAnim) { AnimName = (Action as AgentActionPlayAnim).AnimName; Animation[AnimName].layer = 5; } else if (Action is AgentActionPlayIdleAnim) { AnimName = Owner.AnimSet.GetIdleActionAnim(); } if (AnimName == null) { Action.SetFailed(); Action = null; Release(); return; } // play owner anims CrossFade(AnimName, 0.1f, PlayMode.StopAll); //Animation.Play(animName, AnimationPlayMode.Stop); //end of state if (Animation[AnimName].wrapMode == WrapMode.Loop) { EndOfStateTime = 100000 + Time.timeSinceLevelLoad; } else { EndOfStateTime = Animation[AnimName].length + Time.timeSinceLevelLoad - 0.3f; } // Debug.Log(Action.AnimName + " " + EndOfStateTime ); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action; string animName = null; if (Action is AgentActionPlayAnim) { animName = (Action as AgentActionPlayAnim).AnimName; LookAtTarget = false; } else if (Action is AgentActionPlayIdleAnim) { animName = Owner.AnimSet.GetIdleActionAnim(Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState); LookAtTarget = true; } if (animName == null) { Action.SetFailed(); Action = null; Release(); return; } RotationOk = true; // play owner anims AnimEngine.Play(animName, AnimationPlayMode.Stop); //end of state EndOfStateTime = (AnimEngine[animName].length * 0.9f) + Time.timeSinceLevelLoad; // Debug.Log(Action.AnimName + " " + EndOfStateTime ); }
public override bool HandleNewAction(AgentAction action) { if (action is AgentActionMove) { if (Action != null) { Action.SetSuccess(); } SetFinished(false); // just for sure, if we already finish in same tick Initialize(action); return(true); } if (action is AgentActionIdle) { action.SetSuccess(); SetFinished(true); return(true); } else if (action is AgentActionAttack) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire); Animation[s].blendMode = AnimationBlendMode.Additive; if (Animation.IsPlaying(s)) { Animation[s].time = 0; } else { Animation.Blend(s, 1, 0.1f); } action.SetSuccess(); return(true); } else if (action is AgentActionInjury) { PlayInjuryAnimation(action as AgentActionInjury); return(true); } else if (action is AgentActionReload) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload); AnimationState State = Animation[s]; if (null != State) { State.layer = 2; State.blendMode = AnimationBlendMode.Blend; // What the magic constant 0.3f is good for? Is it here to cause the weapon to be ready little bit sooner // before the animation ends? Why? TimeToFinishWeaponAction = Time.timeSinceLevelLoad + State.length - 0.3f; Blend(s, 0.25f); } else { // TODO: It use to happen (not very often) that the state is NULL. This for example happens when s // is set to "ReloadPlasma". The plasma weapon does not have any reload. The question is what causes the bug? // A cheated client? Or a latency on the network? Another question is what to do in such case? // To fail an action sounds like a correct solution. action.SetFailed(); return(true); } action.SetSuccess(); return(true); } return(false); }
public override bool HandleNewAction(AgentAction action) { //if (m_Human.PlayerProperty != null) //if(Owner.debugAnims) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - action " + action.ToString()); if (action is AgentActionIdle) { action.SetFailed(); return(true); } else if (action is AgentActionAttack) { if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Fire); if (null != s) { AnimationState state = Animation[s]; if (null != state) { TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length * 0.5f; state.layer = 2; state.blendMode = AnimationBlendMode.Additive; if (Animation.IsPlaying(s)) { //Debug.Log(Time.timeSinceLevelLoad + " " + s + " rewind " + Animation[s].length + " " + Animation[s].time); state.time = 0; } else { //Debug.Log(Time.timeSinceLevelLoad + " " + s + " fade " + Animation[s].length + " " + Animation[s].time); Blend(s, 0.05f); } } } } if (WeaponAction != null) { WeaponAction.SetSuccess(); } WeaponAction = action; return(true); } else if (action is AgentActionInjury) { PlayInjuryAnimation(action as AgentActionInjury); return(true); } else if (action is AgentActionReload) { if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Reload); if (null != s) { AnimationState state = Animation[s]; if (null != state) { state.layer = 2; state.blendMode = AnimationBlendMode.Blend; Blend(s, 0.2f); TimeToFinishWeaponAction = Time.timeSinceLevelLoad + state.length - 0.3f; } } action.SetSuccess(); WeaponAction = action; // PrevBlendUp *= 0.25f; //this is to minimize the quick blend to aim after reload // PrevBlendDown *= 0.25f; } return(true); } else if (action is AgentActionRotate) { RotateAction = action as AgentActionRotate; if (null != Owner.AnimSet) { string s = Owner.AnimSet.GetRotateAnim(RotateAction.Rotation); if (s != null && Animation.IsPlaying(s) == false) { /* if ( Animation[s] == null ) * { * Debug.Log ("Animation.Length=" + Animation.GetClipCount() + ", agent=" + Owner.name); * * foreach ( AnimationClip clip in Animation ) * Debug.Log ("clip=" + clip.name ); * } */ AnimationState state = Animation[s]; if (null != state) { state.blendMode = AnimationBlendMode.Additive; state.layer = 1; TimeToFinishRotateAction = Time.timeSinceLevelLoad + state.length + 0.3f; Blend(s, 0.1f); } } } } return(false); }