IEnumerator SwitchWeapon(AgentActionWeaponChange action) { //change FOV if desired if (uLink.Network.isClient && Owner.NetworkView.isMine /* && !Owner.IsInCover/**/) { float newFOV = GameCamera.Instance.DefaultFOV; if (Owner.IsInCover) { newFOV *= Owner.WeaponComponent.GetWeapon(action.NewWeapon).CoverFovModificator; } GameCamera.Instance.SetFov(newFOV, 60); } // string s = Owner.AnimSet.GetWeaponAnim(E_WeaponAction.Switch); Animation[s].layer = 3; Animation[s].blendMode = AnimationBlendMode.Blend; Animation.CrossFade(s, 0.15f, PlayMode.StopSameLayer); Owner.WeaponComponent.GetCurrentWeapon().SetBusy(Animation[s].length - 0.1f); //- 0.1f for better feeling (player feels that he should be able to shoot sooner than the animation ends, so this gives him some reaction time) action.SetSuccess(); yield return(new WaitForSeconds(Animation[s].length * 0.36f)); Owner.WeaponComponent.SwitchWeapons(action.NewWeapon); }
protected void WeaponAutoSwitch() { //FIXME tady se ( proted ) musim oprit o GUI - jinak nevim poradi zbrani List <E_WeaponID> weapons = new List <E_WeaponID>(); int weaponsCount = GuiHUD.Instance.GetInventoryWeaponsCount(); int startIndex = -1; for (int i = 0; i < weaponsCount; i++) { E_WeaponID W = GuiHUD.Instance.GetWeaponInInventoryIndex(i); if (E_WeaponID.None == W) { continue; } if (W == CurrentWeapon) { startIndex = weapons.Count; } WeaponBase wBase = GetWeapon(W); if (null != wBase && wBase.HasAnyAmmo) { weapons.Add(W); if (startIndex > 0) { break; } } } if (startIndex >= 0 && weapons.Count > 0) { if (startIndex == weapons.Count) { startIndex = 0; } // take it Owner.BlackBoard.Desires.Weapon = weapons[startIndex]; //workaround to avoid sliding during weapon change (when this goes through GOAP, the GOAPMove action is terminated and it goes through Idle to the GOAPMove again) // Owner.WorldState.SetWSProperty( E_PropKey.WeaponChange, true ); AgentActionWeaponChange Action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange; Action.NewWeapon = Owner.BlackBoard.Desires.Weapon; Owner.BlackBoard.ActionAdd(Action); } }
void ActionChangeWeapon(E_WeaponID weaponType) { if (CanChangeWeapon() == false) { return; } Owner.BlackBoard.Desires.Weapon = weaponType; //workaround to avoid sliding during weapon change (when this goes through GOAP, the GOAPMove action is terminated and it goes through Idle to the GOAPMove again) //Owner.WorldState.SetWSProperty(E_PropKey.WeaponChange, true); AgentActionWeaponChange Action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange; Action.NewWeapon = Owner.BlackBoard.Desires.Weapon; Owner.BlackBoard.ActionAdd(Action); }
void ChangeWeaponC(E_WeaponID weapon, uLink.NetworkMessageInfo info) { #if !DEADZONE_CLIENT if (Owner.IsServer) { ServerAnticheat.ReportPotentialCheatAttempt("ChangeWeaponC", "should never be called on the server side", Owner.NetworkView.owner); return; } #endif if (Owner.BlackBoard.DontUpdate) { return; } AgentActionWeaponChange action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange; action.NewWeapon = weapon; Owner.BlackBoard.ActionAdd(action); }
void ChangeWeapon(E_WeaponID weapon, uLink.NetworkMessageInfo info) { if (Owner.BlackBoard.DontUpdate) { return; } #if !DEADZONE_CLIENT if (Owner.IsServer) { ServerAnticheat.ReportChangeWeapon(Owner.NetworkView.owner, weapon, info); } #endif AgentActionWeaponChange action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange; action.NewWeapon = weapon; Owner.BlackBoard.ActionAdd(action); Owner.NetworkView.RPC("ChangeWeaponC", uLink.RPCMode.OthersExceptOwner, weapon); }
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); }