void Update() { int powerup = squid.getPowerup(); if (powerup == 0) { source.clip = inkSound; } if (powerup == 1) { source.clip = boostSound; } if (powerup == 2) { source.Stop(); } else if (!source.isPlaying) { source.Play(); } float fire = Input.GetAxis("Fire " + squid.playerIndex) * squid.getControl(); fadeTarg = (squid.getPowerupPhase() == 2 && source.isPlaying ? fire : 0); fade += (fadeTarg - fade) / fadeDrag; source.volume = fade; source.pitch = 0.75F + fade / 4; }
void Update() { float scaleTarg = (Mathf.Abs(1.5F - squid.getPowerupPhase()) < 1 ? 1 : 0); scaleVel += (scaleTarg - scale) * scaleVelForce; scaleVel *= scaleVelDrag; scale += scaleVel; if (scale < 0) { scale = 0; } if (lastPhase != squid.getPowerupPhase() && lastPhase == 1) { scale = 1.5F; } lastPhase = squid.getPowerupPhase(); if (lastPhase == 2 && (Time.time % 1) < 0.05) { scale *= 1.05F; } panelTransform.localScale = new Vector3(scale, scale, 1); int image = squid.getPowerup(); if (squid.getPowerupPhase() == 1) { image = Mathf.FloorToInt(Time.time * 20) % 3; } if (image == 0) { panelImage.sprite = powerup1; } if (image == 1) { panelImage.sprite = powerup2; } if (image == 2) { panelImage.sprite = powerup3; } amount += (squid.getPowerupAmount() - amount) / amountDrag; panelImage.fillAmount = amount; }
void OnTriggerStay(Collider other) { if (state == 1) { SquidController squid = other.GetComponent <SquidController>(); if ((squid != null) && (squid.getPowerupPhase() == 0)) { follow = squid.gameObject; squid.givePowerup(); state = 0; cooldownStart = Time.time; fxBurst.Play(); if (squid.playerIndex == 0) { sound.PlayOneShot(redSound); } else { sound.PlayOneShot(blueSound); } } } }