// 反激活好友宠物aa public void DeactiveFriendPet() { if (mFriendPet == null) { return; } // mFriendPet.NotifyKilled -= OnFriendPetKilled; // if (mFriendPet.Master != null) { mFriendPet.Master = null; } // mFriendPet.SetCurrentHP(-1); mFriendPet.AddHP(0); // 更新界面aa GameObject kFightUI = GameObject.Find("FightUi"); if (kFightUI != null) { kFightUI.GetComponent <sdFightUi>().RefreshPet(); } // mFriendPet = null; }
// 反激活当前出战宠物aa public void DeactivePet() { if (mActivePet == null) { return; } // mActivePet.NotifyKilled -= OnPetKilled; // Hashtable kPetProp = sdNewPetMgr.Instance.GetPetPropertyFromDBID(mActivePet.DBID); if (kPetProp != null) { int iCurHP = mActivePet.GetCurrentHP(); if (iCurHP < 0) { iCurHP = 0; } kPetProp["HP"] = iCurHP; //< 写回当前血量aa } // if (mActivePet.Master != null) { sdGameActor kActor = mActivePet.Master as sdGameActor; kActor.Retainer = null; mActivePet.Master = null; } // mActivePet.SetCurrentHP(-1); mActivePet.AddHP(0); // 更新界面aa GameObject kFightUI = GameObject.Find("FightUi"); if (kFightUI != null) { kFightUI.GetComponent <sdFightUi>().RefreshPet(); } mActivePet = null; }
// 激活当前出战的宠物aa public void CreatePet() { if (mActivePet != null) { DeactivePet(); } int iActivePetIndex = sdNewPetMgr.Instance.ActivePetIndex; if (iActivePetIndex < 0) { return; } ulong ulDBID = sdNewPetMgr.Instance.GetPetFromTeamByIndex(iActivePetIndex); if (ulDBID == ulong.MaxValue) { return; } Hashtable kPetProp = sdNewPetMgr.Instance.GetPetPropertyFromDBID(ulDBID); if (kPetProp == null) { return; } // sdGameMonster kPet = null; foreach (sdGameMonster kMonster in mPetList) { if (kMonster.DBID == ulDBID) { kPet = kMonster; break; } } // 显示激活宠物aa // 1.更新血量aa // 2.设置主从关系aa // 3.随机宠物位置aa // 4.注册死亡回调aa if (kPet != null) { mActivePet = kPet; mActivePet.Master = sdGameLevel.instance.mainChar; sdGameLevel.instance.mainChar.Retainer = mActivePet; GameObject kMainPlayer = sdGameLevel.instance.mainChar.gameObject; Vector3 kMainPlayerPos = kMainPlayer.transform.position; Vector3 kBornPosition = kMainPlayerPos; float fFollowDistance = ((int)(kPetProp["FollowDistance"])) / 1000.0f; BornPosition(kMainPlayerPos, fFollowDistance, ref kBornPosition); mActivePet.gameObject.transform.position = kBornPosition; mActivePet.gameObject.transform.rotation = Quaternion.identity; mActivePet.NotifyKilled += OnPetKilled; mActivePet.SetCurrentHP((int)kPetProp["HP"]); //< mActivePet.AddHP(0); // 宠物战队Buffaa List <int> kBuffList = sdNewPetMgr.Instance.GetPetGroupBuff(mActivePet); if (kBuffList != null) { foreach (int iBuffId in kBuffList) { mActivePet.AddBuff(iBuffId, 0, mActivePet); } } } else { string kPath = kPetProp["Res"] as string; ResLoadParams kParam = new ResLoadParams(); kParam.info = "pet"; kParam.userdata0 = ulDBID; sdResourceMgr.Instance.LoadResource(kPath, OnLoadPet, kParam); } }
// Trigger被触发(继承自sdTriggerReceiver)aa public override void OnTriggerHitted(GameObject kObject, int[] kParam) { base.OnTriggerHitted(kObject, kParam); WhenEnterTrigger(kObject, kParam); if (kParam[3] == 0) { foreach (GameObject kMonsterObject in mMonsterKilledList) { sdGameMonster kMonster = kMonsterObject.GetComponent <sdGameMonster>(); if (kMonster != null) { if (!kMonster.IsActive()) { if (kMonster.GetCurrentHP() <= 0) { kMonster.gameObject.transform.position = kMonster.FirstSummonedPosition; kMonster.gameObject.transform.rotation = kMonster.FirstSummonedRotation; kMonster.SetCurrentHP(0); kMonster.AddHP(kMonster.GetMaxHP()); } kMonster.OnTriggerHitted(kObject, kParam); if (kMonster.IsActive() && kMonster.GetCurrentHP() > 0) { mMonsterList.Add(kMonsterObject); } } } } foreach (GameObject kMonsterObject in mMonsterList) { sdGameMonster kMonster = kMonsterObject.GetComponent <sdGameMonster>(); if (kMonster != null) { mMonsterKilledList.Remove(kMonsterObject); } } if (mMonsterList.Count == 0 && mSubNodeList.Count == 0) { WhenLeaveTrigger(kObject, kParam); } } else if (kParam[3] == 1) { List <GameObject> kMonsterList = new List <GameObject>(mMonsterList.ToArray()); //< 防止递归修改mMonsterList对象aa foreach (GameObject kMonsterObject in kMonsterList) { sdGameMonster kMonster = kMonsterObject.GetComponent <sdGameMonster>(); if (kMonster != null) { kMonster.OnTriggerHitted(kObject, kParam); } } } else { } // foreach (GameObject kLevalAreaObject in mSubNodeClearedList) // { // sdLevelArea kArea = kLevalAreaObject.GetComponent<sdLevelArea>(); // if (kArea != null) // { // kArea.OnTriggerHitted(kObject, kParam); // mSubNodeList.Add(kLevalAreaObject); // } // } }