public bool CheckCondition(MapEventCondition data, MapEvent pEventData, TriggerConditionType except, params object[] args) { switch (data.Type) { case TriggerConditionType.EnterRegion: case TriggerConditionType.InitRegion: case TriggerConditionType.LeaveRegion: { return(data.Type == except); } case TriggerConditionType.WaveIndex: case TriggerConditionType.WavesetEnd: { if (except == data.Type) { return((int)args[0] == data.Args.ToInt32()); } else { return(false); } } default: return(false); } }
public override void Import(XmlObject pData, bool pBuild) { MapEvent data = pData as MapEvent; if (data == null) { return; } Type = data.Type; TypeId = data.Id; Relation1 = data.Relation1; Conditions1 = data.Conditions1; TriggerDelay = data.TriggerDelay; Active = data.Active; if (data.Conditions2 != null) { Relation2 = data.Relation2; Conditions2 = data.Conditions2; TriggerNum = data.TriggerNum; TriggerInterval = data.TriggerInterval; } Build(); SetName(); }
public void CreateMapEvent <T, S>(MapEvent pData, LevelRegion pRegion, LevelContainerBase <T> pHolder, List <S> pElemDataList) where T : LevelElement where S : MapElement { T tElement = null; if (pData.Active) { for (int i = 0; i < pElemDataList.Count; i++) { if (pElemDataList[i].Id == pData.Id) { tElement = pHolder.AddElement(); tElement.Import(pElemDataList[i], false); if (tElement is LevelWaveSet) { LevelWaveSet waveset = tElement as LevelWaveSet; waveset.Region = pRegion; } tElement.Init(); } } } else { tElement = pHolder.FindElement(pData.Id); if (tElement != null) { DestroyImmediate(tElement.gameObject); } } }
public override void Read(XmlNode os) { foreach (XmlNode current in XmlObject.GetChilds(os)) { switch (current.Name) { case "Id": this.Id = ReadInt(current); break; case "Center": this.Center = ReadVector3(current); break; case "EulerAngles": this.EulerAngles = ReadVector3(current); break; case "Size": this.Size = ReadVector3(current); break; case "AllowRide": this.AllowRide = ReadBool(current); break; case "AllowPK": this.AllowPK = ReadBool(current); break; case "AllowTrade": this.AllowTrade = ReadBool(current); break; case "AllowFight": this.AllowFight = ReadBool(current); break; case "StartActive": this.StartActive = ReadBool(current); break; case "Events": XmlObject.GetChilds(current).ForEach(delegate(XmlNode pNode) { MapEvent data = new MapEvent(); data.Read(pNode); Events.Add(data); }); break; } } }
public void StartMapEvent(MapEvent pData, LevelRegion pRegion) { switch (pData.Type) { case MapTriggerType.Barrier: { HolderBarrier pHolder = GetHolder(MapHolderType.Barrier) as HolderBarrier; CreateMapEvent <LevelBarrier, MapBarrier>(pData, pRegion, pHolder, Config.Barriers); } break; case MapTriggerType.Region: { HolderRegion pHolder = GetHolder(MapHolderType.Region) as HolderRegion; CreateMapEvent <LevelRegion, MapRegion>(pData, pRegion, pHolder, Config.Regions); } break; case MapTriggerType.Portal: { HolderPortal pHolder = GetHolder(MapHolderType.Portal) as HolderPortal; CreateMapEvent <LevelPortal, MapPortal>(pData, pRegion, pHolder, Config.Portals); } break; case MapTriggerType.Waveset: { HolderWaveSet pHolder = GetHolder(MapHolderType.WaveSet) as HolderWaveSet; CreateMapEvent <LevelWaveSet, MapWaveSet>(pData, pRegion, pHolder, Config.WaveSets); } break; case MapTriggerType.Result: { OnLevelEnd(); } break; case MapTriggerType.Monstegroup: { HolderMonsterGroup pHolder = GetHolder(MapHolderType.MonsterGroup) as HolderMonsterGroup; CreateMapEvent <LevelMonsterGroup, MapMonsterGroup>(pData, pRegion, pHolder, Config.MonsterGroups); } break; case MapTriggerType.Minegroup: { HolderMineGroup pHolder = GetHolder(MapHolderType.MineGroup) as HolderMineGroup; CreateMapEvent <LevelMineGroup, MapMineGroup>(pData, pRegion, pHolder, Config.MineGroups); } break; } }
public void ActiveEventsByCondition(TriggerConditionType type, params object[] args) { for (int i = 0; i < m_Data.Events.Count; i++) { MapEvent data = m_Data.Events[i]; if (m_HasActiveEvents.Contains(data) && data.Conditions2 == null) { continue; } int num = 0; for (int k = 0; k < data.Conditions1.Count; k++) { MapEventCondition pChild = data.Conditions1[k]; bool isTrigger = CheckCondition(pChild, data, type, args); if (isTrigger) { num++; } } bool active = false; switch (data.Relation1) { case ConditionRelationType.And: active = num >= data.Conditions1.Count; break; case ConditionRelationType.Or: active = num > 0; break; } if (active) { GameEntry.Level.StartMapEvent(data, this); if (!m_HasActiveEvents.Contains(data)) { m_HasActiveEvents.Add(data); } } } }
public override XmlObject Export() { MapEvent data = new MapEvent(); data.Type = Type; data.Id = TypeId; data.Relation1 = Relation1; data.Conditions1 = Conditions1; data.TriggerDelay = TriggerDelay; data.Active = Active; if (UseIntervalTrigger) { data.Relation2 = Relation2; data.Conditions2 = Conditions2; data.TriggerNum = TriggerNum; data.TriggerInterval = TriggerInterval; } return(data); }