Пример #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);
            }
        }
Пример #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>();
 }
Пример #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);
     }
 }