Example #1
0
    public static int AddResToCache(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 2 && (LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(GameObject)) || LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(GameObject))))
        {
            var assetPathId = 0;
            if (LuaDLL.lua_isnumber(L, 1))
            {
                assetPathId = (int)LuaDLL.lua_tonumber(L, 1);
            }
            else
            {
                string resPath = LuaDLL.lua_tostring(L, 1);
                assetPathId = resPath.GetHashCode();
            }

            GameObject go = LuaScriptMgr.GetUnityObject <GameObject>(L, 2);
            if (null == go)
            {
                HobaDebuger.LogWarning("AddResToCache: param 2 must be GameObject");
                return(CheckReturnNum(L, count, nRet));
            }
            else
            {
                ResCacheMan.Instance.AddResToCache(assetPathId, go);
            }
        }
        else
        {
            LogParamError("AddResToCache", count);
        }
        return(CheckReturnNum(L, count, nRet));
    }
Example #2
0
        private void SetSmrPropertyByOutwardInfo(SkinnedMeshRenderer smr, OutwardInfo outwardInfo)
        {
            if (smr == null)
            {
                return;
            }

            smr.sharedMesh     = outwardInfo.Mesh;
            smr.sharedMaterial = outwardInfo.Material;

            if (outwardInfo.Bones == null)
            {
                HobaDebuger.LogWarning("Bones info is null");
                return;
            }

            var boneCount = outwardInfo.Bones.Length;

            Transform[] bones        = new Transform[boneCount];
            Transform   newAddedRoot = null;

            for (int i = 0; i < boneCount; i++)
            {
                bones[i] = FindBone(outwardInfo.Bones[i], Vector3.zero, Vector3.zero, Vector3.one, false, out newAddedRoot);
            }

            smr.bones = bones;
        }
Example #3
0
    //no-base call
    public override void AddItem(int index, int count)
    {
        SafeInit();

        if (index < 0 || index > _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewList> AddItem: index out of range! ");
            return;
        }

        if (count < 1)
        {
            return;
        }

        _ItemCount += count;
        RecalculateBound();

        //InternalUpdateContent(index);

        for (int i = 0; i < count; i++)
        {
            GListItem g_item = TryCreateItem();
            _viewItems.Insert(index + i, g_item);
            UpdateItem(_viewItems, index + i, true);
        }

        for (int i = index + count, max = _viewItems.Count; i < max; i++)
        {
            UpdateItem(_viewItems, i, false);
        }
    }
