123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using CommonAI.Zone;
- using CommonAI.Zone.ZoneEditor;
- using XmdsCommonServer.Plugin.Scene;
- using CommonAI.Data;
- using CommonAI.Zone.Instance;
- namespace XmdsCommonZone.Zones
- {
-
- [XmdsExtensionZone(12201)]
- public class Zone12201 : XmdsServerScene
- {
- private static readonly int S_MONSTER_ID = 1220101;
- private static readonly int S_FOLLOWER_ID = 320009;
-
- private int mMonsterMax = 0;
- private int mFollowerMax = 0;
- private int mTotalCount = 0;
-
- private int mCurMonsters = 0;
- private int mCurFollowers = 0;
- public Zone12201(TemplateManager templates, InstanceZoneListener listener, SceneData data, GSCreateAreaData gsData, string bindGameSrvId)
- : base(templates, listener, data, gsData, bindGameSrvId)
- {
-
- }
- protected override void baseInit(CommonAI.Zone.ZoneEditor.SceneData data, GSCreateAreaData gsData)
- {
- if(gsData == null)
- {
- Log.Error("Zone12201场景游戏服数据为空!");
- return;
- }
- this.mTotalCount = gsData.value1;
- this.mFollowerMax = gsData.value2;
- this.mMonsterMax = Math.Max(0, gsData.value1 - gsData.value2);
- OnTryAddUnit += OnTryAddUnitHandler;
- OnTryAddItem += OnTryAddItemHandler;
- OnUnitRemoved += OnUnitRemovedHandler;
- OnItemRemoved += OnItemRemoveHandler;
- }
- private bool OnTryAddUnitHandler(UnitInfo info)
- {
-
- if(info.UType != UnitInfo.UnitType.TYPE_MONSTER || info.ID != S_MONSTER_ID)
- {
- return true;
- }
-
- if(this.mCurMonsters >= this.mMonsterMax)
- {
- return false;
- }
- this.mCurMonsters++;
-
- return true;
- }
- private bool OnTryAddItemHandler(ItemTemplate info)
- {
-
- if(info.ID != S_FOLLOWER_ID)
- {
- return true;
- }
- if(this.mCurFollowers >= this.mFollowerMax)
- {
- return false;
- }
-
- this.mCurFollowers++;
-
- return true;
- }
- public void OnUnitRemovedHandler(InstanceZone zone, InstanceUnit obj)
- {
- if (obj.IsMonster && obj.Info.ID == S_MONSTER_ID)
- {
- this.mCurMonsters--;
-
- if (this.mCurMonsters < 0)
- {
- Log.Error("OnUnitRemovedHandler monster num is error: " + this.mCurMonsters + ", " + this.mMonsterMax
- + ", " + this.mFollowerMax + ", " + this.mTotalCount);
- this.mCurMonsters = 0;
- }
- }
- }
- public void OnItemRemoveHandler(InstanceZone zone, InstanceItem obj)
- {
- if (obj.Info.ID != S_FOLLOWER_ID)
- {
- return ;
- }
- this.mCurFollowers--;
-
- if (this.mCurFollowers < 0)
- {
- Log.Error("OnItemRemoveHandler item num is error: " + this.mCurFollowers + ", " + this.mMonsterMax +
- ", " + this.mFollowerMax + ", " + this.mTotalCount);
- this.mCurFollowers = 0;
- }
- }
-
- public override void GSZoneFlagNotifyMsg(int value1)
- {
- this.mFollowerMax = Math.Max(this.mFollowerMax, value1);
- this.mMonsterMax = Math.Max(0, this.mTotalCount - this.mFollowerMax);
-
- }
- }
- }
|