static int set_Owner(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); BehaviorDesigner.Runtime.Tasks.Task obj = (BehaviorDesigner.Runtime.Tasks.Task)o; BehaviorDesigner.Runtime.Behavior arg0 = (BehaviorDesigner.Runtime.Behavior)ToLua.CheckObject <BehaviorDesigner.Runtime.Behavior>(L, 2); obj.Owner = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Owner on a nil value")); } }
static int get_Owner(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); BehaviorDesigner.Runtime.Tasks.Task obj = (BehaviorDesigner.Runtime.Tasks.Task)o; BehaviorDesigner.Runtime.Behavior ret = obj.Owner; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Owner on a nil value")); } }
public void MakeDead(bool bOffLine = false) { Debug.LogWarning("MakeDead:" + gameObject.name + " is dead!"); if (GameManager.s_gameSingleMultiType == GameSingleMultiType.MultiGame_WangHu) //联机模式判断状态 { byte Gamestate = SocketDefines.GAME_STATUS_FREE; if (CServerItem.get() != null) { Gamestate = CServerItem.get().GetGameStatus(); } if (Gamestate != SocketDefines.GAME_STATUS_PLAY) { Debug.LogError("MakeDead when Gamestate=" + Gamestate); return; } } Hp = 0; if (IsLocalHuman()) { //切换死亡视角 ControlManager.GetInstance().ControlModelSwitch(ControlManager.CameraControlMode.DeadMode); if (TeamType == PlayerTeam.PlayerTeamType.HideTeam) { UIManager.GetInstance().ShowTopTips("你已经被发现了!", true); } else if (TeamType == PlayerTeam.PlayerTeamType.TaggerTeam) { UIManager.GetInstance().ShowTopTips("你已经死亡!", true); } if (TeamType == PlayerTeam.PlayerTeamType.TaggerTeam) { //byte ModelIndex = (byte)PlayerPrefs.GetInt("ChoosedModelIndex"); //GameObject temp = Resources.Load<GameObject>(HNGameManager.taggerPrefabPath[ModelIndex]); //GameObject localHuman = Instantiate(temp); //localHuman.transform.position = gameObject.transform.position; //localHuman.transform.localEulerAngles = gameObject.transform.localEulerAngles; //炸弹处理 if (ControlManager.GetInstance().BoomButton != null) { ControlManager.GetInstance().BoomButton.gameObject.SetActive(false); } InventoryManager.HaveBoom = false; if (!IsAI) //死亡提示音 { m_hnGameManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_SEEK_DEAD); } if (IsAI) { _avatarAnimator = gameObject.transform.GetComponent <Animator>(); } else { _avatarAnimator = gameObject.transform.GetChild(0).transform.GetComponent <Animator>(); } if (_avatarAnimator != null) { EnableModelDisplay(); _avatarAnimator.SetBool("Death_b", true); } if (UIManager.GetInstance() != null) //警察死亡隐藏人称切换 { UIManager.GetInstance().m_Canvas.transform.Find("Btn/PersonButton").gameObject.SetActive(false); } //GameObject.Destroy(gameObject, 3.0f); } else { if (!IsAI) //死亡提示音 { m_hnGameManager.PlaySoundEffect(-1, (int)AudioManager.Sound_Effect_Defines.SOUND_SEEK_DEAD); if (UIManager.TimeLeft > GameManager.HIDESEEK_GAME_PLAY_TIME - 60 && !bOffLine) //复活道具使用 bOffLine仅供断线重连时判断 { Loom.QueueOnMainThread(() => { ControlManager.GetInstance().ResurrectionButton.gameObject.SetActive(true); Loom.QueueOnMainThread(() => { ControlManager.GetInstance().ResurrectionButton.gameObject.SetActive(false); }, 10); }); } if (UIManager.GetInstance() != null) { UIManager.GetInstance().m_Canvas.transform.Find("Btn/ObjectSwitch").gameObject.SetActive(false); //模型切换 UIManager.GetInstance().m_Canvas.transform.Find("Btn/StealthButton").gameObject.SetActive(false); } } //GameObject.Destroy(gameObject); } } else { if (TeamType == PlayerTeam.PlayerTeamType.TaggerTeam) { if (_avatarAnimator != null) { _avatarAnimator.SetBool("Death_b", true); } //GameObject.Destroy(gameObject, 3.0f); } else { //GameObject.Destroy(gameObject); } } //GameObject.Destroy(gameObject)改为隐藏,保证SendClientPlayersInfo_WangHu还能发送他的信息 float fDelayTime = 0f; if (TeamType == PlayerTeam.PlayerTeamType.TaggerTeam) { fDelayTime = 3.0f; } Loom.QueueOnMainThread(() => { if (this == null) { return; } if (gameObject.GetComponent <CharacterController>() != null) { Destroy(gameObject.GetComponent <CharacterController>()); } GameObject InfoPanel = gameObject.transform.Find("InfoPanel").gameObject; if (InfoPanel != null) { InfoPanel.SetActive(false); } GameObject ModelObj = gameObject.transform.GetChild(0).gameObject; if (ModelObj.transform.childCount == 0) { if (ModelObj.transform.GetComponent <Renderer>() != null) { ModelObj.transform.GetComponent <Renderer>().enabled = false; } } else if (ModelObj.transform.childCount > 0) { for (int j = 0; j < ModelObj.transform.childCount; j++) { if (ModelObj.transform.GetChild(j).GetComponent <Renderer>() != null) { ModelObj.transform.GetChild(j).GetComponent <Renderer>().enabled = false; } } } //MeshCollider mCollider = gameObject.GetComponent<MeshCollider>(); //if (mCollider != null) // mCollider.enabled = false; //mCollider = ModelObj.GetComponent<MeshCollider>(); //if (mCollider != null) // mCollider.enabled = false; //BoxCollider bCollider = gameObject.GetComponent<BoxCollider>(); //if (bCollider != null) // bCollider.enabled = false; //bCollider = ModelObj.GetComponent<BoxCollider>(); //if (bCollider != null) // bCollider.enabled = false; Collider collider = gameObject.GetComponent <Collider>(); if (collider != null) { collider.enabled = false; } collider = null; collider = ModelObj.GetComponent <Collider>(); if (collider != null) { collider.enabled = false; } if (_controller != null) { _controller.enabled = false; } }, fDelayTime); //Stop obj behavior tree if (IsAI) { BehaviorDesigner.Runtime.Behavior behavior = gameObject.GetComponent <BehaviorDesigner.Runtime.Behavior>(); if (behavior != null) { behavior.DisableBehavior(); } } // for dead sync }
public SynchronizedVariable(VariableSynchronizer.SynchronizationType synchronizationType, bool setVariable, Behavior behavior, string variableName, bool global, Component targetComponent, string targetName, bool targetGlobal) { this.synchronizationType = synchronizationType; this.setVariable = setVariable; this.behavior = behavior; this.variableName = variableName; this.global = global; this.targetComponent = targetComponent; this.targetName = targetName; this.targetGlobal = targetGlobal; }
public void Awake() { for (int i = this.synchronizedVariables.Count - 1; i > -1; i--) { VariableSynchronizer.SynchronizedVariable synchronizedVariable = this.synchronizedVariables[i]; if (synchronizedVariable.global) { synchronizedVariable.sharedVariable = GlobalVariables.Instance.GetVariable(synchronizedVariable.variableName); } else { synchronizedVariable.sharedVariable = synchronizedVariable.behavior.GetVariable(synchronizedVariable.variableName); } string text = string.Empty; if (synchronizedVariable.sharedVariable == null) { text = "the SharedVariable can't be found"; } else { switch (synchronizedVariable.synchronizationType) { case VariableSynchronizer.SynchronizationType.BehaviorDesigner: { Behavior behavior = synchronizedVariable.targetComponent as Behavior; if (behavior == null) { text = "the target component is not of type Behavior Tree"; } else { if (synchronizedVariable.targetGlobal) { synchronizedVariable.targetSharedVariable = GlobalVariables.Instance.GetVariable(synchronizedVariable.targetName); } else { synchronizedVariable.targetSharedVariable = behavior.GetVariable(synchronizedVariable.targetName); } if (synchronizedVariable.targetSharedVariable == null) { text = "the target SharedVariable cannot be found"; } } break; } case VariableSynchronizer.SynchronizationType.Property: { PropertyInfo property = synchronizedVariable.targetComponent.GetType().GetProperty(synchronizedVariable.targetName); if (property == null) { text = "the property " + synchronizedVariable.targetName + " doesn't exist"; } else { if (synchronizedVariable.setVariable) { MethodInfo getMethod = property.GetGetMethod(); if (getMethod == null) { text = "the property has no get method"; } else { synchronizedVariable.getDelegate = VariableSynchronizer.CreateGetDelegate(synchronizedVariable.targetComponent, getMethod); } } else { MethodInfo setMethod = property.GetSetMethod(); if (setMethod == null) { text = "the property has no set method"; } else { synchronizedVariable.setDelegate = VariableSynchronizer.CreateSetDelegate(synchronizedVariable.targetComponent, setMethod); } } } break; } case VariableSynchronizer.SynchronizationType.Animator: synchronizedVariable.animator = (synchronizedVariable.targetComponent as Animator); if (synchronizedVariable.animator == null) { text = "the component is not of type Animator"; } else { synchronizedVariable.targetID = Animator.StringToHash(synchronizedVariable.targetName); Type propertyType = synchronizedVariable.sharedVariable.GetType().GetProperty("Value").PropertyType; if (propertyType.Equals(typeof(bool))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Bool; } else { if (propertyType.Equals(typeof(float))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Float; } else { if (propertyType.Equals(typeof(int))) { synchronizedVariable.animatorParameterType = VariableSynchronizer.AnimatorParameterType.Integer; } else { text = "there is no animator parameter type that can synchronize with " + propertyType; } } } } break; case VariableSynchronizer.SynchronizationType.PlayMaker: { Type typeWithinAssembly = TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.VariableSynchronizer_PlayMaker"); if (typeWithinAssembly != null) { MethodInfo method = typeWithinAssembly.GetMethod("Start"); if (method != null) { int num = (int)method.Invoke(null, new object[] { synchronizedVariable }); if (num == 1) { text = "the PlayMaker NamedVariable cannot be found"; } else { if (num == 2) { text = "the Behavior Designer SharedVariable is not the same type as the PlayMaker NamedVariable"; } else { MethodInfo method2 = typeWithinAssembly.GetMethod("Tick"); if (method2 != null) { synchronizedVariable.thirdPartyTick = (Action <VariableSynchronizer.SynchronizedVariable>)Delegate.CreateDelegate(typeof(Action <VariableSynchronizer.SynchronizedVariable>), method2); } } } } } else { text = "has the PlayMaker classes been imported?"; } break; } case VariableSynchronizer.SynchronizationType.uFrame: { Type typeWithinAssembly2 = TaskUtility.GetTypeWithinAssembly("BehaviorDesigner.Runtime.VariableSynchronizer_uFrame"); if (typeWithinAssembly2 != null) { MethodInfo method3 = typeWithinAssembly2.GetMethod("Start"); if (method3 != null) { int num2 = (int)method3.Invoke(null, new object[] { synchronizedVariable }); if (num2 == 1) { text = "the uFrame property cannot be found"; } else { if (num2 == 2) { text = "the Behavior Designer SharedVariable is not the same type as the uFrame property"; } else { MethodInfo method4 = typeWithinAssembly2.GetMethod("Tick"); if (method4 != null) { synchronizedVariable.thirdPartyTick = (Action <VariableSynchronizer.SynchronizedVariable>)Delegate.CreateDelegate(typeof(Action <VariableSynchronizer.SynchronizedVariable>), method4); } } } } } else { text = "has the uFrame classes been imported?"; } break; } } } if (!string.IsNullOrEmpty(text)) { UnityEngine.Debug.LogError(string.Format("Unable to synchronize {0}: {1}", synchronizedVariable.sharedVariable.Name, text)); this.synchronizedVariables.RemoveAt(i); } } if (this.synchronizedVariables.Count == 0) { base.enabled = false; return; } this.UpdateIntervalChanged(); }