Example #4
0
    private void BuildShaderList(GameObject shaderListObj)
    {
        _ShaderMap.Clear();

        if (shaderListObj != null)
        {
            ShaderList compShaderList = shaderListObj.GetComponent <ShaderList>();
            if (compShaderList != null && compShaderList.Shaders != null)
            {
                try
                {
                    int nCount = compShaderList.Shaders.Length;
                    HobaDebuger.LogFormat("ShaderManager.Init, Shaders Count: {0}", nCount);
                    for (int i = 0; i < nCount; ++i)
                    {
                        Shader shader = compShaderList.Shaders[i];
                        if (shader != null && !_ShaderMap.ContainsKey(shader.name))
                        {
                            _ShaderMap.Add(shader.name, shader);
                            //HobaDebuger.LogFormat("ShaderManager.Init, Load Shader: {0}", shader.name);
                        }
                        else
                        {
                            HobaDebuger.LogWarning(HobaText.Format("ShaderManager.Init, Shader {0} is missing!", i));
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    HobaDebuger.LogError(ae.Message);
                }
            }
        }
    }
Example #5
0
    public void AddItem(int index)
    {
        if (index < 0 || index > _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewLayoutTable> AddItem: index out of range! ");
            return;
        }

        //InsertItem(_ViewItems, index);

        GListItem item = null;

        item = TryCreateItem();
        if (item != null)
        {
            _ViewItems.Insert(index, item);
            _ItemCount = _ViewItems.Count;

            //OnAddItem(item.gameObject, item.index);
            item.UpdateItem(index, true);

            for (int i = index + 1, max = _ViewItems.Count; i < max; i++)
            {
                _ViewItems[i].UpdateItem(i, false);
                _ViewItems[i].RectTrans.SetAsLastSibling();
            }

            if (_MainSelection >= index)
            {
                _MainSelection += 1;
            }

            //RepositionItems();
        }
    }
Example #6
0
    public static int SetTextAlignment(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))))
        {
            var target = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (target == null)
            {
                HobaDebuger.LogWarning("SetTextAlingment :: param 1 must be GameObject");
            }
            else
            {
                int  num = (int)LuaScriptMgr.GetNumber(L, 2);
                Text t   = target.GetComponent <Text>();
                t.alignment = (TextAnchor)num;
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetTextAlignment", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #7
0
    //no-base call
    public override void RemoveItem(int index, int count)
    {
        if (!IsInited)
        {
            return;
        }

        if (index < 0 || index >= _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewList> RemoveItem: index out of range! ");
            return;
        }

        if (count < 1)
        {
            return;
        }

        _ItemCount -= count;
        if (_ItemCount < index)
        {
            _ItemCount = index;
        }
        RecalculateBound();

        while (_viewItems.Count > _ItemCount)
        {
            DisposeItem(_viewItems, index);
        }

        for (int i = index, max = _viewItems.Count; i < max; i++)
        {
            UpdateItem(_viewItems, i, false);
        }
    }
Example #8
0
        public void ChangeArmorEmbroidery(string path)
        {
            if (!_EmbroiderySetting.IsValid)
            {
                HobaDebuger.LogWarning("Current Armor does not support ChangeEmbroidery");
                return;
            }

            var bodyRender = GetSkinnedMeshRenderer(OutwardPart.Body);

            if (bodyRender == null)
            {
                HobaDebuger.LogWarningFormat("Current Armor named {0} has no Body Render", gameObject.name);
                return;
            }

            Material mat = new Material(bodyRender.sharedMaterial);

            if (string.IsNullOrEmpty(path))
            {
                ChangeArmorEmbroidery(mat, false, null, null, null, Vector4.zero);
                bodyRender.sharedMaterial = mat;

                var man = transform.GetComponent <EntityEffectComponent>();
                if (null != man)
                {
                    man.OnMaterialChanged(bodyRender);
                }
            }
            else
            {
                Vector4 rect = new Vector4(_EmbroiderySetting.XMin, _EmbroiderySetting.YMin, _EmbroiderySetting.XMax, _EmbroiderySetting.YMax);

                Action <UnityEngine.Object> callback = (asset) =>
                {
                    GameObject go = asset as GameObject;
                    if (go != null)
                    {
                        var imgset = go.GetComponent <EmbroideryImg>();
                        if (imgset != null)
                        {
                            ChangeArmorEmbroidery(mat, true, imgset.DiffuseTex as Texture2D,
                                                  imgset.NormalTex as Texture2D, imgset.SpecularTex as Texture2D, rect);
                            bodyRender.sharedMaterial = mat;

                            var man = transform.GetComponent <EntityEffectComponent>();
                            if (null != man)
                            {
                                man.OnMaterialChanged(bodyRender);
                            }
                        }
                    }
                    else
                    {
                        HobaDebuger.LogWarningFormat("Resource named {0} is null", path);
                    }
                };
                CAssetBundleManager.AsyncLoadResource(path, callback, false, "outward");
            }
        }
Example #9
0
    public static int DebugKey(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        bool ret = false;

#if UNITY_EDITOR
        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string)))
        {
            try
            {
                string str = LuaScriptMgr.GetString(L, 1);
                ret = Input.GetKey(str);
            }
            catch (Exception e)
            {
                HobaDebuger.LogWarning("TestKey:" + e);
            }
        }
        else
        {
            HobaDebuger.LogError("TestKey: param 1 must be string");
        }
#endif
        LuaScriptMgr.Push(L, ret);

        return(CheckReturnNum(L, count, nRet));
    }
Example #10
0
        private void SetSmrPropertyByFashionInfo(OutwardPart part, SkinnedMeshRenderer smr, FashionOutward fashionInfo)
        {
            if (smr == null)
            {
                return;
            }

            smr.sharedMesh     = fashionInfo.Mesh;
            smr.sharedMaterial = fashionInfo.Material;

            if (fashionInfo.BoneInfos == null)
            {
                HobaDebuger.LogWarning("Bones info is null");
                return;
            }

            var boneCount = fashionInfo.BoneInfos.Length;

            Transform[] bones = new Transform[boneCount];
            for (int i = 0; i < boneCount; i++)
            {
                var       info         = fashionInfo.BoneInfos[i];
                Transform newAddedRoot = null;
                bones[i] = FindBone(info.Bones, info.Position, info.Rotation, info.Scale, true, out newAddedRoot);
                if (newAddedRoot != null)
                {
                    _ExtraTransDic[(int)part].Add(newAddedRoot);
                }
            }

            smr.bones = bones;
        }
