public override void Activate() { base.Activate(); Action = null; SendAction(); }
protected override AgentAction MakeAgentAction() { Debug.Log("make dead action"); AgentActionDeath agentAction = AgentActionFactory.Get(AgentActionType.DEATH, Owner) as AgentActionDeath; agentAction.damageType = Owner.BlackBoard.damageType; agentAction.fromWeapon = Owner.BlackBoard.attackerWeapon; agentAction.attacker = Owner.BlackBoard.attacker; agentAction.impuls = Owner.BlackBoard.impuls; return(agentAction); }
private void SendActionKill() { //if (Owner.debugGOAP) Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " Send action to kill"); ActionKill = AgentActionFactory.Create(AgentActionFactory.E_Type.E_DEATH) as AgentActionDeath; ActionKill.FromWeapon = Owner.BlackBoard.AttackerWeapon; ActionKill.Attacker = Owner.BlackBoard.Attacker; Owner.BlackBoard.ActionAdd(ActionKill); Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None); Owner.BlackBoard.DontUpdate = true; }
private void SendAction() { Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_DEATH) as AgentActionDeath; Action.DamageType = Owner.BlackBoard.DamageType; Action.FromWeapon = Owner.BlackBoard.AttackerWeapon; Action.Attacker = Owner.BlackBoard.Attacker; Action.Impuls = Owner.BlackBoard.Impuls; Owner.BlackBoard.ActionAdd(Action); Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None); Owner.BlackBoard.DontUpdate = true; }
override public void OnDeactivate() { // Time.timeScale = 1.0f; if (ActionDeath != null) { ActionDeath.SetSuccess(); } ActionDeath = null; Action.SetSuccess(); Action = null; Owner.BlackBoard.MotionType = E_MotionType.None; base.OnDeactivate(); }
public override void Reset() { if (ActionDeath != null) { ActionDeath.SetSuccess(); } Owner.BlackBoard.InKnockDown = false; Owner.BlackBoard.BusyAction = false; ActionDeath = null; Action.SetSuccess(); Action = null; base.Reset(); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionDeath; // play owner anims string animName = Owner.AnimSet.GetDeathAnim(Action.FromWeapon, Action.DamageType); CrossFade(animName, 0.1f); // Debug.Log(Action.AnimName + " " + EndOfStateTime ); Owner.BlackBoard.MotionType = E_MotionType.None; StartPosition = Transform.position; if (Action.Attacker != null) { FinalPosition = StartPosition + Action.Attacker.Forward; StartRotation = Transform.rotation; FinalRotation.SetLookRotation(-Action.Attacker.Forward); PositionOK = false; RotationOk = false; RotationProgress = 0; } else { StartPosition = Transform.position; FinalPosition = StartPosition + Action.Impuls; PositionOK = false; RotationOk = true; } CurrentMoveTime = 0; MoveTime = AnimEngine[animName].length * 0.6f; Owner.Invoke("SpawnBlood", AnimEngine[animName].length); Owner.BlackBoard.MotionType = E_MotionType.Death; Owner.DisableCollisions(); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionDeath; if (!Owner.RagdollRoot || uLink.Network.isServer) { // Debug.Log ("DIE: AnimStateDeath.InitializeAnimation(), agent=" + Owner.name + ", time=" + Time.timeSinceLevelLoad); InitializeAnimation(); } else { // Debug.Log ("DIE: AnimStateDeath.InitializeRagdoll(), agent=" + Owner.name + ", time=" + Time.timeSinceLevelLoad); InitializeRagdoll(); } }
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); }
public override void OnDeactivate() { // Time.timeScale = 1.0f; if (ActionDeath != null) { ActionDeath.SetSuccess(); } Owner.BlackBoard.InKnockDown = false; Owner.BlackBoard.BusyAction = false; ActionDeath = null; Action.SetSuccess(); Action = null; Owner.BlackBoard.MotionType = E_MotionType.None; Owner.Stop(false); base.OnDeactivate(); }
protected override void Initialize(AgentAction action) { base.Initialize(action); AgentActionDeath deathAction = Owner.BlackBoard.curAction as AgentActionDeath; string animName = Owner.AnimSet.GetDeathAnim(deathAction.fromWeapon, deathAction.damageType); CrossFade(animName, 0.1f); Owner.BlackBoard.motionType = MotionType.NONE; StartPosition = Owner.Transform.position; if (deathAction.attacker != null) { FinalPosition = StartPosition + deathAction.attacker.Forward; StartRotation = Owner.Transform.rotation; FinalRotation.SetLookRotation(-deathAction.attacker.Forward); PositionOK = false; RotationOk = false; RotationProgress = 0; } else { StartPosition = Owner.Transform.position; FinalPosition = StartPosition + deathAction.impuls; PositionOK = false; RotationOk = true; } CurrentMoveTime = 0; MoveTime = Owner.AnimEngine[animName].length * 0.6f; //Owner.Invoke("SpawnBlood", AnimEngine[animName].length); Owner.BlackBoard.motionType = MotionType.DEATH; }
override public void Update() { //if (m_Human.PlayerProperty != null) //Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - update " + State.ToString() + " " + EndOfStateTime); if (State == E_State.Death) { return; } if (RotationOk == false) { CurrentRotationTime += Time.deltaTime; if (CurrentRotationTime >= RotationTime) { CurrentRotationTime = RotationTime; RotationOk = true; } float progress = CurrentRotationTime / RotationTime; Quaternion q = Quaternion.Lerp(StartRotation, FinalRotation, progress); Owner.Transform.rotation = q; } if (PositionOK == false) { CurrentMoveTime += Time.deltaTime; if (CurrentMoveTime >= MoveTime) { CurrentMoveTime = MoveTime; PositionOK = true; } float progress = CurrentMoveTime / MoveTime; Vector3 finalPos = Mathfx.Sinerp(StartPosition, FinalPosition, progress); //MoveTo(finalPos); if (Move(finalPos - Transform.position) == false) { PositionOK = true; } } switch (State) { case E_State.Start: if (EndOfStateTime <= Time.timeSinceLevelLoad) { InitializeKnockdownLoop(); } break; case E_State.Loop: if (EndOfStateTime <= Time.timeSinceLevelLoad) { InitializeKnockdownUp(); } break; case E_State.Fatality: if (EndOfStateTime <= Time.timeSinceLevelLoad) { if (ActionDeath != null) { ActionDeath.SetSuccess(); ActionDeath = null; } InitializeDeath(); } break; case E_State.End: if (EndOfStateTime <= Time.timeSinceLevelLoad) { Release(); } break; case E_State.Death: break; } }
static public AgentAction Create(E_Type type) { int index = (int)type; AgentAction a; if (m_UnusedActions[index].Count > 0) { a = m_UnusedActions[index].Dequeue(); } else { switch (type) { case E_Type.E_IDLE: a = new AgentActionIdle(); break; case E_Type.E_MOVE: a = new AgentActionMove(); break; case E_Type.E_GOTO: a = new AgentActionGoTo(); break; case E_Type.E_COMBAT_MOVE: a = new AgentActioCombatMove(); break; case E_Type.E_ATTACK: a = new AgentActionAttack(); break; case E_Type.E_ATTACK_ROLL: a = new AgentActionAttackRoll(); break; case E_Type.E_ATTACK_WHIRL: a = new AgentActionAttackWhirl(); break; case E_Type.E_INJURY: a = new AgentActionInjury(); break; case E_Type.E_DAMAGE_BLOCKED: a = new AgentActionDamageBlocked(); break; case E_Type.E_BLOCK: a = new AgentActionBlock(); break; case E_Type.E_ROLL: a = new AgentActionRoll(); break; case E_Type.E_INCOMMING_ATTACK: a = new AgentActionIncommingAttack(); break; case E_Type.E_WEAPON_SHOW: a = new AgentActionWeaponShow(); break; case E_Type.Rotate: a = new AgentActionRotate(); break; case E_Type.E_USE_LEVER: a = new AgentActionUseLever(); break; case E_Type.E_PLAY_ANIM: a = new AgentActionPlayAnim(); break; case E_Type.E_PLAY_IDLE_ANIM: a = new AgentActionPlayIdleAnim(); break; case E_Type.E_DEATH: a = new AgentActionDeath(); break; case E_Type.E_KNOCKDOWN: a = new AgentActionKnockdown(); break; case E_Type.Teleport: a = new AgentActionTeleport(); break; default: Debug.LogError("no AgentAction to create"); return(null); } } a.Reset(); a.SetActive(); // DEBUG !!!!!! m_ActionsInAction.Add(a); return(a); }
public static AgentAction Create(E_Type type) { int index = (int)type; AgentAction a; if (m_UnusedActions[index].Count > 0) { a = m_UnusedActions[index].Dequeue(); } else { switch (type) { case E_Type.Idle: a = new AgentActionIdle(); break; case E_Type.Move: a = new AgentActionMove(); break; case E_Type.Sprint: a = new AgentActionSprint(); break; case E_Type.Goto: a = new AgentActionGoTo(); break; case E_Type.Attack: a = new AgentActionAttack(); break; case E_Type.Melee: a = new AgentActionMelee(); break; case E_Type.Injury: a = new AgentActionInjury(); break; case E_Type.Roll: a = new AgentActionRoll(); break; case E_Type.WeaponChange: a = new AgentActionWeaponChange(); break; case E_Type.Rotate: a = new AgentActionRotate(); break; case E_Type.Use: a = new AgentActionUse(); break; case E_Type.PlayAnim: a = new AgentActionPlayAnim(); break; case E_Type.PlayIdleAnim: a = new AgentActionPlayIdleAnim(); break; case E_Type.Death: a = new AgentActionDeath(); break; case E_Type.Knockdown: a = new AgentActionKnockdown(); break; case E_Type.Teleport: a = new AgentActionTeleport(); break; case E_Type.CoverEnter: a = new AgentActionCoverEnter(); break; case E_Type.CoverMove: a = new AgentActionCoverMove(); break; case E_Type.CoverFire: a = new AgentActionCoverFire(); break; case E_Type.CoverFireCancel: a = new AgentActionCoverFireCancel(); break; case E_Type.CoverLeave: a = new AgentActionCoverLeave(); break; case E_Type.Reload: a = new AgentActionReload(); break; case E_Type.UseItem: a = new AgentActionUseItem(); break; case E_Type.ConstructGadget: a = new AgentActionConstructGadget(); break; case E_Type.TeamCommand: a = new AgentActionTeamCommand(); break; default: Debug.LogError("no AgentAction to create"); return(null); } } a.Reset(); a.SetActive(); // DEBUG !!!!!! // m_ActionsInAction.Add(a); return(a); }
public override void Deactivate() { Action = null; base.Deactivate(); }