// シーン内にあるゲージを読み込む private void Start() { stateMachine.Update(); this.rigid = GetComponent <Rigidbody2D>(); speed = 100; // shotGaze=GameObject.Find("ShotGaze").GetComponent<Slider>(); enemy = GameObject.FindGameObjectWithTag("Enemy"); sound = GetComponent <AudioSource>(); //インスタンス生成 direction = Resources.Load("Direction", typeof(LineRenderer)) as LineRenderer; LineRenderer childObject = Instantiate(direction, rigid.position, Quaternion.identity); childObject.transform.parent = this.transform; direction = childObject; // direction.enabled = false; }
// Update is called once per frame void FixedUpdate() { State.Update( ); if (Input.GetMouseButton(0)) { var mouseWorldPos = MouseInWorld( ); var objlocalMouse = LocalPos(mouseWorldPos); if (name == "ZAxis") { Debug.Log(objlocalMouse); } var contain = IsInRange(objlocalMouse); if (contain) { State.SendEvent(DragInt); } else { State.SendEvent(NoDragInt); } } else { State.SendEvent(IdleInt); } StateName = State.CurrentStateName; }
// Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player"); rigid = GetComponent <Rigidbody2D>(); dir = player.transform.position - transform.position; stateMachine.Update(); //時間ないので筋肉解決 for (int i = 0; i < gimmickList.Count; i++) { if (gimmickList.Count == 1) { Instantiate(gimmickList[i], new Vector2(Random.Range(-5, -1), Random.Range(-3, 3)), Quaternion.identity); Instantiate(gimmickList[i], new Vector2(Random.Range(1, 5), Random.Range(-3, 3)), Quaternion.identity); } else if (i % 2 == 0) { Instantiate(gimmickList[i], new Vector2(Random.Range(-5, -1), Random.Range(-3, 3)), Quaternion.identity); } else if (i % 2 == 1) { Instantiate(gimmickList[i], new Vector2(Random.Range(1, 5), Random.Range(-3, 3)), Quaternion.identity); } } }
private void FixedUpdate() { State.Update( ); #if TEST_ONE_DRAGBAR if (Input.GetMouseButton(0)) { // 一番近い,距離がある程度以下のバーをドラッグ判定に // Idleでクリックしたから // Horibar上ならドラッグへ Vector3 world = MouseInWorld( ); var barLocal = BarLocalPos(world); var isInXRange = 0.0f < barLocal.x && barLocal.x < HoriLength; var isInYRange = 0.0f < barLocal.y && barLocal.y < 1.0f; if (isInYRange && isInXRange) { State.SendEvent(DragInt); } else { State.SendEvent(NoDragInt); } } else { State.SendEvent(IdleInt); } StateName = State.CurrentStateName; #endif #if TEST_ALWAYS_DRAG var mouse = Input.mousePosition; var zMouse = new Vector3(mouse.x, mouse.y, Distance(Camera.main.gameObject)); var world = Camera.main.ScreenToWorldPoint(zMouse); SetPosInWorld(world); //Debug.Log( world ); #endif }