Beispiel #1
0
        public void InjectScene()
        {
            List <Injection> injects    = new List <Injection>();
            Camera           mainCamera = Camera.main;

            if (null != mainCamera)
            {
                GameObject cameraGo    = mainCamera.gameObject;
                Injection  cameraGoInj = new Injection()
                {
                    key         = "env.mainCamera",
                    typeName    = typeof(GameObject).FullName,
                    value       = cameraGo,
                    asComponent = false,
                };
                injects.Add(cameraGoInj);
                Injection cameraInj = new Injection()
                {
                    key         = "env.cameraFollow",
                    typeName    = typeof(CameraFollow).FullName,
                    value       = cameraGo.GetComponent <CameraFollow>(),
                    asComponent = true,
                };
                injects.Add(cameraInj);
            }
            injections = injects.ToArray();
        }
Beispiel #2
0
 public void Inject(LuaTable self)
 {
     for (int i = 0; i < injections.Length; i++)
     {
         Injection pair = injections[i];
         pair.Inject(self);
     }
 }
Beispiel #3
0
        public void InjectScene()
        {
            List <Injection> injects    = new List <Injection>();
            Camera           mainCamera = Camera.main;

            if (null != mainCamera)
            {
                GameObject cameraGo    = mainCamera.gameObject;
                Injection  cameraGoInj = new Injection()
                {
                    key         = "env.mainCamera",
                    typeName    = typeof(GameObject).FullName,
                    value       = cameraGo,
                    asComponent = false,
                };
                injects.Add(cameraGoInj);
                Injection cameraInj = new Injection()
                {
                    key         = "env.cameraFollow",
                    typeName    = typeof(CameraFollow).FullName,
                    value       = cameraGo.GetComponent <CameraFollow>(),
                    asComponent = true,
                };
                injects.Add(cameraInj);
                if (cameraGo.GetComponent <CameraDrag>() != null)
                {
                    Injection cameraDragInj = new Injection()
                    {
                        key         = "env.cameraDrag",
                        typeName    = typeof(CameraDrag).FullName,
                        value       = cameraGo.GetComponent <CameraDrag>(),
                        asComponent = true,
                    };
                    injects.Add(cameraDragInj);
                }
            }
            //BuildRoot
            var buildRoot = GameObject.Find("BuildRoot");

            if (buildRoot)
            {
                Injection buildInj = new Injection()
                {
                    key         = "placeManager",
                    typeName    = typeof(PlacementManager).FullName,
                    value       = buildRoot.GetComponent <PlacementManager>(),
                    asComponent = true,
                };
                injects.Add(buildInj);
            }

            injections = injects.ToArray();
        }
Beispiel #4
0
        public void InjectMap()
        {
            List <Injection> injects = new List <Injection>();
            //相机
            GameObject cameraDrag = GameObject.Find("CameraControl");
            Injection  inj        = null;

            if (null != cameraDrag)
            {
                inj = new Injection()
                {
                    key         = "env.cameraControl",
                    typeName    = typeof(CameraDrag).FullName,
                    value       = cameraDrag.GetComponent <CameraDrag>(),
                    asComponent = true,
                };
                injects.Add(inj);
            }
            Camera mainCamera = Camera.main;

            if (null != mainCamera)
            {
                GameObject cameraGo = mainCamera.gameObject;
                inj = new Injection()
                {
                    key         = "env.mainCamera",
                    typeName    = typeof(GameObject).FullName,
                    value       = cameraGo,
                    asComponent = false,
                };
                injects.Add(inj);
            }
            GameObject dataGo = GameObject.Find("run");

            if (null != dataGo)
            {
                Transform dataTrans = dataGo.transform;
                foreach (Transform child in dataTrans)
                {
                    if (child.name == "moveTrans")
                    {
                        inj = new Injection()
                        {
                            key         = "moveTrans",
                            typeName    = typeof(Transform).FullName,
                            value       = child,
                            asComponent = false,
                        };
                        injects.Add(inj);
                    }
                    else
                    {
                        Transform loc = child.Find("loc");
                        if (null != loc)
                        {
                            inj = new Injection()
                            {
                                key         = "loc." + child.name,
                                typeName    = typeof(Transform).FullName,
                                value       = loc,
                                asComponent = false,
                            };
                            injects.Add(inj);
                        }
                        Transform marker = child.Find("marker");
                        if (null != marker)
                        {
                            inj = new Injection()
                            {
                                key         = "marker." + child.name,
                                typeName    = typeof(Transform).FullName,
                                value       = marker,
                                asComponent = false,
                            };
                            injects.Add(inj);
                        }
                    }
                }
            }
            injections = injects.ToArray();
        }