示例#1
0
    void OnGUI()
    {
        GUI.skin = demoSkin;

        float scale = 1.0f;

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            scale = Screen.width / 320;
        }

        //float btnWidth = 165 * scale;
        float btnWidth  = Screen.width / 5 * 2;
        float btnHeight = Screen.height / 25;
        float btnTop    = 30 * scale;
        float btnGap    = 20 * scale;

        GUI.skin.button.fontSize = Convert.ToInt32(13 * scale);

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Send Notify"))
        {
            Hashtable extras = new Hashtable();
            extras.Add("key1", "value1");
            extras.Add("key2", "value2");
            extras.Add("key3", "value3");
            mobPush.req(1, "content-Send Notify", 0, extras);
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Send App Notify"))
        {
            mobPush.req(2, "App Notify", 0, null);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Send Delayed Notify"))
        {
            mobPush.req(3, "Delayed Notify", 1, null);
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Send Locat Notify"))
        {
            LocalNotifyStyle style = new LocalNotifyStyle();
            style.setContent("Text");
            style.setTitle("title");

                #if UNITY_ANDROID
            Hashtable extras = new Hashtable();
            extras["key1"] = "value1";
            extras["key2"] = "value1";
            style.setExtras(extras);
                #endif

            mobPush.setMobPushLocalNotification(style);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "CustomNotify"))
        {
            CustomNotifyStyle style = new CustomNotifyStyle();

                #if UNITY_IPHONE
            style.setType(CustomNotifyStyle.AuthorizationType.Badge | CustomNotifyStyle.AuthorizationType.Sound | CustomNotifyStyle.AuthorizationType.Alert);
                #elif UNITY_ANDROID
            style.setContent("Content");
            style.setTitle("Title");
            style.setTickerText("TickerText");
                #endif

            mobPush.setCustomNotification(style);
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "getRegistrationId"))
        {
            mobPush.getRegistrationId();
        }

        //Test Code
        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "addTags"))
        {
            String[] tags = { "tags1", "tags2", "tags3" };
            mobPush.addTags(tags);
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "getTags"))
        {
            mobPush.getTags();
        }


        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "deleteTags"))
        {
            String[] tags = { "tags1", "tags2", "tags3" };
            mobPush.deleteTags(tags);
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "cleanAllTags"))
        {
            mobPush.cleanAllTags();
        }


        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "addAlias"))
        {
            mobPush.addAlias("alias");
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "getAlias"))
        {
            mobPush.getAlias();
        }


        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "cleanAllAlias"))
        {
            mobPush.cleanAllAlias();
        }

                #if UNITY_ANDROID
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "stopPush"))
        {
            mobPush.stopPush();
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "restartPush"))
        {
            mobPush.restartPush();
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "isPushStop"))
        {
            mobPush.isPushStopped();
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "setClickNotificationToLaunchPage"))
        {
            mobPush.setClickNotificationToLaunchPage(false);
        }
                #endif
    }
示例#2
0
    private static void OnPushEvent(string eventName, Event_ e)
    {
        switch (eventName)
        {
            #region Module events
        case Module_Player.EventFatigueChanged:
        {
            var time = modulePlayer.fatigueRemainTime;
            DelayTimeToNitifyFatigue(time);
            break;
        }

        case Module_Skill.EventUpdateSkillPoint:
        {
            var time = moduleSkill.remainTime;
            DelayTimeToNitifySkill(time);
            break;
        }
            #endregion

            #region SDK events
        case SDKEvent.SELECT_ROLE:        // 添加别名
        {
            var roleId = Convert.ToString((ulong)e.param1);
            m_mobPush.addAlias(roleId);
            break;
        }

        case SDKEvent.TAG:        // tag操作不会操作工会tag
        {
            var type = (uint)e.param1;
            var _id  = (byte)e.param2;
            var tag  = Util.Format(PushTagType_1, _id);

            if (type == 1)
            {
                m_mobPush.addTags(new string[] { tag });
            }
            else
            {
                m_mobPush.deleteTags(new string[] { tag });
            }

            Logger.LogDetail("SDKManager:: {0} tag:{1}", type == 0 ? "删除" : "添加", tag);
            break;
        }

        case SDKEvent.LOCAL_NOTIFY:        // 设置体力和技能点的本地通知
        {
            var type = (SwitchType)e.param1;
            if (type == SwitchType.Fatigue)
            {
                var timeStamp = modulePlayer.fatigueRemainTime;
                DelayTimeToNitifyFatigue(timeStamp);
            }
            else if (type == SwitchType.SkillPoint)
            {
                if (!moduleGuide.IsActiveFunction(HomeIcons.Skill))
                {
                    break;
                }
                var timeStamp = moduleSkill.remainTime;
                DelayTimeToNitifySkill(timeStamp);
            }
            break;
        }

        case SDKEvent.UNION_CHANGE:       // 设置工会tag
        {
            var key      = modulePlayer.id_ + SwitchType.UnionBoss.ToString();
            var prefsTag = PlayerPrefs.GetString(key);

            var unionId = (ulong)e.param1;
            var type    = (uint)e.param2;

            if (unionId == 0)
            {
                if (!string.IsNullOrEmpty(prefsTag))
                {
                    m_mobPush.deleteTags(new string[] { prefsTag });
                }
                return;
            }

            var tag = Util.Format(PushTagType_2, unionId);

            Logger.LogDetail("SDKManager:: {0} 工会 tag:{1}", type == 0 ? "删除" : "添加", tag);

            if (type == 0)
            {
                m_mobPush.deleteTags(new string[] { tag });
                PlayerPrefs.DeleteKey(key);
            }
            else
            {
                m_mobPush.addTags(new string[] { tag });
                PlayerPrefs.SetString(key, tag);
            }
            break;
        }
            #endregion

        default: break;
        }
    }