Exemplo n.º 1
0
 void SelectionChangeCallback(int index, UnitTemplate target)
 {
     if (this.Index == index)
     {
         Set(Target);
     }
 }
Exemplo n.º 2
0
 void TemplateClicked(UnitUITemplate template, UnitTemplate data)
 {
     if (OnClick != null)
     {
         OnClick(template, data);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 void TemplateDragEnd(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (OnTemplateDragEnd != null)
     {
         OnTemplateDragEnd(template, unit, pointerData);
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 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");
            }
Exemplo n.º 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);
        }
Exemplo n.º 13
0
 void ListTemplateDrag(UnitUITemplate template, UnitTemplate unit, PointerEventData pointerData)
 {
     if (Instance == null)
     {
     }
     else
     {
         if (Instance.Template == template.Template)
         {
             SetTemplatePosition(pointerData);
         }
     }
 }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
        }
Exemplo n.º 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
            {
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 22
0
 void OnListUnitClicked(UnitUITemplate template, UnitTemplate data)
 {
     Context.Show(data);
 }
Exemplo n.º 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);
        }