Exemplo n.º 1
0
    //新建一层,叠加或覆盖 如果replace=true 则s_LLStatus的值无效
    public GameObject CreateAndAdd(string uiLayer, string uiname, bool replace = true, LastLayerStatus s_LLStatus = LastLayerStatus.Active_N_Net_N)
    {
        if (currLayerComp != null)
        {
            if (currLayerComp.name == uiname)
            {
                Debug.Log("T CreateAndAdd 同样的界面不要连续加两次!" + uiname);
                return(currLayerComp.gameObject);
            }
        }

        //实例化
        GameObject s_UILayer = UILayerManage.InstantiateUIPre(uiname);

        //添加通用组件
        s_UILayer.AddComponent <UIComponent>();

        //添加本身组件
        s_UILayer.AddComponent(uiLayer);

        //
        if (s_UILayer != null)
        {
            if (replace)
            {
                ReplaceLayer(s_UILayer);
            }
            else
            {
                AddNewLayer(s_UILayer, s_LLStatus);
            }
        }
        return(s_UILayer);
    }
Exemplo n.º 2
0
 public static UILayerManage getInstance()
 {
     if (s_UILayerManage == null)
     {
         s_UILayerManage = new UILayerManage();
     }
     return(s_UILayerManage);
 }
Exemplo n.º 3
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 100, 50), "连接测试"))
        {
            Debug.Log("开始连接");

            string ip   = "192.168.0.43";
            int    port = 6000;

            NetWorkManage s_NetWorkManage = NetWorkManage.getInstance();
            s_NetWorkManage.setHostPort(ip, port);
            if (!s_NetWorkManage.Connect())
            {
                Debug.Log("服务器连接失败,请检查网络!");
                return;
            }
        }

        if (GUI.Button(new Rect(150, 10, 100, 50), "登陆"))
        {
            //登录请求
            Debug.Log("登录请求");

            Msg_2_2 msg = new Msg_2_2();
            msg.aid    = "Test02"; //先写死角色名
            msg.zoneId = 1;        //先写死1

            SendDataStruct data = new SendDataStruct();
            data.cmd      = 2;
            data.dest     = 2;
            data.instance = msg;

            //NetWorkManage.SendData(2, 2, msg);
            NetWorkManage.SendData(data);
        }

        if (GUI.Button(new Rect(350, 10, 100, 50), "login"))
        {
            //登录请求
            Debug.Log("login界面");
            GameObject obj = UILayerManage.getInstance().CreateRoot("UILogin", "UILogin");
        }

        if (GUI.Button(new Rect(500, 10, 100, 50), "抽象工厂模式"))
        {
            IProtocolFactory factory = new ProtocolFactory();

            factory.createProtocolType1().DeserializeData(null);
            factory.createProtocolType2().DeserializeData(null);
        }
    }
Exemplo n.º 4
0
 public void preFireBnt(GameObject obj)
 {
     if ("netBnt" == obj.name)
     {
         Msg_2_2 msg = new Msg_2_2();
         msg.aid    = "Test02"; //先写死角色名
         msg.zoneId = 1;        //先写死1
         NetWorkManage.SendData <Msg_2_2>(2, 2, msg);
     }
     else
     {
         UILayerManage.getInstance().RemoveLayer(gameObject);
     }
 }
Exemplo n.º 5
0
 public void preFireBnt(GameObject obj)
 {
     if ("getTestBnt0" == obj.name)
     {
         UILayerManage.getInstance().RemoveLayer(gameObject);
     }
     else if ("getTestBnt1" == obj.name)
     {
         UILayerManage.getInstance().CreateAndAdd("UIAdditionTip", "UIAdditionTip", false);
     }
     else if ("getTestBnt2" == obj.name)
     {
         UILayerManage.getInstance().CreateAndAdd("UIAdditionTip", "UIAdditionTip", true);
     }
 }
Exemplo n.º 6
0
 public void preFireBnt(GameObject obj)
 {
     if (LOGINBTN0 == obj.name)
     {
         Msg_2_2 msg = new Msg_2_2();
         msg.aid    = "Test02"; //先写死角色名
         msg.zoneId = 1;        //先写死1
         //NetWorkManage.SendData<Msg_2_2>(2, 2, msg);
     }
     else if (LOGINBTN1 == obj.name)
     {
         UILayerManage.getInstance().CreateAndAdd("UIHeroUP", "UIHeroUP", false);
     }
     else if (LOGINBTN2 == obj.name)
     {
         Debug.Log("我我我");
     }
 }
Exemplo n.º 7
0
    //创建第一层界面
    public UIComponent CreateRoot(UIComponent uiLayer, string uiname)
    {
        while (currLayerComp != null)
        {
            RemoveLayer(null, true);
        }

        UIComponent _ui = UILayerManage.InstantiateUIPre(uiLayer, uiname);

        //添加组件
        //s_obj.AddComponent<UIComponent>();
        //s_obj.AddComponent(scriptName);

        if (_ui != null)
        {
            AddNewLayer(_ui, LastLayerStatus.Active_N_Net_N);
        }

        DisposeRes();

        return(_ui);
    }
Exemplo n.º 8
0
    //创建第一层界面
    public GameObject CreateRoot(string uiname, string scriptName)
    {
        while (currLayerComp != null)
        {
            RemoveLayer(currLayerComp.gameObject, true);
        }

        GameObject s_obj = UILayerManage.InstantiateUIPre(uiname);

        //添加组件
        s_obj.AddComponent <UIComponent>();

        s_obj.AddComponent(scriptName);

        if (s_obj != null)
        {
            AddNewLayer(s_obj, LastLayerStatus.Active_N_Net_N);
        }

        DisposeRes();

        return(s_obj);
    }
Exemplo n.º 9
0
    //// Use this for initialization
    //void Start () {

    //}

    //// Update is called once per frame
    //void Update () {

    //}

    //void Awake()
    //{
    //    UIComponent netWork = gameObject.GetComponent<UIComponent>();

    //    UIEventListener.Get(netWork.objMap["closeBnt"]).onClick += preFireBnt;
    //    UIEventListener.Get(netWork.objMap["netBnt"]).onClick += preFireBnt;

    //    netWork.onNetWord = NetResponse;

    //    netWork.onEnter = OnEnterkkk;

    //    netWork.onExit = OnExitkkk;
    //}

    //加入场景 replace=true 替换上一层。replace=false 直接叠加一层。
    public static UIAdditionTip AddNew(bool replace = false)
    {
        UIAdditionTip s_UIHeroUP = (UIAdditionTip)UILayerManage.getInstance().CreateAndAdd(new UIAdditionTip(), "UIAdditionTip", replace);

        return(s_UIHeroUP);
    }
Exemplo n.º 10
0
    //void Awake()
    //{
    //    UIComponent netWorkCOM = gameObject.GetComponent<UIComponent>();

    //    netWorkCOM.setCallback(NetResponse, OnEnterkkk, OnExitkkk);

    //    //添加按钮回调
    //    UIEventListener.Get(netWorkCOM.objMap[LOGINBTN0]).onClick += preFireBnt;
    //    UIEventListener.Get(netWorkCOM.objMap[LOGINBTN1]).onClick += preFireBnt;
    //    UIEventListener.Get(netWorkCOM.objMap[LOGINBTN2]).onClick += preFireBnt;
    //}

    //// Use this for initialization
    //void Start()
    //{
    //}

    //加入场景 replace=true 替换上一层。replace=false 直接叠加一层。
    public static UILogin AddNew(bool replace = false)
    {
        UILogin s_UITongtiantaView = (UILogin)UILayerManage.getInstance().CreateAndAdd(new UILogin(), "UILogin", replace);

        return(s_UITongtiantaView);
    }
Exemplo n.º 11
0
    //// Use this for initialization
    //void Start () {

    //}

    //// Update is called once per frame
    //void Update () {

    //}

    //void Awake()
    //{
    //    UIComponent netWork = gameObject.GetComponent<UIComponent>();

    //    netWork.onEnter = OnEnterkkk;

    //    netWork.onExit = OnExitkkk;

    //    //
    //    UIEventListener.Get(netWork.objMap["getTestBnt0"]).onClick += preFireBnt;
    //    UIEventListener.Get(netWork.objMap["getTestBnt1"]).onClick += preFireBnt;
    //    UIEventListener.Get(netWork.objMap["getTestBnt2"]).onClick += preFireBnt;
    //}

    //加入场景 replace=true 替换上一层。replace=false 直接叠加一层。
    public static UIHeroUP AddNew(bool replace = false)
    {
        UIHeroUP s_UIHeroUP = (UIHeroUP)UILayerManage.getInstance().CreateAndAdd(new UIHeroUP(), "UIHeroUP", replace);

        return(s_UIHeroUP);
    }