Example #11
0
    private static int SetCurLayerVisible(IntPtr L)
    {
        Camera cam = Main.Main3DCamera;

        if (cam == null)
        {
            return(0);
        }

        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(bool))))
        {
            var layer = (int)LuaScriptMgr.GetNumber(L, 1);
            if (layer < 0)
            {
                HobaDebuger.LogWarning("SetCurLayerVisible: Layer can not be a negative number");
                return(CheckReturnNum(L, count, nRet));
            }
            var isOn      = LuaScriptMgr.GetBoolean(L, 2);
            var curMask   = cam.cullingMask;
            var layerMask = 1 << layer;
            var newMask   = isOn ? (curMask | layerMask) : (curMask & (~layerMask));
            cam.cullingMask = newMask;
        }
        else
        {
            LogParamError("SetCurLayerVisible", count);
        }

        return(CheckReturnNum(L, count, nRet));
    }
Example #12
0
    private void SetTransform(Transform trans)
    {
        foreach (var v in actor)
        {
            v.Actor = trans;

            var components = v.GetComponentsInChildren <TextBubbleEvent>(true);
            foreach (var v1 in components)
            {
                v1.textBubble.target = trans;
            }
        }

        for (int i = 0; i < multiActor.Count; i++)
        {
            for (int j = 0; j < multiActor[i].Actors.Count; j++)
            {
                if (multiActor[i].Actors[j] == null)
                {
                    multiActor[i].Actors[j] = trans;
                    break;
                }
            }
        }
        foreach (var v in setParent)
        {
            if (null == v)
            {
                HobaDebuger.LogWarning("CGEntity :this is just a info :" + path + artPath);
                continue;
            }

            if (string.IsNullOrEmpty(v.child))
            {
                v.parent = trans.gameObject;
            }
            else
            {
                var child = trans.Find(v.child);
                if (null != child)
                {
                    v.parent = child.gameObject;
                }
                else
                {
                    HobaDebuger.LogWarning("CGEntity :Cannot find child  :" + path + artPath + v.child);
                }
            }
        }

        foreach (var v in setTransformEvent)
        {
            v.Transform = trans;
        }
    }
Example #13
0
    public bool LoadFromMemory(byte[] filebuffer)
    {
        Clear();

        if (filebuffer == null)
        {
            _IsInited = false;
            return(false);
        }

        try
        {
            using (MemoryStream fs = new MemoryStream(filebuffer))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    _min_x = br.ReadSingle();
                    _min_z = br.ReadSingle();

                    _max_x = br.ReadSingle();
                    _max_z = br.ReadSingle();

                    _count_x = br.ReadInt32();
                    _count_z = br.ReadInt32();

                    _step_trace = br.ReadSingle();

                    _footstepData = new byte[_count_x, _count_z];
                    for (int iz = 0; iz < _count_z; ++iz)
                    {
                        for (int ix = 0; ix < _count_x; ++ix)
                        {
                            _footstepData[ix, iz] = br.ReadByte();
                        }
                    }
                }
            }
        }
        catch (IOException e)
        {
            HobaDebuger.LogWarning(e.Message);

            _IsInited = false;
            return(_IsInited);
        }

        _IsInited = true;
        return(_IsInited);
    }
