Beispiel #1
0
 protected override void Awake()
 {
     base.Awake();
     skillPanelView = GetView <SkillPanelView>("DesBg");
     desPanelView   = desPanel.GetComponent <SkillDetailView>();
     desClose.onClick.AddListener(CloseDesPanel);
 }
Beispiel #2
0
    private void Init()
    {
        m_SkillPanelModel = gameObject.GetComponent <SkillPanelModel>();
        m_SkillPanelView  = gameObject.GetComponent <SkillPanelView>();

        skillList        = new List <GameObject>();
        equipedSkillList = new List <GameObject>();
    }
Beispiel #3
0
    private void Init()
    {
        UICamera = GameObject.Find("UICamera").GetComponent <Camera>();
        canvas   = GameObject.Find("Canvas").GetComponent <Canvas>();

        Bind();

        for (int i = 0; i < skillPanelViews.Count; i++)
        {
            // 对每一个技能面板进行初始化
            SkillPanelView skillPanelView = skillPanelViews[i];
            BaseSkill      baseSkill      = characterMono.characterModel.BaseSkills[i];
            skillPanelView.BindingContext = new SkillPanelViewModel();
            skillPanelView.BindingContext.Modify(baseSkill);

            // 监听EventTrigger控件事件

            // 鼠标悬停事件
            var enterViewEntry = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerEnter,
            };
            enterViewEntry.callback.AddListener(eventData => {
                if (skillTipsMessageView == null)
                {
                    skillTipsMessageView = GameObject.Instantiate <SkillTipsMessageView>(skillTipsMessageViewPrefab, canvas.transform);
                    skillTipsMessageView.BindingContext = new SkillPanelViewModel();
                }

                // 设置提示窗口出现位置
                skillTipsMessageView.transform.SetParent(skillPanelView.transform);
                (skillTipsMessageView.transform as RectTransform).anchoredPosition = new Vector2((skillPanelView.transform as RectTransform).sizeDelta.x / 2, (skillPanelView.transform as RectTransform).sizeDelta.y / 2);
                skillTipsMessageView.transform.SetParent(canvas.transform);

                skillTipsMessageView.BindingContext.Modify(baseSkill);
                skillTipsMessageView.Reveal();
            });

            // 鼠标离开事件
            var exitViewEntry = new EventTrigger.Entry {
                eventID = EventTriggerType.PointerExit
            };
            exitViewEntry.callback.AddListener(eventData => {
                skillTipsMessageView.Hide(immediate: true);
            });


            // eventTrigger添加监听事件
            EventTrigger eventTrigger = skillPanelView.GetComponent <EventTrigger>();
            eventTrigger.triggers.Add(enterViewEntry);
            eventTrigger.triggers.Add(exitViewEntry);
        }

        for (int i = 0; i < skillLevelButtons.Count; i++)
        {
            Button    levelUpButtonn = skillLevelButtons[i];
            BaseSkill skill          = characterMono.characterModel.BaseSkills[i];
            levelUpButtonn.onClick.AddListener(() => {
                if (skill.NextLevelNeedHeroLevel <= character.Level && character.SkillPoint > 0)
                {
                    skill.SkillLevel     += 1;
                    character.SkillPoint -= 1;
                }
            });
        }
    }