Exemple #1
0
    public static GameObject RotateFigure(this GameObject go)
    {
        go.RotateF();
        go.CorrectPositionToBorders(
            t => t.position.y,
            (oldP, diff) => new Vector3(oldP.x, oldP.y + diff, oldP.z),
            (oldP, diff, max) => new Vector3(oldP.x, oldP.y - (diff - max), oldP.z),
            0f,
            19f);
        go.CorrectPositionToBorders(
            t => t.position.x,
            (oldP, diff) => new Vector3(oldP.x + diff, oldP.y, oldP.z),
            (oldP, diff, max) => new Vector3(oldP.x - (diff - max), oldP.y, oldP.z));

        // See if valid
        if (go.IsValidGridPos())
        {
            // It's valid. Update grid.
            go.UpdateGrid();
            RotateSound.Play();
        }
        else
        {
            // It's not valid. revert.
            go.UnRotateF();
        }

        return(go);
    }
 public void PlayRotateSound()
 {
     RotateSound.Position = TimeSpan.Zero;
     RotateSound.Play();
 }