Esempio n. 1
0
    void OnClickGame(GameObject games)
    {
        ActivityDataInfo SerData = UIEventListener.Get(games).parameter as ActivityDataInfo;

        if (SerData.State == ActivityState.NOTATTHE && SerData.UpDateTime > 0)
        {
            GameCenter.messageMng.AddClientMsg(173);
            return;
        }
        if (SerData.Buttontype.Count > 1)
        {
            GameCenter.activityMng.OpenStartSeleteActivity(SerData.ID);
        }
        else
        {
            ActivityButtonRef refdata = ConfigMng.Instance.GetActivityButtonRef(SerData.Buttontype[0]);
            GameCenter.activityMng.GoActivityButtonFunc(refdata, (int)SerData.ID);
        }
    }
Esempio n. 2
0
    void Awake()
    {
        mutualExclusion = true;
        Layer           = GUIZLayer.TOPWINDOW;
        if (btnClose != null)
        {
            UIEventListener.Get(btnClose).onClick = delegate {
                Invoke("InvokeClose", 0.1f);
            }
        }
        ;
        if (activityItem != null)
        {
            activityItem.SetActive(false);
            ActivityItemUI item = activityItem.GetComponent <ActivityItemUI>();
            if (item != null)
            {
                inItemList.Add(item);
            }
        }
        //view = this.item.transform.parent.GetComponent<UIScrollView>();
        GameCenter.activityMng.C2S_ActivityDataInfo();
        //Awake的时候 获取一下初始位置和Clipping Offect
        if (activityInfomation != null)
        {
            position = activityInfomation.transform.position;
            panel    = activityInfomation.GetComponent <UIPanel>();
            if (panel != null)
            {
                offect = panel.clipOffset;
            }
            else
            {
                Debug.LogError("名为" + activityInfomation.gameObject.name + "的预制上没有UIPanel组件");
            }
        }
    }

    void InvokeClose()
    {
        GameCenter.uIMng.SwitchToUI(GUIType.NONE);
    }

    ActivityItemUI curData     = null;
    List <GameObject> listItem = new List <GameObject>();
    void ShowItems()
    {
        for (int i = 0; i < inItemList.Count; i++)
        {
            UIToggle tog = inItemList[i].GetComponent <UIToggle>();
            if (tog != null && tog.value)
            {
                curData = inItemList[i];
                break;
            }
        }
        if (curData == null || curData.SetData == null)
        {
            return;
        }
        if (aName != null)
        {
            aName.text = curData.SetData.title;
        }
        if (aitemDes != null)
        {
            aitemDes.text = curData.SetData.rewardres;
        }
        if (aDes != null)
        {
            aDes.text = curData.SetData.res.Replace("\\n", "\n");
        }

        if (item == null)
        {
            return;
        }
        int j = 0, len = 0;

        for (int m = 0; m < curData.SetData.rewarditem.Count; m++)
        {
            if (curData.SetData.rewarditem[m] != 0)
            {
                len++;
            }
        }
        GameObject go = null;

        for (; j < len; j++)
        {
            if (listItem.Count <= j)
            {
                go = UIUtil.CreateItemUIGame(item);
                go.transform.localPosition = Vector3.zero;
                go.transform.localScale    = Vector3.one;
                listItem.Add(go);
            }
            else
            {
                go = listItem[j];
            }
            ItemUI itemui = go.GetComponent <ItemUI>();
            if (itemui != null)
            {
                itemui.FillInfo(new EquipmentInfo(curData.SetData.rewarditem[j], EquipmentBelongTo.PREVIEW));
            }
            go.SetActive(true);
        }
        for (; j < listItem.Count; j++)
        {
            listItem[j].SetActive(false);
        }

        UIGrid grid = item.GetComponent <UIGrid>();

        if (grid != null)
        {
            grid.repositionNow = true;
        }

        for (int i = 0; i < btnFunc.Length; i++)
        {
            if (btnFunc[i] == null)
            {
                continue;
            }
            if (curData.SetData.buttontype.Count > i)
            {
                ActivityButtonRef refdata = ConfigMng.Instance.GetActivityButtonRef(curData.SetData.buttontype[i]);
                UILabel           lab     = btnFunc[i].GetComponentInChildren <UILabel>();
                if (lab != null)
                {
                    lab.text = refdata.name;
                }
                UIEventListener.Get(btnFunc[i]).onClick  -= OnClikFunc;
                UIEventListener.Get(btnFunc[i]).onClick  += OnClikFunc;
                UIEventListener.Get(btnFunc[i]).parameter = refdata;
                btnFunc[i].gameObject.SetActive(true);
            }
            else
            {
                btnFunc[i].gameObject.SetActive(false);
            }
        }
        //刷新之后初始化位置并且初始化Clipping offect
        if (activityInfomation != null && panel != null)
        {
            activityInfomation.transform.position = position;
            panel.clipOffset = offect;
        }
        else
        {
            Debug.LogError("ActivityInfomation上有组件为空");
        }
    }

    void OnClikFunc(GameObject games)
    {
        if (curData == null || curData.SetData == null)
        {
            return;
        }
        ActivityButtonRef refdata = UIEventListener.Get(games).parameter as ActivityButtonRef;

        GameCenter.activityMng.GoActivityButtonFunc(refdata, curData.SetData.id);
    }
