protected virtual void Activate() { AgentActionRoll = null; CoverLeaveAction = null; RestoreWalkingCharacterCapsule(); }
public override void Deactivate() { Action = null; Owner.WorldState.SetWSProperty(E_PropKey.E_IN_DODGE, false); base.Deactivate(); }
override public void OnDeactivate() { // Time.timeScale = 1; Action.SetSuccess(); Action = null; base.OnDeactivate(); }
protected virtual void Deactivate() { //Debug.Log(name + " Deactivate ", this); InUseMode = false; AgentActionRoll = null; CoverLeaveAction = null; }
public override void Reset() { Owner.BlackBoard.MotionType = E_MotionType.None; Owner.BlackBoard.BusyAction = false; Owner.BlackBoard.ReactOnHits = true; Action.SetSuccess(); Action = null; base.Reset(); }
private void ActionRollTo() { Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_ROLL) as AgentActionRoll; Action.Direction = Owner.BlackBoard.DesiredTarget.Position - Owner.Position; // if (Action.Direction.sqrMagnitude < (Owner.BlackBoard.RollDistance + 2) * (Owner.BlackBoard.RollDistance + 2)) Action.ToTarget = Owner.BlackBoard.DesiredTarget; Action.Direction.Normalize(); Owner.BlackBoard.AddAction(Action); }
public override void OnDeactivate() { // Time.timeScale = 1; Owner.BlackBoard.BusyAction = false; Owner.BlackBoard.ReactOnHits = true; Owner.BlackBoard.MotionType = E_MotionType.None; Action.SetSuccess(); Action = null; base.OnDeactivate(); }
protected virtual void Update() { if (AgentActionRoll != null && AgentActionRoll.IsActive() == false) { RestoreWalkingCharacterCapsule(); AgentActionRoll = null; } if (CoverLeaveAction != null && CoverLeaveAction.IsActive() == false) { CoverLeaveAction = null; } }
protected void Roll(E_Direction direction, uLink.NetworkMessageInfo info) { #if !DEADZONE_CLIENT if (Owner.IsServer) { ServerAnticheat.ReportRoll(Owner.NetworkView.owner, direction, info); Owner.NetworkView.RPC("Roll", uLink.RPCMode.OthersExceptOwner, direction); } #endif AgentActionRoll a = AgentActionFactory.Create(AgentActionFactory.E_Type.Roll) as AgentActionRoll; a.Direction = direction; Owner.BlackBoard.ActionAdd(a); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionRoll; CurrentMoveTime = 0; CurrentRotationTime = 0; StartRotation = Transform.rotation; StartPosition = Transform.position; Vector3 finalDir; if (Action.ToTarget != null) { finalDir = Action.ToTarget.Position - Transform.position; finalDir.Normalize(); FinalPosition = Action.ToTarget.Position - finalDir * Owner.BlackBoard.WeaponRange; } else { finalDir = Action.Direction; FinalPosition = StartPosition + Action.Direction * Owner.BlackBoard.RollDistance; } string AnimName = Owner.AnimSet.GetRollAnim(Owner.BlackBoard.WeaponSelected, Owner.BlackBoard.WeaponState); CrossFade(AnimName, 0.1f); FinalRotation.SetLookRotation(finalDir); RotationTime = Vector3.Angle(Transform.forward, finalDir) / 1000.0f; MoveTime = AnimEngine[AnimName].length * 0.85f; EndOfStateTime = AnimEngine[AnimName].length * 0.9f + Time.timeSinceLevelLoad; RotationOk = RotationTime == 0; PositionOK = false; Owner.BlackBoard.MotionType = E_MotionType.Roll; if (Effect) { CombatEffectsManager.Instance.StartCoroutine(CombatEffectsManager.Instance.PlayAndStop(Effect, 0.1f)); } }
private void ActionRollTo() { Action = null; Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_ROLL) as AgentActionRoll; Action.Direction = Owner.BlackBoard.DesiredDirection; Owner.BlackBoard.ActionAdd(Action); Owner.SoundPlayRoll(); if (Owner.WorldState.GetWSProperty(E_PropKey.E_ORDER).GetOrder() == AgentOrder.E_OrderType.E_DODGE) { Owner.WorldState.SetWSProperty(E_PropKey.E_ORDER, AgentOrder.E_OrderType.E_NONE); } //UnityEngine.Debug.Log(this.ToString() + "Send new roll action to pos " + Action.Direction.ToString()); }
public override void Activate() { base.Activate(); Owner.BlackBoard.Desires.MeleeTriggerOn = false; Owner.BlackBoard.Desires.WeaponTriggerOn = false; Owner.BlackBoard.Desires.WeaponTriggerUp = false; Owner.BlackBoard.Desires.WeaponTriggerUpDisabled = true; Owner.WorldState.SetWSProperty(E_PropKey.InDodge, false); Action = AgentActionFactory.Create(AgentActionFactory.E_Type.Roll) as AgentActionRoll; Action.Direction = Owner.BlackBoard.Desires.RollDirection; Owner.BlackBoard.ActionAdd(Action); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionRoll; StartPosition = Transform.position; switch (Action.Direction) { case E_Direction.Forward: FinalPosition = StartPosition + Owner.Forward * Owner.BlackBoard.BaseSetup.RollDistance; break; case E_Direction.Right: FinalPosition = StartPosition + Owner.Right * Owner.BlackBoard.BaseSetup.RollDistance; break; case E_Direction.Left: FinalPosition = StartPosition - Owner.Right * Owner.BlackBoard.BaseSetup.RollDistance; break; case E_Direction.Backward: FinalPosition = StartPosition - Owner.Forward * Owner.BlackBoard.BaseSetup.RollDistance; break; } //Debug.Log("ROL DIR " + Action.Direction); string AnimName = Owner.AnimSet.GetRollAnim(Action.Direction); CrossFade(AnimName, 0.1f, PlayMode.StopSameLayer); Owner.SetDominantAnimName(AnimName); CurrentMoveTime = 0; MoveTime = Animation[AnimName].length * 0.95f; EndOfStateTime = Animation[AnimName].length * 0.85f + Time.timeSinceLevelLoad; if (Owner.IsOwner) { PositionOK = false; } else { PositionOK = true; } }
protected override void Initialize(AgentAction action) { Debug.Log("roll"); base.Initialize(action); AgentActionRoll rollAction = Owner.BlackBoard.curAction as AgentActionRoll; _currentMoveTime = 0; _currentRotationTime = 0; _startRotation = Owner.Transform.rotation; _startPosition = Owner.Transform.position; Vector3 finalDir; if (rollAction.toTarget != null) { finalDir = rollAction.toTarget.Position - Owner.Transform.position; finalDir.Normalize(); _finalPosition = rollAction.toTarget.Position - finalDir * Owner.BlackBoard.weaponRange; } else { finalDir = rollAction.direction; _finalPosition = _startPosition + rollAction.direction * Owner.BlackBoard.rollDistance; } string animName = Owner.AnimSet.GetRollAnim(Owner.BlackBoard.weaponSelected, Owner.BlackBoard.weaponState); CrossFade(animName, 0.1f); _finalRotation.SetLookRotation(finalDir); _rotationTime = Vector3.Angle(Owner.Transform.forward, finalDir) / 1000.0f; _moveTime = Owner.AnimEngine[animName].length * 0.85f; _endOfStateTime = Owner.AnimEngine[animName].length * 0.9f + Time.timeSinceLevelLoad; _rotationOk = _rotationTime == 0; _positionOK = false; Owner.BlackBoard.motionType = MotionType.ROLL; }
public AgentAction GetInputAction() { Vector3 moveDir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); // phenix 添加 if (moveDir != Vector3.zero) { AgentActionMove moveAction = AgentActionFactory.Get(AgentActionType.MOVE, _owner) as AgentActionMove; moveAction.moveDir = moveDir; AddOrder(moveAction); } if (Input.GetKeyUp(KeyCode.Space)) { AgentActionRoll rollAction = AgentActionFactory.Get(AgentActionType.ROLL, _owner) as AgentActionRoll; rollAction.direction = transform.forward; rollAction.toTarget = null; AddOrder(rollAction); } if (Input.GetKeyUp(KeyCode.J)) { AgentActionAttackMelee attackMeleeAction = AgentActionFactory.Get(AgentActionType.ATTACK_MELEE, _owner) as AgentActionAttackMelee; attackMeleeAction.attackType = OrderAttackType.X; AddOrder(attackMeleeAction); } if (Input.GetKeyUp(KeyCode.K)) { AgentActionAttackMelee attackMeleeAction = AgentActionFactory.Get(AgentActionType.ATTACK_MELEE, _owner) as AgentActionAttackMelee; attackMeleeAction.attackType = OrderAttackType.O; AddOrder(attackMeleeAction); } if (_inputOrders.Count > 0) { return(_inputOrders.Dequeue()); } return(null); }
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 void HandleAction(AgentAction a) { if (a is AgentActionRoll) { // disabled - we will use full-sized capsule for collision testing during roll // SetHeightOfCharacterCapsule( HeightRoll ); AgentActionRoll = a as AgentActionRoll; if (SoundRoll) { Owner.SoundPlay(SoundRoll); } } else if (a is AgentActionCoverEnter) { if ((a as AgentActionCoverEnter).Cover.IsStandAllowed) { SetHeightOfCharacterCapsule(HeightStand); } else { SetHeightOfCharacterCapsule(HeightCover); } //Owner.BlackBoard.Desires.Rotation = (a as AgentActionCoverEnter).Cover.Transform.rotation; } else if (a is AgentActionCoverLeave) { RestoreWalkingCharacterCapsule(); //Owner.BlackBoard.Desires.Rotation.SetLookRotation((a as AgentActionCoverLeave).FinalViewDirection); CoverLeaveAction = (AgentActionCoverLeave)a; } else if (a is AgentActionCoverFire) { if (Owner.BlackBoard.CoverPosition == E_CoverDirection.Middle) { SetHeightOfCharacterCapsule(HeightStand); } else if (Owner.BlackBoard.CoverPosition == E_CoverDirection.Left) { Owner.CharacterController.center = new Vector3(-0.5f, Owner.CharacterController.height * 0.5f, 0); } else { Owner.CharacterController.center = new Vector3(+0.5f, Owner.CharacterController.height * 0.5f, 0); } } else if (a is AgentActionCoverFireCancel) { if (Owner.BlackBoard.CoverPose == E_CoverPose.Crouch) { SetHeightOfCharacterCapsule(HeightCover); } else { SetHeightOfCharacterCapsule(HeightStand); } } }
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); }