Beispiel #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);
            }
        }
Beispiel #2
0
////INavdiEnt
        virtual public void Activated()
        {
            if (!setup)
            {
                Dj.Error("BankableEntity " + gameObject + " was Activated without being Setup first");
            }
            asleep = false;
            this.gameObject.SetActive(true);
        }
Beispiel #3
0
 ////BankableEntity: Setup, Sleep
 public void Setup()
 {
     if (setup)
     {
         Dj.Error("BankableEntity " + gameObject + " was called Setup twice in one lifetime");
     }
     setup  = true;
     sleepy = false;
 }
Beispiel #4
0
 virtual public bool Clear()
 {
     if (this.permanent)
     {
         Dj.Error("Can't Clear permanent Ents " + this); return(false);
     }
     DoEach((ent) => { ent.Deactivated(); });
     ents.Clear();
     return(true);
 }
Beispiel #5
0
 protected void BANG(D delta)
 {
     if (story == null)
     {
         Dj.Error("BasePage.BANG but story==null");
     }
     else
     {
         story.SpawnNewDelta(delta);
     }
 }
Beispiel #6
0
 virtual public bool Remove(INavdiEnt ent)
 {
     if (!this.active)
     {
         Dj.Error("Can't Remove from inactive Ents " + this); return(false);
     }
     if (this.permanent)
     {
         Dj.Error("Can't Remove from permanent Ents " + this); return(false);
     }
     if (ents.Remove(ent))
     {
         ent.Deactivated();
     }
     return(true);
 }
Beispiel #7
0
 virtual public bool Add(INavdiEnt ent)
 {
     if (!this.active && !this.permanent)
     {
         Dj.Error("Can't Add to inactive Ents " + this); return(false);
     }
     if (maxSize >= 0 && ents.Count >= maxSize)
     {
         Dj.Error("Can't Add to full Ents " + this + " (at capacity of " + maxSize + ")"); ent.Deactivated(); return(false);
     }
     if (ents.Add(ent) && this.active)
     {
         ent.Activated();
     }
     return(true);
 }
Beispiel #8
0
        public Sprite GetCharSprite(char c)
        {
            int index = alphabet.IndexOf(c);

            if (index >= 0)
            {
                if (index < this.Length)
                {
                    return(this[index]);
                }
                else
                {
                    Dj.Error("Font " + name + " index >= Length. alphabet/sprs mismatch?");
                }
            }
            return(null);
        }