Ejemplo n.º 1
0
    public void ShowDetail(SpecilistView vv)
    {
        int idx = view.avalableList.IndexOf(vv);

        if (idx != -1)
        {
            Tezhi tezhi = model.availabelTezhi [idx];
            ShowDetail(tezhi);
        }
    }
Ejemplo n.º 2
0
    public void RegisterAsAvailable(SpecilistView vv)
    {
        DragEventListener listener = vv.root.GetComponent <DragEventListener> ();

        if (listener == null)
        {
            Debug.Log("error");
            return;
        }
        listener.ClearDragEvent();
        listener.ClearClickEvent();

        listener.OnClickEvent += delegate(PointerEventData eventData) {
            ShowDetail(vv);
        };

        listener.OnBeginDragEvent += delegate(PointerEventData eventData) {
            vv.root.SetParent(root, true);
        };
        listener.OnDragEvent += delegate(PointerEventData eventData) {
            vv.root.position = mUIMgr.GetWorldPosition(eventData.position);
        };
        listener.OnEndDragEvent += delegate(PointerEventData eventData) {
            List <RaycastResult> results = new List <RaycastResult> ();
            bool used = false;
            EventSystem.current.RaycastAll(eventData, results);
            foreach (RaycastResult ret in results)
            {
                if (ret.gameObject != null)
                {
                    if (ret.gameObject == view.PosSkillContainer.gameObject)
                    {
                        vv.root.SetParent(view.PosSkillContainer, false);
                        used = true;
                        RegisterAsChoosed(vv);
                        model.selectedOne.Add(view.avalableList.IndexOf(vv));
                    }
                }
            }
            if (!used)
            {
                vv.root.SetParent(view.AvailableContainer, false);
            }
        };
    }
Ejemplo n.º 3
0
    public void RegisterAsChoosed(SpecilistView vv)
    {
        DragEventListener listener = vv.root.GetComponent <DragEventListener> ();

        if (listener == null)
        {
            Debug.Log("error");
            return;
        }
        listener.ClearClickEvent();
        listener.ClearDragEvent();
        listener.OnClickEvent += delegate(PointerEventData eventData) {
            vv.root.SetParent(view.AvailableContainer, false);
            RegisterAsAvailable(vv);
            vv.selected = false;
            model.selectedOne.Remove(view.avalableList.IndexOf(vv));
        };
    }
Ejemplo n.º 4
0
    public override void BindView()
    {
        if (root == null)
        {
            Debug.Log("bind fail no root found");
        }
        view.NextStage = root.Find("NextStage").GetComponent <Button>();

        view.SKillLeft = root.Find("Text_Left").GetComponent <Text> ();
        view.PointLeft = root.Find("属性调整").GetChild(0).GetChild(1).GetComponent <Text> ();

        view.SKillLeft.text = model.LeftSkillPoint + "";
        view.PointLeft.text = model.LeftPoint + "";

        view.PosSkillContainer  = root.Find("已选优势");
        view.AvailableContainer = root.Find("可选特质").GetChild(1).GetChild(0).GetChild(0);

        view.DetailName = root.Find("SpeDetail").GetChild(0).GetComponent <Text>();
        view.DetailDesp = root.Find("SpeDetail").GetChild(1).GetComponent <Text>();


        Transform pRoot = root.Find("属性调整").GetChild(1);

        foreach (Transform child in pRoot)
        {
            BasePropertyLineView vv = new BasePropertyLineView();
            vv.BindView(child);
            vv.BaseValue.text = model.bas[child.GetSiblingIndex()] + "";
            view.baseLines.Add(vv);
        }

        foreach (Tezhi tezhi in model.availabelTezhi)
        {
            GameObject    go = GameMain.GetInstance().GetModule <ResLoader>().Instantiate("UI/AvailableTezhi", view.AvailableContainer);
            SpecilistView vv = new SpecilistView();
            vv.BindView(go.transform);
            vv.Name.text = tezhi.Name;
            view.avalableList.Add(vv);
        }
    }
Ejemplo n.º 5
0
    public override void RegisterEvent()
    {
        view.NextStage.onClick.AddListener(delegate() {
            mUIMgr.CloseCertainPanel(this);
            SetupPlayerInfo();
            GameMain.GetInstance().GetModule <CoreManager>().ChangeScene("Main", delegate {
                ICoreManager cm = GameMain.GetInstance().GetModule <CoreManager>();
                MainGameMode gm = cm.GetGameMode() as MainGameMode;
                gm.NextTurn();
            });

            //mUIMgr.ShowPanel("UIMain");
        });

        for (int i = 0; i < view.avalableList.Count; i++)
        {
            DragEventListener listener = view.avalableList[i].root.gameObject.GetComponent <DragEventListener>();
            if (listener == null)
            {
                listener = view.avalableList[i].root.gameObject.AddComponent <DragEventListener>();
                SpecilistView speView = view.avalableList [i];
                //GameObject go = view.avalableList [i].root.gameObject;
                RegisterAsAvailable(speView);
            }
        }

        foreach (BasePropertyLineView vv in view.baseLines)
        {
            BasePropertyLineView nowV = vv;
            int idx = view.baseLines.IndexOf(nowV);
            {
                ClickEventListerner listener = vv.AddButton.gameObject.GetComponent <ClickEventListerner>();
                if (listener == null)
                {
                    listener = vv.AddButton.gameObject.AddComponent <ClickEventListerner>();
                    listener.OnClickEvent += delegate(PointerEventData eventData) {
                        if (model.LeftPoint <= 0)
                        {
                            return;
                        }
                        model.LeftPoint--;
                        model.extra[idx]++;
                        view.PointLeft.text = model.LeftPoint + "";
                        view.baseLines[idx].ExtraValue.text = model.extra[idx] + "";
                    };
                }
            }
            {
                ClickEventListerner listener = vv.MinusButton.gameObject.GetComponent <ClickEventListerner>();
                if (listener == null)
                {
                    listener = vv.MinusButton.gameObject.AddComponent <ClickEventListerner>();
                    listener.OnClickEvent += delegate(PointerEventData eventData) {
                        if (model.extra[idx] <= 0)
                        {
                            return;
                        }
                        model.LeftPoint++;
                        model.extra[idx]--;
                        view.PointLeft.text = model.LeftPoint + "";
                        view.baseLines[idx].ExtraValue.text = model.extra[idx] + "";
                    };
                }
            }
        }
    }
