Пример #1
0
 void SelectionChangeCallback(int index, UnitTemplate target)
 {
     if (this.Index == index)
     {
         Set(Target);
     }
 }
Пример #2
0
 void TemplateClicked(UnitUITemplate template, UnitTemplate data)
 {
     if (OnClick != null)
     {
         OnClick(template, data);
     }
 }
Пример #3
0
        public virtual Deployment Deploy(UnitTemplate data)
        {
            if (Proponent.Energy.Value < data.Deployment.Cost)
            {
                throw new Exception(Proponent.name + "Base trying to Deploy a Unit that the Proponent can't afford to spend Energy on");
            }

            if (Units.Count >= Units.Max)
            {
                throw new Exception(Proponent.name + " Base trying to deploy a Unit but it's reached it's maximum allowed units count");
            }

            Proponent.Energy.Value -= data.Deployment.Cost;

            Spawn(data);

            var deployment = new Deployment(this, data);

            Deployments.Add(deployment);

            deployment.OnCompletion += OnDeploymentComplete;

            if (OnDeployment != null)
            {
                OnDeployment(deployment);
            }

            return(deployment);
        }
Пример #4
0
 void TemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (OnTemplateDragEnd != null)
     {
         OnTemplateDragEnd(template, unit, pointerData);
     }
 }
Пример #5
0
            public Deployment(MonoBehaviour behaviour, UnitTemplate unit)
            {
                this.Unit = unit;

                Duration = Timer = unit.Deployment.Time;

                Coroutine = behaviour.StartCoroutine(Procedure());
            }
        public virtual void Set(UnitTemplate template, ItemUpgradeType type)
        {
            this.Template = template;
            this.Type     = type;

            label.text = type.DisplayName.Text;

            UpdateState();
        }
Пример #7
0
            public virtual void Set(UnitTemplate template)
            {
                FormatUpgradeLabel(power, template, Core.Items.Upgrades.Types.Common.Power, template.Attack.Power);
                FormatUpgradeLabel(range, template, Core.Items.Upgrades.Types.Common.Range, template.Attack.Range);
                FormatUpgradeLabel(defense, template, Core.Items.Upgrades.Types.Common.Defense, template.Defense);

                FormatLabel(hp, nameof(HP), template.Health);
                FormatLabel(speed, nameof(Speed), template.MovementMethod);
                FormatLabel(deploy, nameof(Deploy), template.Deployment.Time, "seconds-unit");
            }
Пример #8
0
        public virtual void Show(UnitTemplate template)
        {
            Template = template;

            Character.Set(template);

            Initial.Show();
            Upgrade.Hide();

            Show();
        }
        public virtual void Set(PlayerProponent player, UnitTemplate template)
        {
            this.Player   = player;
            this.Template = template;

            price.text = template.Deployment.Cost.ToString("N0");

            template.Icon.ApplyTo(icon);

            UpdateState();
        }
        public virtual IUnitSelectionData Find(UnitTemplate template)
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].Template == template)
                {
                    return(this[i]);
                }
            }

            return(null);
        }
        public virtual void Add(UnitTemplate template)
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i] == null)
                {
                    this[i] = template;
                    return;
                }
            }

            this[0] = template;
        }
        UnitSelectionUITemplate CreateTemplate(UnitTemplate unit, int index)
        {
            var instance = Instantiate(template, transform);

            instance.name = "Slot " + index.ToString();

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

            script.Init(index);
            script.Set(unit);

            return(script);
        }
Пример #13
0
 void ListTemplateDrag(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (Instance == null)
     {
     }
     else
     {
         if (Instance.Template == template.Template)
         {
             SetTemplatePosition(pointerData);
         }
     }
 }
Пример #14
0
        UnitUITemplate CreateTemplate(UnitTemplate data)
        {
            var instance = Instantiate(template, ScrollRect.content);

            instance.name = data.name + " Template";

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

            script.Init();
            script.Set(data);

            return(script);
        }
        public virtual void ClearAny(UnitTemplate target)
        {
            if (target == null)
            {
                return;
            }

            for (int i = 0; i < Count; i++)
            {
                if (this[i] == target)
                {
                    this[i] = null;
                }
            }
        }
Пример #16
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();
                }
            }
        }
Пример #17
0
        public virtual void Set(UnitTemplate data)
        {
            this.Template = data;

            if (data.Illustration.Sprite == null)
            {
                illustration.color = new Color(1f, 1f, 1f, 0f);
            }
            else
            {
                illustration.color = Color.white;

                illustration.sprite = data.Illustration.Sprite;
            }

            UpdateIllustration();

            UpdateState();
        }
Пример #18
0
        public override void Set(UnitTemplate data)
        {
            if (data == null)
            {
                base.Template = data;

                label.text = (Index + 1).ToString();
            }
            else
            {
                base.Set(data);
            }

            rank.gameObject.SetActive(data != null);
            icon.gameObject.SetActive(data != null);
            label.gameObject.SetActive(data == null);

            GrayscaleController.On = data == null;
        }
Пример #19
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
            {
            }
        }
Пример #20
0
        protected virtual Unit Spawn(UnitTemplate template)
        {
            var instance = Instantiate(template.Prefab, transform.position, transform.rotation);

            instance.name = template.name + " (" + Proponent.name + ")";

            instance.transform.localScale = transform.lossyScale;

            Tools.Layer.Set(instance, Proponent.Layer);

            var unit = instance.GetComponent <Unit>();

            var data = Proponent.Units.Selection.Find(template);

            unit.Configure(Proponent, data);

            if (OnSpawn != null)
            {
                OnSpawn(unit);
            }

            return(unit);
        }
 public virtual void Start(UnitTemplate target)
 {
     Template = target;
 }
Пример #22
0
 void OnListUnitClicked(UnitUITemplate template, UnitTemplate data)
 {
     Context.Show(data);
 }
Пример #23
0
 public virtual bool CanDeploy(UnitTemplate unit)
 {
     return(Units.Count < Units.Max && Proponent.Energy.Value >= unit.Deployment.Cost);
 }
        public ItemUpgradesData(UnitTemplate template, List <Element> list)
        {
            this.list = list;

            CheckDefaults(template);
        }