// Update is called once per frame protected override void Update() { //Debug.Log("hp : " + hp + " enabled : " + actionEnabled); base.Update(); if (!actionEnabled) { return; } laserTimer.TimeUpdate(Time.deltaTime); if (!laserTimer.IsTimeout()) { return; } if (ActionInput.GetButton(ButtonCode.Jump)) { if (!chargeEffect.activeSelf) { chargeEffect.SetActive(true); } charge = Mathf.Min(charge + chargeSpeed * Time.deltaTime, chargeMax); if (charge >= chargeLaserBorder && !chargeMaxEffect.activeSelf) { chargeMaxEffect.SetActive(true); } } else if (ActionInput.GetButtonUp(ButtonCode.Jump)) { if (charge >= chargeLaserBorder) { CreateChargeLaser(); chargeMaxEffect.SetActive(false); } else { CreateNormalLaser(); } charge = 0f; chargeEffect.SetActive(false); laserTimer.TimeReset(); } if (isDead) { GameOver(); } }
OnSelected SetSE() { return(() => { if (ActionInput.GetButton(ButtonCode.RightArrow)) { seVol++; seVol = Mathf.Min(seVol, 20); audioMixer.SetFloat("SEVol", seVol); } if (ActionInput.GetButton(ButtonCode.LeftArrow)) { seVol--; seVol = Math.Max(seVol, -80); audioMixer.SetFloat("SEVol", seVol); } titleUi.text = "おんりょうせってい … <sprite=7>でへんこう\n全体 < " + (masterVol + 80) + " >\nBGM < " + (bgmVol + 80) + " >\nこうかおん < " + (seVol + 80) + " >\n元にもどす"; }); }
// Update is called once per frame void Update() { AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0); if (ActionInput.GetButton(ButtonCode.RightArrow) && !isSquat) { power.x += accelVx * Time.deltaTime * 60; if (power.x > maxVx) { power.x -= accelVx * Time.deltaTime * 60; power.x = Mathf.Max(power.x, maxVx); } else { power.x = Mathf.Min(power.x, maxVx); } direction = 1; } else if (ActionInput.GetButton(ButtonCode.LeftArrow) && !isSquat) { power.x -= accelVx * Time.deltaTime * 60; if (power.x < -maxVx) { power.x += accelVx * Time.deltaTime * 60; power.x = Mathf.Min(power.x, -maxVx); } else { power.x = Mathf.Max(power.x, -maxVx); } direction = -1; } else { if (isGround) { if (power.x > 0) { power.x -= accelVx * 2 * Time.deltaTime * 60; power.x = Mathf.Max(0, power.x); } else if (power.x < 0) { power.x += accelVx * 2 * Time.deltaTime * 60; power.x = Mathf.Min(0, power.x); } } else { //スピードが早すぎるときは減速しない if (Mathf.Abs(power.x) < maxVx * 2) { if (power.x > 0) { power.x -= accelVx * Time.deltaTime * 60; power.x = Mathf.Max(0, power.x); } else if (power.x < 0) { power.x += accelVx * Time.deltaTime * 60; power.x = Mathf.Min(0, power.x); } } } } //スピードが早いときは減速しない if (Mathf.Abs(power.x) < maxVx) { if (power.x > maxVx) { power.x -= accelVx * Time.deltaTime * 60; power.x = Mathf.Max(power.x, maxVx); } else if (power.x < -maxVx) { power.x += accelVx * Time.deltaTime * 60; power.x = Mathf.Min(power.x, -maxVx); } } //風 if (wind != null) { //power.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 00.5f; gravity = defaultGravity - Mathf.Sin((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.02f; } transform.localScale = new Vector3( defaultScaleX * direction, transform.localScale.y, transform.localScale.x); isSquat = stateInfo.IsName("squat"); if (ActionInput.GetButton(ButtonCode.DownArrow)) { animator.SetBool("squat", true); } else { animator.SetBool("squat", false); } if (isContactRight) { power.x = Mathf.Min(power.x, 0); } if (isContactLeft) { power.x = Mathf.Max(power.x, 0); } if (ActionInput.GetButtonDown(ButtonCode.Jump) && jumpEnabled) { if (!isGround) { airJumpTimes--; if (airJumpTimes <= 0) { jumpEnabled = false; } } isJumping = true; jumpFrames = defaultJumpFrames; power.y = maxVy; isGround = false; animator.SetBool("Jump", true); // tada //音 audioSource.PlayOneShot(jumpSE); //エフェクト JumpEffFire(); } if (isGround) { airJumpTimes = defaultAirJumpTimes; jumpEnabled = true; jumpCooltime = jumpDefaultCooltime; isJumping = false; jumpFrames = defaultJumpFrames; power.y = 0; animator.SetBool("Jump", false); // tada if (power.magnitude < 0.01f) { v = Vector2.zero; } v = Vector3.ProjectOnPlane(power, groundNormal); //風 if (wind != null) { v.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.1f; } v.x = Mathf.Clamp(v.x, -maxVx * 2, maxVx * 2); Debug.DrawRay(groundPoint, groundNormal, Color.red); //Debug.DrawRay(groundPoint, v, Color.red); } else { //ジャンプ if (jumpCooltime > 0) { jumpCooltime -= Time.deltaTime; } else { if (airJumpTimes == 0) { jumpEnabled = false; } } if (isJumping && jumpFrames > 0) { if (ActionInput.GetButtonDown(ButtonCode.Jump)) { animator.Play("PlayerJump", 0, 0.0f); // tada //音 audioSource.PlayOneShot(jumpSE); } if (ActionInput.GetButton(ButtonCode.Jump)) { jumpFrames -= Time.deltaTime; power.y = maxVy; isGround = false; } else { isJumping = false; } } else { power.y += gravity * Time.deltaTime * 60; } power.y = Mathf.Clamp(power.y, -maxVy, maxVy * 2); v = power; //風 if (wind != null) { v.x += -Mathf.Cos((ActionInput.GetJoyconVector().y + 90) * Mathf.Deg2Rad) * 0.25f; } v.x = Mathf.Clamp(v.x, -maxVx * 2, maxVx * 2); } isMoving = Mathf.Abs(power.x) > 0; //エフェクト if ((isGround && !oldIsGround) || (isGround && !asikemuri.isPlaying && isMoving)) { asikemuri.Play(); } if ((!isGround && oldIsGround) || (isGround && asikemuri.isPlaying && !isMoving)) { asikemuri.Stop(); } if (isGround && !oldIsGround) { LaundEffFire(); } if (isGround && v.magnitude > 0) { //audioSource.clip = ashiSE; //audioSource.Play(); } else { //audioSource.clip = null; //audioSource.Stop(); } //地面に付いてるか保存 oldIsGround = isGround; oldIsMoving = isMoving; //rb.velocity = v + rv; rb.MovePosition(transform.position + (Vector3)v * Time.deltaTime * 60); //rv = Vector2.zero; //rv = Vector2.zero; //transform.position += (Vector3)v; Debug.DrawRay(transform.position, v * Time.deltaTime * 60, Color.white); //Debug.Log("速さ:"+v.magnitude); // tada animator.SetFloat("MoveSpeed", Mathf.Abs(v.x)); }