override public bool HandleNewAction(ActionBase action) { if (action as ActionBlock != null) { Debug.LogError("obsolete AgentActionBlock arrived"); action.SetFailed(); return(true); } if (action as ActionDamageBlocked != null) { ActionDamageBlocked = action as ActionDamageBlocked; //if (Owner.debugAnims == true) Debug.Log(Time.timeSinceLevelLoad + " Handle new action " + action.ToString()); if (ActionDamageBlocked.BreakBlock == true) { InitializeBlockFailed(); } else { InitializeBlockSuccess(); } return(true); } return(false); }
override public void OnDeactivate() { // Time.timeScale = 1.0f; if (ActionDamageBlocked != null) { ActionDamageBlocked.SetSuccess(); } ActionDamageBlocked = null; ActionBlock.SetSuccess(); ActionBlock = null; Owner.BlackBoard.MotionType = E_MotionType.None; base.OnDeactivate(); }
// 生成动作 static public ActionBase Create(E_Type type) { int index = (int)type; ActionBase a; if (m_UnusedActions[index].Count > 0) { a = m_UnusedActions[index].Dequeue(); } else { switch (type) { case E_Type.E_IDLE: a = new ActionIdle(); break; case E_Type.E_MOVE: a = new ActionMove(); break; case E_Type.E_GOTO: a = new ActionGoTo(); break; case E_Type.E_COMBAT_MOVE: a = new ActionCombatMove(); break; case E_Type.E_ATTACK: a = new ActionAttack(); break; case E_Type.E_ATTACK_ROLL: a = new ActionAttackRoll(); break; case E_Type.E_ATTACK_WHIRL: a = new ActionAttackWhirl(); break; case E_Type.E_INJURY: a = new ActionInjury(); break; case E_Type.E_DAMAGE_BLOCKED: a = new ActionDamageBlocked(); break; case E_Type.E_BLOCK: a = new ActionBlock(); break; case E_Type.E_ROLL: a = new ActionRoll(); break; case E_Type.E_INCOMMING_ATTACK: a = new ActionIncommingAttack(); break; case E_Type.E_WEAPON_SHOW: a = new ActionWeaponShow(); break; case E_Type.E_Rotate: a = new ActionRotate(); break; case E_Type.E_USE_LEVER: a = new ActionUseLever(); break; case E_Type.E_PLAY_ANIM: a = new ActionPlayAnim(); break; case E_Type.E_PLAY_IDLE_ANIM: a = new ActionPlayIdleAnim(); break; case E_Type.E_DEATH: a = new ActionDeath(); break; case E_Type.E_KNOCKDOWN: a = new ActionKnockdown(); break; case E_Type.E_Teleport: a = new ActionTeleport(); break; default: Debug.LogError("no Action to create"); return(null); } } a.Reset(); a.SetActive(); m_ActionsInAction.Add(a); return(a); }
override public void Update() { //if (m_Human.PlayerProperty != null) //Debug.Log(Time.timeSinceLevelLoad + " " + this.ToString() + " - update " + State.ToString() + " " + EndOfStateTime); UpdateFinalRotation(); 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.E_START: if (EndOfStateTime <= Time.timeSinceLevelLoad) { InitializeBlockLoop(); } break; case E_State.E_BLOCK: if (EndOfStateTime <= Time.timeSinceLevelLoad) { InitializeBlockEnd(); } Move(MoveDir.normalized / 2); break; case E_State.E_BLOCK_HIT: if (EndOfStateTime <= Time.timeSinceLevelLoad) { if (Time.timeSinceLevelLoad < BlockEndTime) { InitializeBlockLoop(); } else { InitializeBlockEnd(); } if (ActionDamageBlocked != null) { ActionDamageBlocked.SetSuccess(); ActionDamageBlocked = null; } } break; case E_State.E_END: if (EndOfStateTime <= Time.timeSinceLevelLoad) { Release(); } break; } }