using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GravityControl : MonoBehaviour {

    public GameObject level;
    public ColorRegister.Color boxColor;
    private RaycastHit upDirection;
    public LayerMask wallOnly;
    public int gravity;

    void FixedUpdate()
    {
        Physics.Raycast(transform.position, transform.up, out upDirection, Mathf.Infinity, wallOnly);
        Debug.DrawRay(transform.position, transform.up);
    }
	
	// Update is called once per frame
	//void Update () {
 //       //transform.Rotate(new Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) * Time.deltaTime * speed); // rotate only by 90 degrees
 //       level.transform.rotation = transform.rotation;
 //       #region Player Control
 //       //if(Input.GetKeyDown(KeyCode.W))
 //       //{
 //       //    transform.Rotate(new Vector3(90,0,0));
 //       //}
 //       if(Input.GetKeyDown(KeyCode.Q))
 //       {
 //           transform.Rotate(new Vector3(0, 0, -90));
 //       }
 //       //else if(Input.GetKeyDown(KeyCode.S))
 //       //{
 //       //    transform.Rotate(new Vector3(-90, 0, 0));
 //       //}
 //       else if(Input.GetKeyDown(KeyCode.E))
 //       {
 //           transform.Rotate(new Vector3(0, 0, 90));
 //       }
 //       #endregion

 //       //Debug.Log(upDirection.collider.name);

 //       #region Gravity Control
 //       if (upDirection.collider != null)
 //       {
 //           if (upDirection.collider.CompareTag("UpCeiling"))
 //           {
 //               Debug.Log("Level is up facing");
 //               Physics.gravity = new Vector3(0, -gravity, 0);
 //           }
 //           else if (upDirection.collider.CompareTag("RightCeiling"))
 //           {
 //               Physics.gravity = new Vector3(-gravity, 0, 0);
 //               Debug.Log("Level is right ceiling");
 //           }
 //           else if (upDirection.collider.CompareTag("LeftCeiling"))
 //           {
 //               Physics.gravity = new Vector3(gravity, 0, 0);
 //               Debug.Log("Level is left ceiling");
 //           }
 //           else if (upDirection.collider.CompareTag("DownCeiling"))
 //           {
 //               Physics.gravity = new Vector3(0, gravity, 0);
 //               Debug.Log("Level is down facing");
 //           }
 //           else if (upDirection.collider.CompareTag("FrontCeiling"))
 //           {
 //               Physics.gravity = new Vector3(0, 0, gravity);
 //               //Debug.Log("Level is front facing");
 //           }
 //           else if (upDirection.collider.CompareTag("BackCeiling"))
 //           {
 //               Physics.gravity = new Vector3(0, 0, -gravity);
 //               //Debug.Log("Level is back facing");
 //           }
 //       }
 //       #endregion
 //   }
}
