Beispiel #1
0
    public void RemoveVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback)
    {
        if (_animDic.ContainsKey(voxel.Pos))
        {
            AnimTuple anim = _animDic[voxel.Pos];
            anim.Trans.GetComponent<MeshRenderer>().material.color = voxel.Color;
            anim.Trans.GetComponent<DummyBehavior>().StopAllCoroutines();
            anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
            {
                finishCallback();
            }));
        }
        else
        {
            if (hasPreviousBlock)
            {
                AnimTuple anim = new AnimTuple();
                _animDic[voxel.Pos] = anim;
                anim.Trans = CreateAnimTransform(voxel);
                anim.Trans.localScale = Vector3.one;
                anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
                {
                    finishCallback();
                }));

            }
        }
    }
Beispiel #2
0
 public void RemoveVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback)
 {
     if (_animDic.ContainsKey(voxel.Pos))
     {
         AnimTuple anim = _animDic[voxel.Pos];
         anim.Trans.GetComponent <MeshRenderer>().material.color = voxel.Color;
         anim.Trans.GetComponent <DummyBehavior>().StopAllCoroutines();
         anim.Cor = anim.Trans.GetComponent <DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
         {
             finishCallback();
         }));
     }
     else
     {
         if (hasPreviousBlock)
         {
             AnimTuple anim = new AnimTuple();
             _animDic[voxel.Pos]   = anim;
             anim.Trans            = CreateAnimTransform(voxel);
             anim.Trans.localScale = Vector3.one;
             anim.Cor = anim.Trans.GetComponent <DummyBehavior>().StartCoroutine(RemoveVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
             {
                 finishCallback();
             }));
         }
     }
 }
Beispiel #3
0
 public void AddVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback, bool firstTime = true)
 {
     if (_animDic.ContainsKey(voxel.Pos) && firstTime) // Animation going on at this point
     {
         RemoveVoxelAnimation(hasPreviousBlock, voxel, () =>
         {
             AddVoxelAnimation(false, voxel, () =>
             {
                 finishCallback();
             }, false);
         });
     }
     else if (_animDic.ContainsKey(voxel.Pos))
     {
         AnimTuple anim = _animDic[voxel.Pos];
         anim.Trans.GetComponent<MeshRenderer>().material.color = voxel.Color;
         anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(AddVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
         {
             finishCallback();
         }));
     }
     else // No animation going on at this point
     {
         if (hasPreviousBlock)
         {
             RemoveVoxelAnimation(hasPreviousBlock, voxel, () =>
             {
                 AddVoxelAnimation(false, voxel, () =>
                 {
                     finishCallback();
                 }, false);
             });
         }
         else
         {
             AnimTuple anim = new AnimTuple();
             _animDic[voxel.Pos] = anim;
             anim.Trans = CreateAnimTransform(voxel);
             anim.Cor = anim.Trans.GetComponent<DummyBehavior>().StartCoroutine(AddVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
             {
                 finishCallback();
             }));
         }
     }
 }
Beispiel #4
0
 public void AddVoxelAnimation(bool hasPreviousBlock, Voxel voxel, Action finishCallback, bool firstTime = true)
 {
     if (_animDic.ContainsKey(voxel.Pos) && firstTime) // Animation going on at this point
     {
         RemoveVoxelAnimation(hasPreviousBlock, voxel, () =>
         {
             AddVoxelAnimation(false, voxel, () =>
             {
                 finishCallback();
             }, false);
         });
     }
     else if (_animDic.ContainsKey(voxel.Pos))
     {
         AnimTuple anim = _animDic[voxel.Pos];
         anim.Trans.GetComponent <MeshRenderer>().material.color = voxel.Color;
         anim.Cor = anim.Trans.GetComponent <DummyBehavior>().StartCoroutine(AddVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
         {
             finishCallback();
         }));
     }
     else // No animation going on at this point
     {
         if (hasPreviousBlock)
         {
             RemoveVoxelAnimation(hasPreviousBlock, voxel, () =>
             {
                 AddVoxelAnimation(false, voxel, () =>
                 {
                     finishCallback();
                 }, false);
             });
         }
         else
         {
             AnimTuple anim = new AnimTuple();
             _animDic[voxel.Pos] = anim;
             anim.Trans          = CreateAnimTransform(voxel);
             anim.Cor            = anim.Trans.GetComponent <DummyBehavior>().StartCoroutine(AddVoxelAnimationCor(voxel.Pos, anim.Trans, () =>
             {
                 finishCallback();
             }));
         }
     }
 }