Example #14
0
    private static int SetStringLength(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string)))
        {
            string content    = LuaDLL.lua_tostring(L, 1);
            int    needLength = int.Parse(LuaDLL.lua_tostring(L, 2));
            if (needLength < 1)
            {
                HobaDebuger.LogWarning("SetStringLength should not be fushu:" + needLength);
                LuaDLL.lua_pushnil(L);
                return(CheckReturnNum(L, count, nRet));
            }
            int countLength = 0;
            for (int i = 0; i < content.Length; i++)
            {
                if ((content[i] >= 0 && content[i] <= 127) || (content[i] >= 194 && content[i] <= 244))
                {
                    countLength++;
                }
                else
                {
                    countLength = countLength + 2;
                }
                if (countLength == needLength)
                {
                    LuaDLL.lua_pushstring(L, content.Substring(0, i + 1));
                    return(CheckReturnNum(L, count, nRet));
                }
                else if (countLength > needLength)
                {
                    LuaDLL.lua_pushstring(L, content.Substring(0, i));
                    return(CheckReturnNum(L, count, nRet));
                }
            }
            HobaDebuger.LogWarning("SetStringLength Unknown:" + needLength);
            LuaDLL.lua_pushnil(L);
            return(CheckReturnNum(L, count, nRet));
        }
        else
        {
            LogParamError("SetStringLength", count);
            LuaDLL.lua_pushnil(L);
            return(CheckReturnNum(L, count, nRet));
        }
    }
