Ejemplo n.º 1
0
 public void DoExit()
 {
     foreach (string trigger in triggers)
     {
         TriggerMgr.ToggleTrigger(trigger, false);
     }
     ResourceMgr.CleanAllGameObjects();
 }
Ejemplo n.º 2
0
 public void RegisterTrigger(string _uuid)
 {
     if (triggers.Contains(_uuid))
     {
         return;
     }
     triggers.Add(_uuid);
     //hide the trigger, show it when enter slate
     TriggerMgr.ToggleTrigger(_uuid, false);
 }
Ejemplo n.º 3
0
        public void DoEnter()
        {
            //preload assets
            foreach (Asset asset in assets.Values)
            {
                // asset has format like as .wav
                if (asset.file.Contains("."))
                {
                    byte[] data = UGCMgr.Take(asset.file);
                    if (null == data)
                    {
                        this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file);
                        continue;
                    }
                    if (asset.group.Equals("skybox"))
                    {
                        Material skybox = UGCMgr.BuildSkybox(data);
                        CameraMgr.ApplySkybox(skybox);
                    }
                }
                else
                {
                    Object obj = ResourceMgr.FindFromPreload(asset.package, asset.file);
                    if (null == obj)
                    {
                        this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file);
                        continue;
                    }

                    if (asset.group.Equals("agent"))
                    {
                        GameObject clone = ResourceMgr.CloneGameObject(asset.package, asset.file, asset.guid);
                        agents.Add(asset.guid);
                        clone.transform.position   = new Vector3(asset.px, asset.py, asset.pz);
                        clone.transform.rotation   = Quaternion.Euler(asset.rx, asset.ry, asset.rz);
                        clone.transform.localScale = new Vector3(asset.sx, asset.sy, asset.sz);

                        if (asset.gaze)
                        {
                            ReticleHandler handler = clone.AddComponent <ReticleHandler>();
                            handler.path    = asset.slate;
                            handler.trigger = asset.gazeAlias;
                            EventTrigger et = clone.AddComponent <EventTrigger>();

                            EventTrigger.Entry entryEnter = new EventTrigger.Entry();
                            entryEnter.eventID = EventTriggerType.PointerEnter;
                            entryEnter.callback.AddListener((data) => { handler.onPointerEnter(); });
                            et.triggers.Add(entryEnter);

                            EventTrigger.Entry entryExit = new EventTrigger.Entry();
                            entryExit.eventID = EventTriggerType.PointerExit;
                            entryExit.callback.AddListener((data) => { handler.onPointerExit(); });
                            et.triggers.Add(entryExit);

                            EventTrigger.Entry entryClick = new EventTrigger.Entry();
                            entryClick.eventID = EventTriggerType.PointerClick;
                            entryClick.callback.AddListener((data) => { handler.onPointerClick(); });
                            et.triggers.Add(entryClick);

                            Collider collider = clone.GetComponent <Collider>();
                            if (null != collider)
                            {
                                collider.enabled = true;
                            }
                        }
                    }
                    else if (asset.group.Equals("skybox"))
                    {
                        CameraMgr.ApplySkybox(obj as Material);
                    }
                }
            }

            //hide all triggers
            TriggerMgr.ToggleAllTrigger(false);
            //show trigger in current slate
            foreach (string trigger in triggers)
            {
                TriggerMgr.ToggleTrigger(trigger, true);
            }

            // execute startup blocks
            foreach (string guid in blocks)
            {
                Block block = BlockMgr.FindBlock(guid);
                if (block.action.Equals("Entry:Startup"))
                {
                    block.Execute();
                }
            }
        }