Example #1
0
        protected virtual void OnNodeStarted(EditorScene z)
        {
            z.OnUnitDead            += Z_OnUnitDead;
            z.OnUnitGotInstanceItem += Z_OnUnitGotInstanceItem;
            z.OnGameOver            += Z_OnGameOver;

            if (TimerConfig.timer_sec_ZoneKeepPlayerTimeout > 0)//场景无人后清理时间.程序控制.
            {
                keepPlayerExpire = TimeSpan.FromSeconds(TimerConfig.timer_sec_ZoneKeepPlayerTimeout);
                z.AddTimePeriodicMS((int)(keepPlayerExpire.TotalMilliseconds / 2), (t) =>
                {
                    CheckZoneDispose(z, t);
                });
            }
            this.EventMgr = EventManagerFactory.Instance.CreateEventManager("Zone", z.UUID);
            if (this.EventMgr != null)
            {
                this.EventMgr.PutObject("Zone", z);
                this.EventMgr.PutObject("Service", this.service);
                this.EventMgr.PutObject("Node", this);
                this.EventMgr.Start();
                node.OnZoneBeginUpdate += zone =>
                {
                    this.EventMgr.EnterUpdate();
                };
                node.OnZoneEndUpdate += zone =>
                {
                    this.EventMgr.Update();
                };
            }
        }