Ejemplo n.º 1
0
        //// MonoBehaviour
        virtual protected void Awake()
        {
            // make a bank for each child
            this.banks = new Dictionary <string, Bank>();
            // Transform spawn = new GameObject("{Spawn}").transform;
            Transform sleep = new GameObject("{zzz}").transform;

            foreach (Transform child in transform)
            {
                BankableEntity b = child.GetComponent <BankableEntity>();
                if (b == null)
                {
                    Dj.Error("(Awake) Navdi contains non-bankable child " + child.gameObject.name);
                }
                banks.Add(b.gameObject.name, new Bank(b, new GameObject("{" + b.gameObject.name + "s}").transform, sleep));
                b.gameObject.SetActive(false);         // hide the children
            }
            Initialize();
            string init_error;

            if (!Initialize_Assert(out init_error))
            {
                throw new System.Exception("navdi2.XXI.Initialize failed: " + init_error);
            }
        }
Ejemplo n.º 2
0
 ////Unity
 public Bank(BankableEntity original, Transform spawn, Transform sleep)
 {
     this.original          = original;
     this.spawn             = spawn;
     this.sleep             = sleep;
     this.spawnedBankables  = new List <BankableEntity>();
     this.sleepingBankables = new List <BankableEntity>();
 }
Ejemplo n.º 3
0
 public bool BankableSleep(BankableEntity b)
 {
     if (spawnedBankables.Contains(b))
     {
         spawnedBankables.Remove(b);
         sleepingBankables.Add(b);
         b.transform.SetParent(sleep);
         return(true);
     }
     else
     {
         return(false);
     }
 }