public void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { foreach (GameObject UI_Object in UI_Objects) { UI_Object.SetActive(false); } } if (SofaPickUp && Input.GetKeyDown("e") && Player.position.x <= 5 && Player.position.x >= -5 && Player.position.y <= 2.5 && Player.position.y >= -3) { sofa.SetActive(true); Sofa.position = Player.position; Vector3 placevector = Sofa.position; if (Player.position.y > 2) { placevector.y = placevector.y - 1; } else { placevector.y = placevector.y + 1; } Player.position = placevector; SofaPickUp = false; } }
public void ClosePanel() { foreach (GameObject UI_Object in UI_Objects) { UI_Object.SetActive(false); } }
public override State Execute() { UI_Object item = DeviceToRelease.GetComponent <UI_Object> (); item.Action(); return(State.Suceeded); }
public override State Execute() { UI_Object item = ItemToTake.GetComponent <UI_Object> (); item.Action(); item.ChangeState(); return(State.Suceeded); }
public override State Execute() { UI_Object item = ItemToRelease.GetComponent <UI_Object> (); item.Action(); item.ChangeState(); item.PutItemAt(x, y, z); return(State.Suceeded); }
// Update is called once per frame void Update() { Vector3 mousePos = Input.mousePosition; mousePos.z = Camera.main.nearClipPlane; Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePos); RaycastHit2D hit; if (hit = Physics2D.Raycast(worldPosition, Vector3.forward, 0.01f)) { if (hit.collider) { GameObject gameObject = hit.collider.gameObject; if (gameObject.GetComponent <UI_Object>()) { UI_MouseOver = gameObject.GetComponent <UI_Object>(); } } } else { UI_MouseOver = UI_Null; } if (Input.GetMouseButton(0)) { UI_Active.WhenMouseDown(); } else if (UI_Active != UI_MouseOver) { UI_Active = UI_MouseOver; UI_Active.OnMouseOver(); } if (Input.GetMouseButtonDown(0)) { UI_Active.OnMouseClick(); } if (Input.GetMouseButtonUp(0)) { UI_Active.OnMouseUp(); } }
// Start is called before the first frame update void Start() { UI_MouseOver = UI_Null; UI_Active = UI_Null; UI_Active.OnMouseOver(); }