Esempio n. 3
0
    /// <summary>
    /// 按钮功能
    /// </summary>
    public void GoActivityButtonFunc(ActivityButtonRef refdata, int id)
    {
        if (refdata == null)
        {
            return;
        }
        if (!activityDic.ContainsKey(id))
        {
            return;
        }
        if (!activityDic[id].ActivityLev)
        {
            GameCenter.messageMng.AddClientMsg(13);
            return;
        }

        ActivityType type = (ActivityType)id;

        //=============fix 完全没必要每次判断都进行一次强制转换,可以先声明一个变量,强制转换一次,然后拿该变量去判断
        if (type == ActivityType.FAIRYAUBONFIRE || type == ActivityType.FAIRYAUSHIPMENTDART ||
            type == ActivityType.FAIRYAUSIEGE || type == ActivityType.FAIRYDOMAINTOPROTECT)
        {
            if (!GameCenter.mainPlayerMng.MainPlayerInfo.HavaGuild)
            {
                GameCenter.messageMng.AddClientMsg(235);
                return;
            }
        }

        if (type == ActivityType.BATTLEFAGIHT)
        {
            GameCenter.battleFightMng.C2S_ReqFlyBattleFeild();
            return;
        }

        if (type == ActivityType.DAILYTRANSPORTDART)
        {
            GameCenter.uIMng.SwitchToUI(GUIType.NONE);
            GameCenter.activityMng.C2S_ReqDartPos(DartType.DailyDart);
            return;
        }

        if (type == ActivityType.FAIRYAUSHIPMENTDART)
        {
            GameCenter.activityMng.C2S_ReqDartPos(DartType.GuildDart);
            return;
        }
        if (type == ActivityType.FAIRYAUBONFIRE)
        {
            GameCenter.activityMng.C2S_FlyMyGuildFire();
            return;
        }
        if (type == ActivityType.UNDERBOSS)
        {
            BossChallengeWnd.OpenAndGoWndByType(BossChallengeWnd.ToggleType.UnderBoss);
            return;
        }
        if (activityDic[id].State != ActivityState.ONGOING)
        {
            GameCenter.messageMng.AddClientMsg(173);
            return;
        }
        if (type == ActivityType.RAIDERARK)
        {
            //Debug.Log("跳转夺宝奇兵界面!!!");
            GameCenter.activityMng.C2S_FlyRaiderArk();
            return;
        }

        //=============fix 没有使用枚举,而是使用魔数========
        if (refdata.type == (int)ButtonType.GUI)
        {
            GameCenter.uIMng.SwitchToUI((GUIType)Enum.Parse(typeof(GUIType), refdata.pageId));
        }
        else if (refdata.type == (int)ButtonType.FengShen)
        {
            GameCenter.activityMng.C2S_FlyFengShen(id);
        }
        else if (refdata.type == (int)ButtonType.ToPoint)
        {//寻路点
            GameCenter.taskMng.TraceToScene(refdata.mapId, new Vector3(refdata.mapXY[0], 0, refdata.mapXY[1]));
            GameCenter.curMainPlayer.GoTraceSearchTreasure();
        }
        else if (refdata.type == (int)ButtonType.subGUI)
        {
            GameCenter.uIMng.SwitchToSubUI((SubGUIType)Enum.Parse(typeof(SubGUIType), refdata.pageId));
        }
        else if (refdata.type == (int)ButtonType.fly)
        {//飞副本,
            GameCenter.mainPlayerMng.C2S_Fly_Pint(refdata.mapId, refdata.mapXY[0], refdata.mapXY[1]);
        }
        else if (refdata.type == (int)ButtonType.ToNpc)
        {//寻路NPC
            GameCenter.taskMng.PublicTraceToNpc(refdata.mapId);
            GameCenter.curMainPlayer.GoTraceSearchTreasure();
        }
    }