コード例 #1
0
        /// <summary>
        /// 获取目标模型
        /// </summary>
        /// <param name="node">节点</param>
        public TargetModelInfo GetTargetModel(XmlNode node)
        {
            var targetModel = new TargetModelInfo();
            var xe          = (XmlElement)node;

            targetModel.TargetModelId = xe.GetAttribute(Const.Id);
            foreach (XmlNode property in xe.ChildNodes)
            {
                property.CommonInfoHandle(targetModel);
                switch (property.Name)
                {
                case Const.ATargetModelUrl:
                    targetModel.TargetUrl = property.InnerText;
                    break;

                case Const.ATargetModelId:
                    targetModel.TargetId = property.InnerText;
                    break;

                case Const.ATargetModelClassId:
                    targetModel.TargetClassId = property.InnerText;
                    break;

                case Const.ATargetModelLastModificationDate:
                    targetModel.TargetLastModificationDate = property.InnerText.ToDateTime();
                    break;
                }
            }

            return(targetModel);
        }
コード例 #2
0
        static int _s_set_ModelAction(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                TargetModelInfo __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.ModelAction = LuaAPI.lua_tostring(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
コード例 #3
0
        static int _g_get_LocalEuler(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                TargetModelInfo __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);
                translator.PushUnityEngineVector3(L, __cl_gen_to_be_invoked.LocalEuler);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
コード例 #4
0
        static int _g_get_ResPath(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                TargetModelInfo __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.ResPath);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
コード例 #5
0
        static int _s_set_LocalEuler(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                TargetModelInfo     __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);
                UnityEngine.Vector3 __cl_gen_value; translator.Get(L, 2, out __cl_gen_value);
                __cl_gen_to_be_invoked.LocalEuler = __cl_gen_value;
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
コード例 #6
0
        static int __CreateInstance(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    TargetModelInfo __cl_gen_ret = new TargetModelInfo();
                    translator.Push(L, __cl_gen_ret);
                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to TargetModelInfo constructor!"));
        }
コード例 #7
0
        static int _m_SetModelInfo(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            TargetModelInfo __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);


            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 6 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.Vector3>(L, 3) && translator.Assignable <UnityEngine.Vector3>(L, 4) && translator.Assignable <UnityEngine.Vector3>(L, 5) && (LuaAPI.lua_isnil(L, 6) || LuaAPI.lua_type(L, 6) == LuaTypes.LUA_TSTRING))
                {
                    string res_path = LuaAPI.lua_tostring(L, 2);
                    UnityEngine.Vector3 local_pos; translator.Get(L, 3, out local_pos);
                    UnityEngine.Vector3 local_scale; translator.Get(L, 4, out local_scale);
                    UnityEngine.Vector3 local_euler; translator.Get(L, 5, out local_euler);
                    string modelAction = LuaAPI.lua_tostring(L, 6);

                    __cl_gen_to_be_invoked.SetModelInfo(res_path, local_pos, local_scale, local_euler, modelAction);



                    return(0);
                }
                if (__gen_param_count == 5 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.Vector3>(L, 3) && translator.Assignable <UnityEngine.Vector3>(L, 4) && translator.Assignable <UnityEngine.Vector3>(L, 5))
                {
                    string res_path = LuaAPI.lua_tostring(L, 2);
                    UnityEngine.Vector3 local_pos; translator.Get(L, 3, out local_pos);
                    UnityEngine.Vector3 local_scale; translator.Get(L, 4, out local_scale);
                    UnityEngine.Vector3 local_euler; translator.Get(L, 5, out local_euler);

                    __cl_gen_to_be_invoked.SetModelInfo(res_path, local_pos, local_scale, local_euler);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to TargetModelInfo.SetModelInfo!"));
        }
コード例 #8
0
        static int _m_StartLoadModel(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            TargetModelInfo __cl_gen_to_be_invoked = (TargetModelInfo)translator.FastGetCSObj(L, 1);


            try {
                {
                    __cl_gen_to_be_invoked.StartLoadModel(  );



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
コード例 #9
0
        /// <summary>
        /// 拷贝指引的目标控件
        /// </summary>
        public void CopyTargetObj()
        {
            if (TargetObject == null)
            {
                return;
            }

            CopyObj = UnityEngine.GameObject.Instantiate(TargetObject) as GameObject;


            var toggle = CopyObj.GetComponent <Toggle>();

            if (toggle != null)
            {
                toggle.group = null;
            }

            CopyTrans = CopyObj.transform;

            // 需要特殊处理的MonoBehaviour
            var spec_list = SGameEngine.Pool <MonoBehaviour> .List.New();

            // 把非UI控件的MonoBehaviour销毁掉
            var remove_list = SGameEngine.Pool <MonoBehaviour> .List.New();

            var db_guide_copy_behavior = DBManager.Instance.GetDB <DBGuideCopyBehavior>();

            foreach (var com in CopyObj.GetComponentsInChildren <MonoBehaviour>(true))
            {
                // 处理特殊的组件
                TargetModelInfo target_model_info = com as TargetModelInfo;
                if (target_model_info != null)
                {
                    spec_list.Add(target_model_info);
                    continue;
                }

                // 因为UIItemNewSlot采用了延迟加载图标,直接拷贝会图标丢失,需要把UIItemNewSlot也拷贝进来并进行加载工作
                UIItemNewSlot slot = com as UIItemNewSlot;
                if (slot != null)
                {
                    UIItemNewSlot source_slot = TargetObject.GetComponentInChildren <UIItemNewSlot>();

                    if (source_slot != null)
                    {
                        slot.ItemInfo = source_slot.ItemInfo;
                        slot.SetUI();
                        if (slot.ItemInfo != null && GoodsHelper.GetGoodsType(slot.ItemInfo.type_idx) == GameConst.GIVE_TYPE_SOUL)
                        {
                            slot.CanShowCircleBkg = true;
                            slot.SetColor(false);
                            slot.SetBgImageVisiable(false);
                            slot.SetEffectRootVisiable(false);
                        }
                    }

                    continue;
                }

                // ui控件的基类
                if (com == null || com is ICanvasElement || com is Selectable)
                {
                    continue;
                }

                // 其他需要添加的组件
                string class_name = com.GetType().Name;
                if (db_guide_copy_behavior.ContainType(class_name))
                {
                    continue;
                }

                //有Alpha渐变时直接设为不透明
                TweenAlpha tween = com as TweenAlpha;
                if (tween != null)
                {
                    tween.value = 1;
                }

                // 剩余的组件添加到remove_list
                remove_list.Add(com);
            }

            for (int i = remove_list.Count - 1; i >= 0; i--)
            {
                //包含序列帧特效的GameObject直接删掉,因为有特效重叠不同步的问题,物品除外
                if (remove_list[i] is UGUIFrameAnimation)
                {
                    if (remove_list[i].transform.parent != null && remove_list[i].transform.parent.parent != null)
                    {
                        if (remove_list[i].transform.parent.parent.GetComponent <UIItemNewSlot>() == null)
                        {
                            UnityEngine.Object.DestroyImmediate(remove_list[i].gameObject);
                        }
                    }
                }
                else
                {
                    UnityEngine.Object.DestroyImmediate(remove_list[i]);
                }
            }
            SGameEngine.Pool <MonoBehaviour> .List.Free(remove_list);

            var canvas = CopyObj.GetComponent <Canvas>();

            if (canvas != null)
            {
                UnityEngine.Object.DestroyImmediate(canvas);
            }

            CopyObj.SetActive(false);
            CopyTrans.SetParent(Wnd.TargetTmpRoot);

            var local_pos = CopyTrans.localPosition;

            local_pos.z             = 0f;
            CopyTrans.localPosition = local_pos;
            RectTransform copy_trans   = CopyTrans.GetComponent <RectTransform>();
            RectTransform traget_trans = TargetObject.GetComponent <RectTransform>();

            UGUIMath.SetWidgetSize(copy_trans, traget_trans);
            CopyObj.SetActive(true);

            // 可能traget_trans的父亲节点有缩放
            var rect_corner = new Vector3[4];

            copy_trans.GetWorldCorners(rect_corner);
            float copy_rect_size_x = rect_corner[2].x - rect_corner[0].x;

            traget_trans.GetWorldCorners(rect_corner);
            float target_size_x = rect_corner[2].x - rect_corner[0].x;

            float scale = 1;

            if (copy_rect_size_x != 0)
            {
                scale = target_size_x / copy_rect_size_x;
            }
            Vector3 ori_scale = CopyTrans.localScale;

            CopyTrans.localScale = new Vector3(ori_scale.x * scale, ori_scale.y * scale, ori_scale.z * scale);

            for (int i = spec_list.Count - 1; i >= 0; i--)
            {
                var com = spec_list[i];

                //StartLoadModel 函数中播放模型动作在object隐藏时会不生效,需延后调用
                TargetModelInfo target_model_info = com as TargetModelInfo;
                if (target_model_info != null)
                {
                    target_model_info.StartLoadModel();
                }
            }

            SGameEngine.Pool <MonoBehaviour> .List.Free(spec_list);
        }