Ejemplo n.º 6
0
    public override void RegisterEvent()
    {
        view.NextStage.onClick.AddListener(delegate() {
            mUIMgr.CloseCertainPanel(this);
            SetupPlayerInfo();

            MainGMInitData data = new MainGMInitData();
            data.isNextTurn     = true;
            GameMain.GetInstance().GetModule <CoreManager>().ChangeScene("Main", data);

            //mUIMgr.ShowPanel("UIMain");
        });

        for (int i = 0; i < view.avalableList.Count; i++)
        {
            DragEventListener listener = view.avalableList[i].root.gameObject.GetComponent <DragEventListener>();
            if (listener == null)
            {
                listener = view.avalableList[i].root.gameObject.AddComponent <DragEventListener>();
                SpecilistView speView = view.avalableList [i];
                //GameObject go = view.avalableList [i].root.gameObject;
                RegisterAsAvailable(speView);
            }
        }

        foreach (BasePropertyLineView vv in view.baseLines)
        {
            BasePropertyLineView nowV = vv;
            int idx = view.baseLines.IndexOf(nowV);
            {
                //Debug.Log(idx + ":" + nowV.root.name);
                ClickEventListerner listener = vv.AddButton.gameObject.GetComponent <ClickEventListerner>();
                if (listener == null)
                {
                    listener = vv.AddButton.gameObject.AddComponent <ClickEventListerner>();

                    listener.OnClickEvent += delegate(PointerEventData eventData) {
                        if (model.LeftPoint <= 0)
                        {
                            return;
                        }
                        if (model.extra[idx] >= RELOCATE_LIMIT)
                        {
                            view.WarningMsg.gameObject.SetActive(true);
                            return;
                        }
                        else
                        {
                            view.WarningMsg.gameObject.SetActive(false);
                        }

                        Debug.Log("+++++");
                        model.LeftPoint--;
                        model.extra[idx]++;
                        view.PointLeft.text = model.LeftPoint + "";
                        view.baseLines[idx].BaseValue.text = model.bas[idx] + model.extra[idx] + "";
                    };
                }
            }
            {
                ClickEventListerner listener = vv.MinusButton.gameObject.GetComponent <ClickEventListerner>();
                if (listener == null)
                {
                    listener = vv.MinusButton.gameObject.AddComponent <ClickEventListerner>();
                    listener.OnClickEvent += delegate(PointerEventData eventData) {
                        if (model.extra[idx] > RELOCATE_LIMIT)
                        {
                            return;
                        }
                        if (model.extra[idx] <= 0)
                        {
                            return;
                        }
                        {
                            view.WarningMsg.gameObject.SetActive(false);
                        }

                        Debug.Log("-----");
                        model.LeftPoint++;
                        model.extra[idx]--;
                        view.PointLeft.text = model.LeftPoint + "";
                        view.baseLines[idx].BaseValue.text = model.bas[idx] + model.extra[idx] + "";
                    };
                }
            }
        }

        view.Next_Button.onClick.AddListener(delegate() {
            if (cur_section == 3)
            {
                mUIMgr.CloseCertainPanel(this);
                SetupPlayerInfo();

                MainGMInitData data = new MainGMInitData();
                data.isNextTurn     = true;
                GameMain.GetInstance().GetModule <CoreManager>().ChangeScene("Main", data);
            }
            else
            {
                ShowNextSection();
                if (cur_section == 2)
                {
                    view.Back_Button.gameObject.SetActive(true);
                }
                if (cur_section == 3)
                {
                    view.WarningMsg.gameObject.SetActive(false);
                    view.Next_Button.GetComponent <Image>().sprite = pResMgr.LoadResource <Sprite>("Adjust/AdjustButton/go_stage");
                }
            }
        });

        view.Back_Button.onClick.AddListener(delegate() {
            ShowLastSection();
            if (cur_section == 1)
            {
                view.Back_Button.gameObject.SetActive(false);
            }
            view.Next_Button.GetComponent <Image>().sprite = pResMgr.LoadResource <Sprite>("Adjust/AdjustButton/go_next");
        });
    }