public void doDecorateItemEvent() { bool deleteEventTrigger = false; //m_eventCanTriggerCount = m_eventList.Count; if (null != m_eventList && m_eventList.Count > 0) { for (int i = 0; i < m_eventList.Count;) { GameEventConfig e = m_eventList[i]; deleteEventTrigger = doEventTrigger(e); if (deleteEventTrigger) { m_eventList.Remove(e); //需要删除的事件 } else { i++; } } } }
//加个返回值判断下事件触发了需不要删除 bool doEventTrigger(GameEventConfig gEvent) { bool deleteEventTrigger = true; //默认触发了就删掉, 除非触发失败或者事件可以多次触发 if (!isEventTrigger(gEvent.eventTriggers)) { return(false); //不能触发事件就返回 } DecorateType eventType = gEvent.eventType; //Debug.Log("SceneDecorateItem::doTrigger: " + m_eDecType); if (eventType == DecorateType.DecType_Random) { if (null != m_lDecList && m_lDecList.Count > 0) { int randInt = Random.Range(0, m_lDecList.Count - 1); m_spRenderer.sprite = m_lDecList[randInt]; if (true == m_bNeedFall) { if (m_gColliderGo.transform.position.x <= transform.position.x) { m_vEulerRotation = this.transform.localEulerAngles; m_vEulerRotation.z = -90.0f; this.transform.localEulerAngles = m_vEulerRotation; } else { m_vEulerRotation = this.transform.localEulerAngles; m_vEulerRotation.z = 90.0f; this.transform.localEulerAngles = m_vEulerRotation; } } } } else if (eventType == DecorateType.DecType_Talk) { if (null == DialogManage.m_me) { return(false); } else if (gEvent.eventResult > 0) { DialogManage.m_me.StartDialogByID(gEvent.eventResult); } } else if (eventType == DecorateType.DecType_GetItem) { if (null == GameManager.instance) { return(false); } else if (gEvent.eventResult > 0) { GameManager.instance.AddItemToPlayer(gEvent.eventResult); } } else if (eventType == DecorateType.DecType_GameOver) { if (null == GameManager.instance) { return(false); } else if (gEvent.eventResult > 0) { //GameManager.instance.GameOver(); 暂时就让他自己走吧 } } destroyTouchItem(); if (deleteEventTrigger) { deleteEventTrigger = gEvent.isRepeat == 0; //可以重复触发的事件不能删除,不能重复触发的触发完删除 } return(deleteEventTrigger); }