Ejemplo n.º 1
0
 public void InitUnit(int index, Unit unit, IAm iAm)
 {
     if (unit)
     {
         unit.Init(index, iAm);
     }
     else
     {
         Debug.Log("No " + iAm.ToString() + " unit !");
     }
 }
Ejemplo n.º 2
0
 private void SetupInteligence(IAm iAm)
 {
     Intell = GetComponent <Intell>();
     if (Intell == null)
     {
         Debug.LogError("Unit has no inteligence.");
         return;
     }
     _unit.Intell = Intell;
     Intell.IAm   = iAm;
     Intell.Init(_unit);
     gameObject.tag = iAm.ToString();
 }
Ejemplo n.º 3
0
        internal static Projectile GetAvailableProjectile(
            List <Projectile> gameObjects,
            CreateProjectile createProjectile,
            Unit.OnHit onHit,
            IAm iAm,
            ref int?projectileIndex
            )
        {
            Projectile go = null;
            int        i  = 0;

            foreach (Projectile obj in gameObjects)
            {
                if (obj.Available == true)
                {
                    go = obj;
                    projectileIndex = i;
                    //Debug.Log(obj.gameObject.activeSelf + " :" + DateTime.Now);
                    break;
                }
                i++;
            }

            if (go == null)
            {
                HitArea arrowHitArea = null;
                go = createProjectile(go);
                foreach (Transform hA in go.transform)
                {
                    arrowHitArea = hA.GetComponent <HitArea>();
                    if (arrowHitArea != null)
                    {
                        break;
                    }
                }
                if (arrowHitArea != null)
                {
                    arrowHitArea.Init(onHit, iAm.ToString(), isProjectile: true, projectile: go);
                }

                return(go);
            }
            else
            {
                return(null);
            }
        }