예제 #1
0
 /// <summary>
 /// Moves the cube to the place vector.
 /// The vector should be a grid vector.
 /// Returns if the move was sucessful.
 /// </summary>
 public bool Move(Engine engine, Vector3 place)
 {
     if (place != GridPosition)
     {
         if (Cube.IsMoveBlockSafe(engine, place))
         {
             Cube _placeCube = Cube.IsMoveCubeSafe(engine, place);
             if (_placeCube == null)
             {
                 Mode          = CubeMode.Moving;
                 Direction     = (place * Block.Size - DrawPosition) / Speed;
                 AnimationStep = Speed;
                 GridPosition  = place;
                 return(true);
             }
             else
             {
                 FoundCollision(engine, _placeCube, Vector3.Normalize(place * Block.Size - DrawPosition));
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }