Exemple #1
0
        ///// <summary>
        ///// True if this is a leaf node,
        ///// *including if it refers to itself*,
        ///// but NOT if it is part of a cycle larger than just itself
        ///// </summary>
        ///// <returns></returns>
        //public bool IsLeaf()
        //{
        //    // bit hacky, but we might want to force
        //    // a saying to be a transition saying
        //    // even if it has children
        //    if (this.IsForcedLeaf)
        //    {
        //        return true;
        //    }

        //    return
        //    (this.NextSaying == null || this.NextSaying == this)
        //    && (this.YesSaying == null || this.YesSaying == this)
        //    && (this.NoSaying == null || this.NoSaying == this);
        //}

        /// <summary>
        /// For convenience,
        /// walk down the tree from this node
        /// and give every leaf branch found the given callback
        /// </summary>
        /// <param name="callback"></param>
        public void GiveAllEndingsCallback(ISayingCallback callback)
        {
            bool foundAnyChildren = false;

            if (this.NextSaying != null && this.NextSaying != this)
            {
                this.NextSaying.GiveAllEndingsCallback(callback);
                foundAnyChildren = true;
            }
            if (this.YesSaying != null && this.YesSaying != this)
            {
                this.YesSaying.GiveAllEndingsCallback(callback);
                foundAnyChildren = true;
            }
            if (this.NoSaying != null && this.NoSaying != this)
            {
                this.NoSaying.GiveAllEndingsCallback(callback);
                foundAnyChildren = true;
            }

            if (!foundAnyChildren)
            {
                this.sayingCallback = callback;
            }
        }
Exemple #2
0
 public Saying(string text, Font font, ISayingCallback callback)
 {
     this.Text           = text;
     this.Font           = font;
     this.sayingCallback = callback;
 }