示例#1
0
 void TemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (OnTemplateDragEnd != null)
     {
         OnTemplateDragEnd(template, unit, pointerData);
     }
 }
示例#2
0
 void TemplateClicked(UnitUITemplate template, UnitTemplate data)
 {
     if (OnClick != null)
     {
         OnClick(template, data);
     }
 }
示例#3
0
 void ListTemplateDrag(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (Instance == null)
     {
     }
     else
     {
         if (Instance.Template == template.Template)
         {
             SetTemplatePosition(pointerData);
         }
     }
 }
示例#4
0
        void ListTemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
        {
            if (Instance == null)
            {
            }
            else
            {
                Destroy(Instance.gameObject);
                Instance = null;

                Selection.Context.Apply();

                if (OnDragEnd != null)
                {
                    OnDragEnd();
                }
            }
        }
示例#5
0
        public override void Init()
        {
            base.Init();

            Templates = new UnitUITemplate[List.Count];

            Player.Inventory.OnUpdate += InventroyUpdateCallback;

            for (int i = 0; i < List.Count; i++)
            {
                Templates[i] = CreateTemplate(List[i]);

                Templates[i].OnClick        += TemplateClicked;
                Templates[i].DragBeginEvent += TemplateDragBegin;
                Templates[i].DragEvent      += TemplateDrag;
                Templates[i].DragEndEvent   += TemplateDragEnd;
            }

            UpdateState();
        }
示例#6
0
        UnitUITemplate CreateTemplate(UnitUITemplate source)
        {
            var instance = Instantiate(template, RectTransform);

            instance.name = source.Template.name + " Drag Template";

            var script = instance.GetComponent <UnitUITemplate>();

            script.Init();
            script.Set(source.Template);

            script.LayoutElement.ignoreLayout = true;
            script.CanvasGroup.blocksRaycasts = false;
            script.CanvasGroup.alpha          = 0.6f;

            script.Lock.Active = false;

            script.RectTransform.sizeDelta = source.RectTransform.sizeDelta * 0.8f;

            return(script);
        }
示例#7
0
        void ListTemplateDragBegin(UnitUITemplate UITemplate, UnitTemplate template, PointerEventData pointerData)
        {
            if (Instance == null)
            {
                if (Player.Inventory.Contains(template.CatalogItem))
                {
                    Selection.Context.Start(UITemplate.Template);

                    Instance = CreateTemplate(UITemplate);

                    SetTemplatePosition(pointerData);

                    if (OnDragBegin != null)
                    {
                        OnDragBegin();
                    }
                }
            }
            else
            {
            }
        }
示例#8
0
 void OnListUnitClicked(UnitUITemplate template, UnitTemplate data)
 {
     Context.Show(data);
 }