Ejemplo n.º 1
0
 public void CopyTo(BloxEvent ev)
 {
     Debug.Log("CopyTo", "BloxEvent", Color.yellow);
     if (Application.isPlaying)
     {
         Debug.LogError("This can't be done at runtime");
     }
     else
     {
         Debug.Log("CopyTo", "Blox", Color.yellow);
         this.Serialize();
         if (this.data == null)
         {
             this.data = new BloxEventData();
         }
         ev.ident           = this.ident;
         ev.screenName      = this.screenName;
         ev.active          = this.active;
         ev._ed_viewOffs    = Vector2.zero;
         ev.data            = this.data.Copy();
         ev.storedBlocksIdx = new List <int>();
         ev.storedBlocksIdx.AddRange(this.storedBlocksIdx);
         ev.Deserialize(this.blox);
     }
 }
Ejemplo n.º 2
0
        private void CollectBlockData(BloxBlock b, List <BloxBlock> savedBlocks, BloxEventData data)
        {
            BloxBlockData item = new BloxBlockData(b);

            savedBlocks.Add(b);
            data.blocks.Add(item);
            if (b.contextBlock != null)
            {
                this.CollectBlockData(b.contextBlock, savedBlocks, data);
            }
            if (((b.paramBlocks != null) ? b.paramBlocks.Length : 0) != 0)
            {
                for (int i = 0; i < b.paramBlocks.Length; i++)
                {
                    if (b.paramBlocks[i] != null)
                    {
                        this.CollectBlockData(b.paramBlocks[i], savedBlocks, data);
                    }
                }
            }
            if (b.firstChild != null)
            {
                for (b = b.firstChild; b != null; b = b.next)
                {
                    this.CollectBlockData(b, savedBlocks, data);
                }
            }
        }
Ejemplo n.º 3
0
 public void Serialize()
 {
     if (this._isDirty)
     {
         //Debug.Log("Serialize", "BloxEvent", Color.yellow);
         this._isDirty        = false;
         this.storedBlocksIdx = new List <int>();
         List <BloxBlock> list = new List <BloxBlock>();
         this.data = new BloxEventData();
         if (this.firstBlock != null)
         {
             this.storedBlocksIdx.Add(0);
             for (BloxBlock next = this.firstBlock; next != null; next = next.next)
             {
                 this.CollectBlockData(next, list, this.data);
             }
         }
         else
         {
             this.storedBlocksIdx.Add(-1);
         }
         for (int i = 0; i < this.unlinkedBlocks.Count; i++)
         {
             this.storedBlocksIdx.Add(list.Count);
             for (BloxBlock bloxBlock = this.unlinkedBlocks[i]; bloxBlock != null; bloxBlock = bloxBlock.next)
             {
                 this.CollectBlockData(bloxBlock, list, this.data);
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             if (list[j] != null)
             {
                 if (list[j].next != null)
                 {
                     this.data.blocks[j].next = list.IndexOf(list[j].next);
                 }
                 if (list[j].firstChild != null)
                 {
                     this.data.blocks[j].firstChild = list.IndexOf(list[j].firstChild);
                 }
                 if (list[j].contextBlock != null)
                 {
                     this.data.blocks[j].contextBlock = list.IndexOf(list[j].contextBlock);
                 }
                 if (((list[j].paramBlocks != null) ? list[j].paramBlocks.Length : 0) != 0)
                 {
                     this.data.blocks[j].paramBlocks = new int[list[j].paramBlocks.Length];
                     for (int k = 0; k < list[j].paramBlocks.Length; k++)
                     {
                         this.data.blocks[j].paramBlocks[k] = list.IndexOf(list[j].paramBlocks[k]);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        public BloxEventData Copy()
        {
            BloxEventData bloxEventData = new BloxEventData();

            for (int i = 0; i < this.blocks.Count; i++)
            {
                bloxEventData.blocks.Add(this.blocks[i].Copy());
            }
            return(bloxEventData);
        }
Ejemplo n.º 5
0
 public void Deserialize(Blox owningBlox)
 {
     this.owningBlox = owningBlox;
     if (this._isDirty)
     {
         this.Serialize();
     }
     if (this.data != null)
     {
         this.firstBlock = null;
         this.unlinkedBlocks.Clear();
         List <BloxBlock> list = new List <BloxBlock>();
         for (int i = 0; i < this.data.blocks.Count; i++)
         {
             BloxBlock item = this.data.blocks[i].CreateBlock();
             list.Add(item);
         }
         for (int j = 0; j < this.data.blocks.Count; j++)
         {
             if (this.data.blocks[j].next >= 0)
             {
                 list[j].next = list[this.data.blocks[j].next];
             }
             if (this.data.blocks[j].firstChild >= 0)
             {
                 list[j].firstChild = list[this.data.blocks[j].firstChild];
             }
             if (this.data.blocks[j].contextBlock >= 0)
             {
                 list[j].contextBlock = list[this.data.blocks[j].contextBlock];
             }
             if (this.data.blocks[j].paramBlocks.Length != 0)
             {
                 list[j].paramBlocks = new BloxBlock[this.data.blocks[j].paramBlocks.Length];
                 for (int k = 0; k < this.data.blocks[j].paramBlocks.Length; k++)
                 {
                     if (this.data.blocks[j].paramBlocks[k] >= 0)
                     {
                         list[j].paramBlocks[k] = list[this.data.blocks[j].paramBlocks[k]];
                     }
                 }
             }
         }
         if (this.storedBlocksIdx != null)
         {
             if (this.storedBlocksIdx.Count > 0 && this.storedBlocksIdx[0] >= 0)
             {
                 this.firstBlock = list[this.storedBlocksIdx[0]];
             }
             if (this.storedBlocksIdx.Count > 1)
             {
                 for (int l = 1; l < this.storedBlocksIdx.Count; l++)
                 {
                     if (this.storedBlocksIdx[l] >= 0 && this.storedBlocksIdx[l] < list.Count)
                     {
                         BloxBlock bloxBlock = list[this.storedBlocksIdx[l]];
                         if (bloxBlock != null)
                         {
                             this.unlinkedBlocks.Add(bloxBlock);
                         }
                     }
                 }
             }
         }
         if (Application.isPlaying && !Application.isEditor)
         {
             this.data            = null;
             this.storedBlocksIdx = null;
         }
     }
 }