コード例 #1
0
    // 反激活当前出战宠物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;
    }
コード例 #2
0
    // 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);
//			}
//		}
    }
コード例 #3
0
    // 更新(继承自MonoBehaviour)
    protected override void Update()
    {
        // 更新CDaa
        if (maxCd > 0)
        {
            cooldown -= Time.deltaTime;
            if (mPetSelectSprite.spriteName != "")
            {
                mPetCD.fillAmount = 0;                  // 激活状态不显示CD.
            }
            else
            {
                mPetCD.fillAmount = cooldown / maxCd;
            }

            if (cooldown <= 0)
            {
                maxCd = 0;                      //< CD结束aa
            }
        }

        // 更新宠物血量aa
        if (sdNewPetMgr.Instance.ActivePetIndex == (int)id)
        {
            GameObject    kGameLevelObject = sdGameLevel.instance.gameObject;
            sdTuiTuLogic  kTuituLogic      = kGameLevelObject.GetComponent <sdTuiTuLogic>();
            sdGameMonster kPet             = kTuituLogic.ActivePet;
            if (kPet != null && kPet.Initialized)
            {
                int iCurHP = kPet.GetCurrentHP();
                int iMaxHP = kPet.GetMaxHP();
                if (mPetHP != null)
                {
                    mPetHP.fillAmount = (float)iCurHP / (float)iMaxHP;                          //< 更新血条aa
                }
            }
        }
        else if (sdNewPetMgr.Instance.BattlePetNum == (int)id)
        {
            // 宠物不显示血量.
            GameObject    kGameLevelObject = sdGameLevel.instance.gameObject;
            sdTuiTuLogic  kTuituLogic      = kGameLevelObject.GetComponent <sdTuiTuLogic>();
            sdGameMonster kPet             = kTuituLogic.FriendPet;
            if (kPet != null && kPet.Initialized)
            {
                if (Time.time - mLastRecoverHPTime > 20.0f)                                     //< 20s自动消失aa
                {
                    sdNewPetMgr.Instance.DeactiveFriendPet();
                }
            }
        }
        else
        {
            float fDeltaTime = Time.time - mLastRecoverHPTime;
            if (fDeltaTime > 0.99f)
            {
                UInt64 ulDBID = sdNewPetMgr.Instance.GetPetFromTeamByIndex((int)id);
                if (ulDBID != UInt64.MaxValue)
                {
                    Hashtable kPetProperty = sdNewPetMgr.Instance.GetPetPropertyFromDBID(ulDBID);
                    if (kPetProperty != null)
                    {
                        int iMaxHP   = (int)kPetProperty["MaxHP"];
                        int iDeltaHP = (int)(iMaxHP * 0.01f);
                        int iCurHP   = (int)kPetProperty["HP"];

                        if (iCurHP + iDeltaHP > iMaxHP)
                        {
                            iCurHP = iMaxHP;
                        }
                        else
                        {
                            iCurHP += iDeltaHP;
                        }

                        kPetProperty["HP"] = iCurHP;                                                                    //< 更新血量aa

                        if (mPetHP != null)
                        {
                            mPetHP.fillAmount = (float)iCurHP / (float)iMaxHP;                                  //< 更新血条aa
                        }
                        mLastRecoverHPTime = Time.time;

                        if (iCurHP / (float)iMaxHP > 0.3f)                                                              //< 血量超过30%才能召唤aa
                        {
                            mIsHPEnough = true;
                        }
                        else
                        {
                            mIsHPEnough = false;
                        }
                    }
                }
            }
        }
    }