using UnityEngine;
using System.Collections;
public class PlayerControls01 : MonoBehaviour {
void Start ()
{
}
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
Debug.Log ("Mouse Down");
}
else if (Input.GetMouseButton (0))
{
Debug.Log("Mouse Move");
}
else if(Input.GetMouseButtonUp(0))
{
Debug.Log ("Mouse Up");
}
}
}
using UnityEngine;
using System.Collections;
public class PlayerControls02 : MonoBehaviour {
private Vector3 pos, oldpos;
public bool bMove = false;
private bool bPause = false;
void Start ()
{
}
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
//Debug.Log ("Mouse Down");
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Ray2D ray2D = new Ray2D(new Vector2(ray.origin.x, ray.origin.y), new Vector2(ray.direction.x, ray.direction.y));
RaycastHit2D[] hits = Physics2D.RaycastAll(ray2D.origin, ray2D.direction);
int i = 0;
while(i < hits.Length) {
RaycastHit2D hit = hits[i];
if(hit.collider.tag == "Player") {
if(!bPause) {
bMove = true;
pos = transform.position;
}
}
//Debug.Log ("Touch -> " + hit.collider.tag);
i++;
}
}
else if (Input.GetMouseButton (0))
{
if(bMove)
{
oldpos = pos;
pos = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z));
transform.position = new Vector3 (transform.position.x + (pos.x - oldpos.x),
transform.position.y + (pos.y - oldpos.y),
transform.position.z);
/*
transform.localPosition = new Vector3 (transform.localPosition.x + (pos.x - oldpos.x),
transform.localPosition.y + (pos.y - oldpos.y),
transform.localPosition.z);
*/
//Debug.Log("Mouse Move");
}
}
else if(Input.GetMouseButtonUp(0))
{
//Debug.Log ("Mouse Up");
bMove = false;
}
}
}
using UnityEngine;
using System.Collections;
public class MenuSceneController01 : MonoBehaviour
{
private bool bStart = false;
private bool bExit = false;
void Start ()
{
}
void Update ()
{
if (Input.GetMouseButtonDown (0)) {
Debug.Log ("Mouse Down");
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Ray2D ray2D = new Ray2D (new Vector2 (ray.origin.x, ray.origin.y), new Vector2 (ray.direction.x, ray.direction.y));
RaycastHit2D[] hits = Physics2D.RaycastAll (ray2D.origin, ray2D.direction);
int i = 0;
while (i < hits.Length) {
RaycastHit2D hit = hits [i];
if (hit.collider.tag == "Start") {
Debug.Log ("Mouse(Start) Down");
bStart = true;
break;
} else if (hit.collider.tag == "Exit") {
bExit = true;
break;
}
i++;
}
} else if (Input.GetMouseButton (0)) {
} else if (Input.GetMouseButtonUp (0)) {
if (bStart) {
bStart = false;
Application.LoadLevel("GameScene01");
} else if (bExit) {
bExit = false;
Application.Quit();
}
}
}
}
using UnityEngine;
using System.Collections;
public class MenuSceneController02 : MonoBehaviour
{
private bool bStart = false;
private bool bExit = false;
private Button buttonScript;
void Start ()
{
}
void Update ()
{
if (Input.GetMouseButtonDown (0)) {
Debug.Log ("Mouse Down");
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Ray2D ray2D = new Ray2D (new Vector2 (ray.origin.x, ray.origin.y), new Vector2 (ray.direction.x, ray.direction.y));
RaycastHit2D[] hits = Physics2D.RaycastAll (ray2D.origin, ray2D.direction);
int i = 0;
while (i < hits.Length) {
RaycastHit2D hit = hits [i];
if (hit.collider.tag == "Start") {
Debug.Log ("Mouse(Start) Down");
bStart = true;
buttonScript = hit.transform.GetComponent<Button>();
buttonScript.ChangeButtonImage();
break;
} else if (hit.collider.tag == "Exit") {
bExit = true;
hit.transform.GetComponent<Button>().ChangeButtonImage();
break;
}
i++;
}
} else if (Input.GetMouseButton (0)) {
} else if (Input.GetMouseButtonUp (0)) {
if (bStart) {
bStart = false;
Application.LoadLevel("GameScene01");
} else if (bExit) {
bExit = false;
Application.Quit();
}
}
}
}