void FixedUpdate() { State = DarthState.stoping; CheckGround(); if (Convert.ToBoolean(CnInputManager.GetAxis("Horizontal"))) { Run(); } if (isGrounded && CnInputManager.GetButtonDown("Jump")) { Jump(); } if (CnInputManager.GetButtonDown("Attack")) { Shoot(); } ////чтобы часто не стрелять //shotsTimeCounter -= Time.deltaTime; //фича высоко не прыгать if (gameObject.transform.position.y >= 5.500000F) { gameObject.transform.position = new Vector2(gameObject.transform.position.x, 5.500000F); } }
//стрельба private void Shoot() { //if (shotsTimeCounter <= 0) //{ //Vector3 position = transform.position; //position.y += 1.5F; //FireBallController newFire = Instantiate(FireBall, position, FireBall.transform.rotation) as FireBallController; //newFire.Direction = newFire.transform.right * (mySpriteRenderer.flipX ? -1.0F : 1.0F); //shotsTimeCounter = shotsTime; //} if (mySpriteRenderer.flipX == true) { //CircleColaiderLeft.GetComponent<CircleCollider2D>().enabled = true; CircleColaiderLeft.enabled = true; Invoke("OfCircleColaiderLeft", 1); } else { CircleColaiderRights.enabled = true; //CircleColaiderRights.GetComponent<CircleCollider2D>().enabled = true; Invoke("OfCircleColaiderRights", 1); } KichAudio.Play(); State = DarthState.atack; }
private void Run() { // if (isGrounded) State = DarthState.run; Vector3 position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f); transform.position += position * speed * Time.deltaTime; mySpriteRenderer.flipX = position.x < 0.0F; }