protected void CoverLeave(AgentActionCoverLeave.E_Type typeOfLeave, uLink.NetworkMessageInfo info) { //TODO: How is this? I believe we definitelly cannot afford to ignore the CoverLeave event on both on proxies and I think we //should not ignore it on server too. No doubt about proxies - they should just do what they are told to do. //About the server - how can we ignore it without fixing a client? If we ignore it, the player stayes in a cover forever //which might cause both: visual artefacts and even detecting player as a cheater. //I don't think that a potential cheater can gain much of benefit by leaving the cover prematurely. //if (Owner.BlackBoard.DontUpdate) // return; if (Owner.IsInCover) { #if !DEADZONE_CLIENT if (Owner.IsServer) { ServerAnticheat.ReportCoverLeave(Owner.NetworkView.owner, typeOfLeave, info); Owner.NetworkView.RPC("CoverLeave", uLink.RPCMode.OthersExceptOwner, typeOfLeave); } #endif AgentActionCoverLeave action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverLeave) as AgentActionCoverLeave; action.TypeOfLeave = typeOfLeave; action.FinalViewDirection = Owner.BlackBoard.Cover.Forward; action.Cover = Owner.BlackBoard.Cover; Owner.BlackBoard.ActionAdd(action); } }
protected virtual void Activate() { AgentActionRoll = null; CoverLeaveAction = null; RestoreWalkingCharacterCapsule(); }
public override void Reset() { Action.SetSuccess(); Action = null; base.Reset(); }
protected virtual void Deactivate() { //Debug.Log(name + " Deactivate ", this); InUseMode = false; AgentActionRoll = null; CoverLeaveAction = null; }
public override void Activate() { base.Activate(); Action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverLeave) as AgentActionCoverLeave; Action.FinalViewDirection = Owner.BlackBoard.Cover.Forward; Action.Cover = Owner.BlackBoard.Cover; Owner.BlackBoard.ActionAdd(Action); }
public override void OnDeactivate() { // Time.timeScale = 1; Owner.BlackBoard.ReactOnHits = true; Owner.BlackBoard.BusyAction = false; Owner.CoverStop(); 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; } }
public override void Activate() { base.Activate(); Action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverLeave) as AgentActionCoverLeave; Action.FinalViewDirection = Owner.BlackBoard.Cover.Forward; if (Owner.BlackBoard.CoverPosition == E_CoverDirection.Left) { Action.TypeOfLeave = AgentActionCoverLeave.E_Type.Left; } else { Action.TypeOfLeave = AgentActionCoverLeave.E_Type.Right; } Action.Cover = Owner.BlackBoard.Cover; Owner.BlackBoard.ActionAdd(Action); }
public override void Activate() { base.Activate(); Action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverLeave) as AgentActionCoverLeave; if (Owner.BlackBoard.Cover.CanJumpUp) { Action.TypeOfLeave = AgentActionCoverLeave.E_Type.JumpUp; } else { Action.TypeOfLeave = AgentActionCoverLeave.E_Type.Jump; } Action.FinalViewDirection = Owner.BlackBoard.Cover.Forward; Action.Cover = Owner.BlackBoard.Cover; // Debug.Log(Action.TypeOfLeave); Owner.BlackBoard.ActionAdd(Action); }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionCoverLeave; StartPosition = Transform.position; string AnimName; //Debug.Log(Time.realtimeSinceStartup + " init"); RotationOK = true; switch (Action.TypeOfLeave) { case AgentActionCoverLeave.E_Type.Right: case AgentActionCoverLeave.E_Type.Left: float multiplierHelper = 1; if (Action.TypeOfLeave == AgentActionCoverLeave.E_Type.Right) { AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.LeaveRight, Owner.BlackBoard.CoverPose, E_CoverDirection.Right); } else { multiplierHelper = -1; AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.LeaveLeft, Owner.BlackBoard.CoverPose, E_CoverDirection.Left); } //FinalPosition = Owner.Position + Owner.Right * 1.5f * multiplierHelper + Owner.Forward * 1.3f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position + Owner.Right * 1.5f * multiplierHelper + Owner.Forward * 1.1f ); FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); StartPositionHelper = StartPosition - Owner.Right * multiplierHelper; FinalPositionHelper = FinalPosition + Owner.Forward; CurrentMoveTime = 0f; Animation[AnimName].speed = 1f; MoveTime = 0.3f; EndOfStateTime = 0.3f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.Jump: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.JumpOver, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position + Owner.Forward * 2.0f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position + Owner.Forward * 2.0f ); // prevents to fall through the scene in case we are jumping 'uphill' FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); CurrentMoveTime = -0.2f; Animation[AnimName].speed = 1.3f; MoveTime = 0.4f; EndOfStateTime = 0.9f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.JumpUp: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.JumpUp, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position + Vector3.up * 1.4f + Owner.Forward * 0.65f; FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, Owner.Forward); CurrentMoveTime = 0.0f; Animation[AnimName].speed = 1.4f; MoveTime = Animation[AnimName].length * 0.8f / Animation[AnimName].speed; EndOfStateTime = Animation[AnimName].length / Animation[AnimName].speed * 0.8f + Time.timeSinceLevelLoad; Owner.BlackBoard.Speed = 5; break; case AgentActionCoverLeave.E_Type.Back: AnimName = Owner.AnimSet.GetCoverAnim(AnimSet.E_CoverAnim.Leave, Owner.BlackBoard.CoverPose, E_CoverDirection.Middle); //FinalPosition = Owner.Position - Owner.BlackBoard.Cover.Forward * 1.1f; //FinalPosition = BuildSafeFinalPositionForLeavingCover( Owner.Position - Owner.BlackBoard.Cover.Forward * 1.1f ); FinalPosition = BuildSafeFinalPositionForLeavingCover(Action.TypeOfLeave, Owner.Position, Owner.Right, -Owner.BlackBoard.Cover.Forward); StartRotation = Owner.Transform.rotation; FinalRotation.eulerAngles = new Vector3(0, Owner.BlackBoard.Desires.Rotation.eulerAngles.y, 0); Animation[AnimName].speed = 1.2f; MoveTime = 0.1f; CurrentMoveTime = -0.1f; EndOfStateTime = 0.15f + Time.timeSinceLevelLoad; // RotationOK = false; //ComponentBody will take care about the rotation... When this is enabled it causes a rotation glitch. break; default: AnimName = ""; Debug.LogWarning("Unsupported type of cover leaving : Action.TypeOfLeave"); break; } // Debug.Log ("AnimStateCoverLeave, AnimName=" + AnimName + ", time=" + Time.timeSinceLevelLoad); CrossFade(AnimName, 0.15f, PlayMode.StopSameLayer); Owner.SetDominantAnimName(AnimName); Owner.WeaponComponent.DisableCurrentWeapon(Animation[AnimName].length); PositionOK = false; Owner.BlackBoard.MotionType = E_MotionType.None; //change FOV to the weapon/default value if (uLink.Network.isClient && Owner.NetworkView.isMine) { float newFOV = GameCamera.Instance.DefaultFOV; GameCamera.Instance.SetFov(newFOV, 200); } }
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); } } }
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); }