public override void Deactivate() { Action = null; base.Deactivate(); Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.None); }
protected override AgentAction MakeAgentAction() { AgentActionKnockdown agentAction = AgentActionFactory.Get(AgentActionType.KNOCKDOWN, Owner) as AgentActionKnockdown; agentAction.fromWeapon = Owner.BlackBoard.attackerWeapon; agentAction.attacker = Owner.BlackBoard.attacker; agentAction.impuls = Owner.BlackBoard.impuls; agentAction.time = Owner.BlackBoard.maxKnockdownTime * UnityEngine.Random.Range(0.7f, 1); return(agentAction); }
private void SendAction() { Action = AgentActionFactory.Create(AgentActionFactory.E_Type.E_KNOCKDOWN) as AgentActionKnockdown; Action.FromWeapon = Owner.BlackBoard.AttackerWeapon; Action.Attacker = Owner.BlackBoard.Attacker; Action.Impuls = Owner.BlackBoard.Impuls; Action.Time = Owner.BlackBoard.MaxKnockdownTime * UnityEngine.Random.Range(0.7f, 1); Owner.BlackBoard.ActionAdd(Action); Owner.WorldState.SetWSProperty(E_PropKey.E_EVENT, E_EventTypes.Knockdown); }
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 Activate() { base.Activate(); Action = null; WorldStateProp prop = Owner.WorldState.GetWSProperty(E_PropKey.E_EVENT); if (prop == null || prop.GetEvent() != E_EventTypes.Knockdown) { return; } //WorldStateTime = prop.Time; SendAction(); }
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 AgentActionKnockdown; string animName = Owner.AnimSet.GetKnockdowAnim(E_KnockdownState.Down, Owner.BlackBoard.WeaponSelected); StartRotation = Transform.rotation; StartPosition = Transform.position; Vector3 dir = Action.Attacker.Position - Transform.position; float angle = 0; if (dir.sqrMagnitude > 0.1f * 0.1f) { dir.Normalize(); angle = Vector3.Angle(Transform.forward, dir); } else { dir = Transform.forward; } FinalRotation.SetLookRotation(dir); RotationTime = angle / 500.0f; FinalPosition = StartPosition + Action.Impuls; MoveTime = AnimEngine[animName].length * 0.4f; RotationOk = RotationTime == 0; PositionOK = MoveTime == 0; CurrentRotationTime = 0; CurrentMoveTime = 0; CrossFade(animName, 0.05f); EndOfStateTime = Time.timeSinceLevelLoad + AnimEngine[animName].length * 0.9f; KnockdownEndTime = EndOfStateTime + Action.Time; State = E_State.Start; }
protected override void Initialize(AgentAction action) { base.Initialize(action); Action = action as AgentActionKnockdown; Owner.SoundPlay(Owner.KnockdownSound); string animName = Owner.AnimSet.GetKnockdownAnim(E_KnockdownState.Down); CrossFade(animName, 0.05f, PlayMode.StopSameLayer); Owner.SetDominantAnimName(animName); if (Owner.IsServer) { StartRotation = Transform.rotation; StartPosition = Transform.position; float angle = Vector3.Angle(Transform.forward, Action.Direction); FinalRotation.SetLookRotation(-Action.Direction); RotationTime = angle / 250.0f; //FinalPosition = StartPosition + Action.Attacker.Forward * 2.0f; FinalPosition = BuildFinalPosition(StartPosition, Action.Direction); MoveTime = Animation[animName].length * 0.3f; RotationOk = RotationTime == 0; PositionOK = MoveTime == 0; CurrentRotationTime = 0; CurrentMoveTime = -0.1f; } else { RotationOk = true; PositionOK = true; } EndOfStateTime = Time.timeSinceLevelLoad + Animation[animName].length * 0.9f; State = E_State.Knockdown; }
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(); }
void HandleAction(AgentAction action) { if (action is AgentActionAttack) { if (Owner.IsOwner) { Owner.NetworkView.RPC("AttackS", uLink.RPCMode.Server, (action as AgentActionAttack).FromPos, (action as AgentActionAttack).AttackDir); } } else if (action is AgentActionInjury) { var injury = action as AgentActionInjury; if (Owner.IsServer) { uLink.NetworkViewID viewId = (injury.Attacker != null && injury.Attacker.NetworkView != null) ? injury.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Injury", RPCMode.Others, viewId, injury.Pos, injury.Impulse, (short)injury.Damage, (short)injury.BodyPart); } } else if (action is AgentActionReload) { if (Owner.IsOwner) { Owner.NetworkView.RPC("Reload", uLink.RPCMode.Server); } } else if (action is AgentActionTeamCommand) { AgentActionTeamCommand a = action as AgentActionTeamCommand; if (Owner.IsOwner) { Owner.NetworkView.RPC("TeamCmd", RPCMode.Server, a.Command); } } else if (action is AgentActionRoll) { if (Owner.IsOwner) { Owner.NetworkView.RPC("Roll", uLink.RPCMode.Server, (action as AgentActionRoll).Direction); } } else if (action is AgentActionDeath) { var death = action as AgentActionDeath; if (Owner.IsServer) { uLink.NetworkViewID viewId = (death.Attacker != null && death.Attacker.NetworkView != null) ? death.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Death", RPCMode.Others, viewId, death.Pos, death.Impulse, (short)death.Damage, (short)death.BodyPart); if (null != death.Attacker) { PPIManager.Instance.ServerAddScoreForKill(Owner.NetworkView.owner, death.Attacker.NetworkView.owner, Owner.BlackBoard.AttackersDamageData, death.BodyPart, Owner.GadgetsComponent.GetBoostGoldReward()); } /*if (Server.Instance.GameInfo.GameType == E_MPGameType.ZoneControl) * { * // currently not using rebalancing after death * //PPIManager.Instance.ServerRebalanceTeams(); * }*/ } } else if (action is AgentActionCoverEnter) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverEnter", uLink.RPCMode.Server, Mission.Instance.GameZone.GetCoverIndex(Owner.BlackBoard.Cover), Owner.BlackBoard.Desires.CoverPosition); } } else if (action is AgentActionCoverLeave) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverLeave", uLink.RPCMode.Server, ((AgentActionCoverLeave)action).TypeOfLeave); } } else if (action is AgentActionCoverFire) { if (Owner.IsOwner) { AgentActionCoverFire a = action as AgentActionCoverFire; Owner.NetworkView.RPC("CoverFireStart", uLink.RPCMode.Server, a.CoverPose, a.CoverDirection); } } else if (action is AgentActionCoverFireCancel) { if (Owner.IsOwner) { Owner.NetworkView.RPC("CoverFireStop", uLink.RPCMode.Server); } } else if (action is AgentActionWeaponChange) { if (Owner.IsOwner) { Owner.NetworkView.RPC("ChangeWeapon", uLink.RPCMode.Server, (action as AgentActionWeaponChange).NewWeapon); } } else if (action is AgentActionUseItem) { // Debug.Log ("ComponentNetworkAction.HandleAction(), time=" + Time.timeSinceLevelLoad + ", BlackBoard.KeepMotion=" + Owner.BlackBoard.KeepMotion + ", Owner.IsOwner=" + Owner.IsOwner); if (Owner.IsOwner) { if (Owner.IsInCover) { Owner.NetworkView.RPC("UseItemInCover", uLink.RPCMode.Server, Owner.BlackBoard.Desires.Gadget, Owner.BlackBoard.CoverPose, Owner.BlackBoard.CoverPosition); } else { Owner.NetworkView.RPC("UseItem", uLink.RPCMode.Server, Owner.BlackBoard.Desires.Gadget, Owner.BlackBoard.KeepMotion); } } } else if (action is AgentActionMelee) { if (Owner.IsOwner) { AgentActionMelee a = action as AgentActionMelee; uLink.NetworkViewID viewId = (a.Target != null && a.Target.NetworkView != null) ? a.Target.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Melee", uLink.RPCMode.Server, a.MeleeType, viewId); } } else if (action is AgentActionKnockdown) { if (Owner.IsServer) { AgentActionKnockdown a = action as AgentActionKnockdown; uLink.NetworkViewID viewId = (a.Attacker != null && a.Attacker.NetworkView != null) ? a.Attacker.NetworkView.viewID : uLink.NetworkViewID.unassigned; Owner.NetworkView.RPC("Knockdown", uLink.RPCMode.Others, a.MeleeType, viewId, a.Direction); } } }
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); }