Example #15
0
    public static int SetText(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string))))
        {
            var labelObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (labelObj == null)
            {
                HobaDebuger.LogWarning("SetText: param 1 must be GameObject");
                LuaScriptMgr.Instance.CallOnTraceBack();
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var   textComp  = labelObj.GetComponent <Text>();
            GText gtextComp = null;
            if (textComp == null)
            {
                gtextComp = labelObj.GetComponent <GText>();
            }

            if (textComp == null && gtextComp == null)
            {
                HobaDebuger.LogWarning("SetText: param 1 must have text component");
                LuaScriptMgr.Instance.CallOnTraceBack();
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var content = LuaScriptMgr.GetString(L, 2);
            if (null != textComp)
            {
                textComp.text = content;
            }
            else
            {
                gtextComp.text = content;
            }
        }
        else
        {
            //Debug.LogError(LuaStatic.GetTraceBackInfo(L));

            GameUtilWrap.LogParamError("SetText", count);
            LuaScriptMgr.Instance.CallOnTraceBack();
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #16
0
    //no-base call
    public override void RemoveItem(int index, int count)
    {
        if (IsInited)
        {
            if (index < 0 || index >= _ItemCount)
            {
                HobaDebuger.LogWarning("<GNewListLoop> RemoveItem: index out of range! ");
                return;
            }

            if (count < 1)
            {
                return;
            }

            _ItemCount -= count;
            if (_ItemCount < index)
            {
                _ItemCount = index;
            }
            if (_ItemCount < 0)
            {
                _ItemCount = 0;
            }

            int offset = GetPageOffset(_viewRange, index);
            int max    = GetPageOffset(_viewRange, ItemCount);

            if (offset < 0)
            {
                offset = 0;
            }

            for (int i = offset; i < _viewItems.Count && i < max; i++)
            {
                UpdateItem(_viewItems, i, OffsetByPage(_viewRange, i));
            }

            for (int i = _viewItems.Count; i > max && i > 0; i--)
            {
                DisposeItem(_viewItems, i - 1);
            }

            RecalculateBound();
            UpdateContents();
        }
    }
Example #17
0
    private static AssetBundle SyncLoadAssetBundleInUpdate(string assetBundleName)
    {
        if (assetBundleName.Length == 0)
        {
            Debug.LogWarning("can not load bundle with empty name");
            return(null);
        }
        // Already loaded.
        LoadedAssetBundle bundle = null;

        if (_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle) && bundle != null)
        {
            return(bundle.Bundle);
        }

        //判断更新目录下的assetbundle是否存在
        string url;

        if (IsUpdateFileExist(assetBundleName))
        {
            url = HobaText.Format("{0}{1}", _UpdateAssetBundleURL, assetBundleName);
        }
        else
        {
            return(null);
        }

        string key = assetBundleName;
        var    loadedAssetBundle = AssetBundle.LoadFromFile(url);

        if (loadedAssetBundle == null)
        {
            var errMsg = HobaText.Format("failed to load AssetBundle {0}", key);
            if (!_DownloadingErrors.ContainsKey(key))
            {
                _DownloadingErrors.Add(key, errMsg);
            }
            HobaDebuger.LogWarning(errMsg);
            return(null);
        }

        var lab = new LoadedAssetBundle(loadedAssetBundle, key);

        _LoadedAssetBundles.Add(key, lab);
        return(loadedAssetBundle);
    }
Example #18
0
    public static int SetGroupToggleOn(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))))
        {
            var groupObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (groupObj == null)
            {
                HobaDebuger.LogWarning("SetGroupToggleOn: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var group = groupObj.GetComponent <ToggleGroup>();
            if (group == null)
            {
                HobaDebuger.LogWarning("SetGroupToggleOn: param 1 must have ToggleGroup component " + GNewUITools.PrintScenePath(groupObj.transform, 5));
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var toggleIndex = (int)LuaScriptMgr.GetNumber(L, 2);
            var toggleObj   = groupObj.transform.GetChild(toggleIndex - 1);
            //var toggleObj = LuaScriptMgr.GetUnityObject<GameObject>(L, 2);
            if (toggleObj == null)
            {
                HobaDebuger.LogWarning("SetGroupToggleOn: param 2 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var toggle = toggleObj.GetComponent <Toggle>();
            if (toggle == null)
            {
                HobaDebuger.LogWarning("SetGroupToggleOn: param 2 must have Toggle component " + GNewUITools.PrintScenePath(groupObj.transform, 5));
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }
            group.SetAllTogglesOff();
            toggle.isOn = true;
        }
        else
        {
            GameUtilWrap.LogParamError("SetGroupToggleOn", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #19
0
    public static int SetTextAndChangeLayout(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string), typeof(int))))
        {
            var labelObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (labelObj == null)
            {
                HobaDebuger.LogWarning("SetTextAndChangeLayout: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var textComp = labelObj.GetComponent <Text>();
            if (textComp == null)
            {
                HobaDebuger.LogWarning("SetTextAndChangeLayout: param 1 must have text component");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            var content = LuaScriptMgr.GetString(L, 2);
            textComp.text = content;
            var maxPreferredWidth = (int)LuaScriptMgr.GetNumber(L, 3);
            var layout            = labelObj.GetComponent <LayoutElement>();
            if (maxPreferredWidth > 0 && layout != null)
            {
                float pw = textComp.preferredWidth;

                if (pw > maxPreferredWidth)
                {
                    layout.preferredWidth = maxPreferredWidth;
                }
                else
                {
                    layout.preferredWidth = pw + 1;
                }
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetTextAndChangeLayout", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #20
0
    private static int StopSkillScreenEffect(IntPtr L)
    {
        // 如果处于CG中,当前相机会enable false,此时忽略这些效果
        Camera cam = Main.Main3DCamera;

        if (cam == null || !cam.enabled)
        {
            return(0);
        }
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (LuaScriptMgr.CheckTypes(L, 1, typeof(double)))
        {
            int effect_type = (int)LuaScriptMgr.GetNumber(L, 1);

            if (effect_type == 1)  // 打断相机振动
            {
                string       key = (string)LuaScriptMgr.GetString(L, 2);
                CameraShaker cs  = cam.gameObject.GetComponent <CameraShaker>();
                if (cs != null && key != string.Empty)
                {
                    cs.RemoveShakeNodeByKey(key);
                }
                else
                {
                    HobaDebuger.LogWarning("error in StopSkillScreenEffect value check !");
                }
            }
            else if (effect_type == 2)  // 打断相机距离变换
            {
                CCamCtrlMan.Instance.StopCameraStretching();
            }
            else if (effect_type == 3)  // 打断RadialBlur
            {
                var obj_go = LuaScriptMgr.GetUnityObject <GameObject>(L, 2);
                var blur   = obj_go.GetComponentInChildren <RadialBlurBoot>();
                if (blur != null)
                {
                    blur.StopEffect();
                }
            }
        }
        return(CheckReturnNum(L, count, nRet));
    }
Example #21
0
    private static int SubUnicodeString(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if ((count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(int), typeof(int))) ||
            (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(string), typeof(int))))
        {
            string str = LuaScriptMgr.GetString(L, 1);
            if (string.IsNullOrEmpty(str))
            {
                HobaDebuger.LogWarning("SubUnicodeString string is null or empty");
                LuaScriptMgr.Push(L, "");
                return(CheckReturnNum(L, count, nRet));
            }
            int startIndex = (int)LuaScriptMgr.GetNumber(L, 2) - 1;
            try
            {
                if (count == 2)
                {
                    str = str.Substring(startIndex);
                }
                else
                {
                    int length = (int)LuaScriptMgr.GetNumber(L, 3);
                    str = str.Substring(startIndex, length);
                }
                LuaScriptMgr.Push(L, str);
                return(CheckReturnNum(L, count, nRet));
            }
            catch (Exception e)
            {
                HobaDebuger.LogErrorFormat("SubUnicodeString Exception: {0}", e.Message);
                LuaScriptMgr.Push(L, "");
                return(CheckReturnNum(L, count, nRet));
            }
        }
        else
        {
            LogParamError("SubUnicodeString", count);
            LuaScriptMgr.Push(L, "");
            return(CheckReturnNum(L, count, nRet));
        }
    }
Example #22
0
    public static int SetImageAndChangeLayout(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        // gameObject, voiceSecond, maxWidth
        if ((count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int), typeof(int))))
        {
            var labelObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (labelObj == null)
            {
                HobaDebuger.LogWarning("SetImageAndChangeLayout: param 1 must be GameObject");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            Image imgComp = labelObj.GetComponent <Image>();
            if (imgComp == null)
            {
                HobaDebuger.LogWarning("SetImageAndChangeLayout: param 1 must have image component");
                return(GameUtilWrap.CheckReturnNum(L, count, nRet));
            }

            int imageWidth = (int)LuaScriptMgr.GetNumber(L, 2);

            var maxPreferredWidth = (int)LuaScriptMgr.GetNumber(L, 3);
            var layout            = labelObj.GetComponent <LayoutElement>();
            if (maxPreferredWidth > 0 && layout != null)
            {
                if (imageWidth > maxPreferredWidth)
                {
                    layout.preferredWidth = maxPreferredWidth;
                }
                else
                {
                    layout.preferredWidth = imageWidth;
                }
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetImageAndChangeLayout", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #23
0
    public static int GetChildFromTemplate(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))))
        {
            var labelObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (labelObj == null)
            {
                HobaDebuger.LogWarning("GetChildFromTemplate: param 1 must be GameObject");
                LuaDLL.lua_pushnil(L);
            }
            else
            {
                var tempComp = labelObj.GetComponent <UITemplate>();
                if (tempComp == null)
                {
                    HobaDebuger.LogWarning("GetChildFromTemplate: param 1 must have UITemplate component");
                    LuaDLL.lua_pushnil(L);
                }
                else
                {
                    var id  = (int)LuaScriptMgr.GetNumber(L, 2);
                    var ret = tempComp.GetControl(id);
                    if (ret != null)
                    {
                        LuaScriptMgr.Push(L, ret);
                    }
                    else
                    {
                        LuaDLL.lua_pushnil(L);
                    }
                }
            }
        }
        else
        {
            GameUtilWrap.LogParamError("GetChildFromTemplate", count);
            LuaDLL.lua_pushnil(L);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #24
0
    private static int GetModelHeight(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 1;

        if ((count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject))))
        {
            var m = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (m != null)
            {
                float heigth = CUnityUtil.GetModelHeight(m);
                LuaScriptMgr.Push(L, heigth);
            }
            else
            {
                HobaDebuger.LogWarning("GetModelHeight param 1 is null");
                LuaScriptMgr.Push(L, 0);
            }
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(bool)))
        {
            var m = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (m != null)
            {
                bool  inchild = LuaScriptMgr.GetBoolean(L, 2);
                float heigth  = CUnityUtil.GetModelHeight(m, inchild);
                LuaScriptMgr.Push(L, heigth);
            }
            else
            {
                HobaDebuger.LogWarning("GetModelHeight param 1 is null");
                LuaScriptMgr.Push(L, 0);
            }
        }
        else
        {
            LogParamError("GetModelHeight", count);
            LuaScriptMgr.Push(L, 0);
        }

        return(CheckReturnNum(L, count, nRet));
    }
Example #25
0
    //no-base call
    public override void AddItem(int index, int count)
    {
        SafeInit();

        if (index < 0 || index > _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewListLoop> AddItem: index out of range! ");
            return;
        }

        if (count < 1)
        {
            return;
        }

        //update range
        _ItemCount += count;

        //add empty slot
        int max       = Mathf.Min(_viewItems.Count + count, PageSize);
        int deltaSize = max - _viewItems.Count;

        for (int i = 0; i < deltaSize; i++)
        {
            _viewItems.Add(null);
        }

        int offset = GetPageOffset(_viewRange, index);

        if (offset < 0)
        {
            offset = 0;
        }
        for (int i = offset; i < _viewItems.Count; i++)
        {
            UpdateItem(_viewItems, i, OffsetByPage(_viewRange, i));
        }

        RecalculateBound();
        UpdateContents();
    }
Example #26
0
    public static int SetDropDownOption(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string))))
        {
            var target = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (target == null)
            {
                HobaDebuger.LogWarning("GUIWrap :: AddDrowDownOption: param 1 must be GameObject");
            }
            else
            {
                var dorp = target.GetComponent <Dropdown>();
                if (!dorp)
                {
                    HobaDebuger.LogWarning("GUIWrap :: AddDrowDownOption: there isnt a DropDown component on this GameObject.");
                }
                else
                {
                    var options = LuaScriptMgr.GetString(L, 2);
                    if (string.IsNullOrEmpty(options))
                    {
                        HobaDebuger.LogWarning("GUIWrap :: AddDrowDownOption: param 2 IsNullOrEmpty.");
                    }
                    else
                    {
                        dorp.ClearOptions();
                        string[] opts = options.Split(',');
                        dorp.AddOptions(new List <string>(opts));
                    }
                }
            }
        }
        else
        {
            GameUtilWrap.LogParamError("SetDropDownOption", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #27
0
    public void RemoveItem(int index)
    {
        if (index < 0 || index >= _ItemCount)
        {
            HobaDebuger.LogWarning("<GNewLayoutTable> removeItem: index out of range! ");
            return;
        }

        if (MainSelected == index)
        {
            SetSelection(-1);
        }

        DisposeItem(_ViewItems, index);
        _ItemCount = _ViewItems.Count;

        for (int i = index; i < _ViewItems.Count; i++)
        {
            _ViewItems[i].UpdateItem(i, false);
        }
        //RepositionItems();
    }
Example #28
0
    public void Load(FileStream file_stream)
    {
        Clear();

        try
        {
            using (BinaryReader br = new BinaryReader(file_stream))
            {
                _min_x = br.ReadSingle();
                _min_z = br.ReadSingle();

                _max_x = br.ReadSingle();
                _max_z = br.ReadSingle();

                _count_x = br.ReadInt32();
                _count_z = br.ReadInt32();

                _step_trace = br.ReadSingle();

                _footstepData = new byte[_count_x, _count_z];
                for (int iz = 0; iz < _count_z; ++iz)
                {
                    for (int ix = 0; ix < _count_x; ++ix)
                    {
                        _footstepData[ix, iz] = br.ReadByte();
                    }
                }
            }
        }
        catch (IOException e)
        {
            HobaDebuger.LogWarning(e.Message);

            _IsInited = false;
            return;
        }

        _IsInited = true;
    }
Example #29
0
    public static int SetRectTransformStretch(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject)))
        {
            var target = LuaScriptMgr.GetUnityObject <GameObject>(L, 1);
            if (target == null)
            {
                HobaDebuger.LogWarning("AddListOperationEvent :: param 1 must be GameObject");
            }
            else
            {
                RectTransform rt = target.GetComponent <RectTransform>();
                rt.anchorMin = new Vector2(0, 0);
                rt.anchorMax = new Vector2(1, 1);
                rt.offsetMin = new Vector2(0, 0);
                rt.offsetMax = new Vector2(0, 0);
            }
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Example #30
0
    // 真实服务器模式下 接收协议处理
    private static void OnReceiveSocketPrtc(ExSocket exSocket, byte[] data)
    {
        if (data == null || data.Length < sizeof(int))
        {
            HobaDebuger.LogWarning("Protocol Data Length is too short");
            return;
        }

        int id = System.BitConverter.ToInt32(data, 0);

        byte[] pbs = null;
        if (data.Length > sizeof(int))
        {
            int len = data.Length - sizeof(int);
            pbs = new byte[len];
            System.Buffer.BlockCopy(data, 4, pbs, 0, len);
        }

        CS2CPrtcData prtc = _PrtcDataPool.GetObject();

        prtc.Set(id, pbs);
        Instance().AddNewProtocol(prtc);
    }