Ejemplo n.º 1
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);
//			}
//		}
    }