// Start is called before the first frame update
 void Start()
 {
     text = GetComponent <TextMeshPro>();
     gnc  = transform.parent.GetComponent <GenericUnitController>() ?? null;
     // ChangeStateTextAndColor();
     //uc.SM.onStateChange += ChangeStateTextAndColor;
 }
Exemple #2
0
        void GetTargetAccordingToPriority()
        {
            if (TargetPriority == TargetPriority.ClosestToPathEnd)
            {
                float proximity = 999f;
                GenericUnitController t_target = null;
                foreach (var ef in TargetBank.Targets)
                {
                    if (GameObjectPool.Instance.Targetables.Contains(ef.Key))
                    {
                        if (GameObjectPool.Instance.ActiveUnits[ef.Key].PathWalker.SplineAttached)
                        {
                            float p = GameObjectPool.Instance.ActiveUnits[ef.Key].PathWalker.ProximityToPathEnd;
                            if (p < proximity)
                            {
                                t_target  = GameObjectPool.Instance.ActiveUnits[ef.Key];
                                proximity = p;
                            }
                        }
                    }
                }
                if (!t_target)
                {
                    if (!TargetBank.Targets.IsNullOrEmpty())
                    {
                        if (GameObjectPool.Instance.ActiveUnits.ContainsKey(TargetBank.Targets.Keys.First()))
                        {
                            t_target = GameObjectPool.Instance.ActiveUnits[TargetBank.Targets.Keys.First()];
                        }
                    }
                }

                UnitBattleManager.TargetUnit = t_target;
            }
        }
Exemple #3
0
    public void OnUnitEnable(GenericUnitController unit)
    {
        /*try
         * {*/
        ActiveUnits.Add(unit.name, unit);

        /*}
         * catch (Exception e)
         * {
         *  Debug.LogWarning(e.Message  + " : " + unit.name);
         * }*/

        onUnitEnable?.Invoke(unit.name);
    }
 private void Start()
 {
     gnc = GetComponent <GenericUnitController>();
     gnc.Data.DynamicData.BasePosition = transform.position;
 }