Example #1
0
        public void VerifyGC()
        {
            // Verify that we can:
            //
            //      1. Add an event listener
            //      2. Receive events
            //      3. Force a GC and still receive events
            //      4. Clear references to the listener
            //         (without removing the handler)
            //      5. Force a GC again and verify that the
            //         listener was collected.

            var source   = new EventSource();
            var listener = new EventListener();

            received = false;
            listener.AddListener(source);
            source.RaiseEvent();
            Assert.True(received);

            TriggerGC();

            received = false;
            source.RaiseEvent();
            Assert.True(received);

            listener  = null;
            collected = false;
            TriggerGC();
            Assert.True(collected);
        }
Example #2
0
    public SceneCatAIStateManager(SceneCat creep)
        : base(creep)
    {
        EventListener.AddListener(ObjectEvent.CallCat, delegate(GameObject gameObject) {
            AIObjectParam param = new AIObjectParam(gameObject);
            SetState <CatRunRaoTouState>(param);
            _CallCat = true;
        });

        EventListener.AddListener(ObjectEvent.CallEat, delegate(GameObject gameObject) {
            AIObjectParam param = new AIObjectParam(gameObject);
            SetState <CatRunEatState>(param);
            _CallEat = true;
        });
    }
Example #3
0
        public void Basics()
        {
            // Verify that we can:
            //
            //      1. Add an event listener
            //      2. Receive events
            //      3. Remove the listener
            //      4. Stop receiving events

            var source   = new EventSource();
            var listener = new EventListener();

            received = false;
            listener.AddListener(source);
            source.RaiseEvent();
            Assert.True(received);

            received = false;
            listener.RemoveListener(source);
            source.RaiseEvent();
            Assert.False(received);
        }
Example #4
0
    void Start()
    {
        var task = AssetLoader.LoadScene("testscene.unity", LoadSceneMode.Additive, (scene, mode) =>
        {
            mScene = scene;
        });

        task.isCancel = true;

        //return;

        AssetLoader.LoadAsset <TextAsset>("data.bytes", (asset) =>
        {
            if (asset != null)
            {
                byte[] bytes = asset.assetObject.bytes;

                //启动线程加载
                ThreadQueue.RunAsync(() => DataTableManager.Instance.Init(bytes),
                                     () => {
                    asset.Destroy();
                });
            }
        });

        AssetLoader.LoadAsset <GameObject>("cube.prefab", (asset) => {
            if (asset != null)
            {
                Debug.Log("Load Success:cube.prefab!");
                asset.Destroy();
            }
            else
            {
                Debug.Log("Load Failed:cube.prefab!");
            }
        });



        AssetLoader.LoadAsset <GameObject>("cube1.prefab", (asset) =>
        {
            if (asset != null)
            {
                Debug.Log("Load Success:cube1.prefab!");
            }
            else
            {
                Debug.Log("Load Failed:cube1.prefab!");
            }
        });
        //task.isCancel = true;

        Instance = this;

        CameraManager.Instance.Init();

        mEntity          = ObjectPool.GetInstance <BattleEntity>();
        mEntity.id       = 1;
        mEntity.position = Vector3.zero;
        mEntity.config   = "yingxiong_kulouqishi.txt";
        mEntity.properties.SetProperty <float>((uint)PropertyID.PRO_MOVE_SPEED, 6);

        BattleManager.Instance.AddEntity(mEntity);
        mEntity.active = true;

        mEntity1          = ObjectPool.GetInstance <BattleEntity>();
        mEntity1.id       = 2;
        mEntity1.position = new Vector3(10, 0, 0);
        mEntity1.config   = "nvjiangjun.txt";

        BattleManager.Instance.AddEntity(mEntity1);
        mEntity1.active = true;

        EventSystem.Instance.AddListener(1, 1, 0, OnListen);
        EventSystem.Instance.Invoke(1, 1, 0);

        EventListener listener = new EventListener();

        listener.AddListener((Action)OnListen);
        listener.Invoke();
        listener.AddListener((Action <int>)OnListen);
        listener.Invoke(1);
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     EventListener.AddListener(ObjectEvent.SendSound, delegate() {
         EventListener.Broadcast(ObjectEvent.CallCat, gameObject);
     });
 }