public void getEventCollision() { Vector2 targetPos = getTargetPosition(); RaycastHit2D hit = Physics2D.Linecast(_player.transform.position, targetPos, 1 << LayerMask.NameToLayer("EventStuff")); if (hit) { if (Input.GetKeyDown(KeyCode.Space)) { GameObject target = hit.collider.gameObject; //Debug.Log(target.name); BasicStuff stuff = target.GetComponent <BasicStuff>(); if (stuff == null) { Debug.LogWarning("This stuff lost its component: " + target.name); return; } if (stuff.GetEventState() == EventState.Stop && (stuff.ID < 100 || stuff.isTool)) { stuff.dealWithEvent(_playerStuff); } else if (stuff.GetEventState() == EventState.Waiting) { stuff.waitBroken(_playerStuff); } else { _tips.setTips("什么事也没有发生"); } } } }
public void TurnGame(HumanSystem player) { pointer.transform.Rotate(Vector3.forward); float z = Mathf.Abs(pointer.transform.rotation.z % 360); if (Input.GetMouseButtonDown(0)) { if (z >= 0.9 || z <= 1) { player.heart += 33; pointer.transform.eulerAngles = new Vector3(0, 0, UnityEngine.Random.Range(-1, 1)); player.state = HumanState.isIdle; _tips.setTips("妻子心情变好了"); } turnTable.gameObject.transform.localPosition = new Vector3(99999, 0, 0); player.isTurnGame = false; } }