void Spray(int fluidIndex) { Smudge.SmudgeType spray = Smudge.SmudgeType.SmudgeJ; if (fluidIndex == 1) { spray = Smudge.SmudgeType.SmudgeK; } else if (fluidIndex == 2) { spray = Smudge.SmudgeType.SmudgeL; } bool inRange = sprayController.AnimateSpray(spray, (fluidRemaining[fluidIndex] > 0)); if (fluidRemaining[fluidIndex] > 0) { FloorManager.currentFloor.smudgeManager.SpraySmudge(spray); fluidRemaining[fluidIndex]--; if (fluidIndex == 0) { gaugeMoveJ.decreasing = true; } else if (fluidIndex == 1) { gaugeMoveK.decreasing = true; } else if (fluidIndex == 2) { gaugeMoveL.decreasing = true; } } // Debug.Log("After spraying, fluid of " + fluidIndex + " is " + fluidRemaining[fluidIndex]); }
void Update() { if (Input.GetKeyDown(KeyCode.Space) && CharacterMover.targeting) { wiperController.AnimateWipe(); } // Loop through J, K, L and do keydown things for (int i = 0; i < 3; i++) { // set up variables Smudge.SmudgeType spray = Smudge.SmudgeType.SmudgeJ; if (i == 0 && !Input.GetKeyDown(KeyCode.J)) { continue; } else if (i == 1) { if (!Input.GetKeyDown(KeyCode.K)) { continue; } spray = Smudge.SmudgeType.SmudgeK; } else if (i == 2) { if (!Input.GetKeyDown(KeyCode.L)) { continue; } spray = Smudge.SmudgeType.SmudgeL; } // key is down // if not refilling or cleaning up, attempt to spray if (!refilling[i] && characterMover.speedState == 0) { Spray(i); } // if refilling and above a certain point, stop refilling if (refilling[i] && fluidRemaining[i] >= 1) { refilling[i] = false; capsound.Play(); if (SmudgeManager.currentTarget == -1) { continue; // don't spray if not targeting anything } Smudge.SmudgeType target = FloorManager.currentFloor.smudgeManager.allSmudges[SmudgeManager.currentTarget].type; if (target == spray) { Spray(i); } } } }
public void SpraySmudge(Smudge.SmudgeType spray) { // spray matches exactly - neutralize perfectly if (spray == allSmudges[currentTarget].type) { allSmudges[currentTarget].Neutralize(100); return; } // spray is not an exact match - neutralize either kinda or bad int kinda = 34; int bad = 20; Smudge.SmudgeType smudge = allSmudges[currentTarget].type; Smudge.SmudgeType red = Smudge.SmudgeType.SmudgeJ; Smudge.SmudgeType yellow = Smudge.SmudgeType.SmudgeK; Smudge.SmudgeType green = Smudge.SmudgeType.SmudgeL; if (smudge == red) { if (spray == yellow) { allSmudges[currentTarget].Neutralize(kinda); } else if (spray == green) { allSmudges[currentTarget].Neutralize(bad); } } else if (smudge == yellow) { if (spray == green) { allSmudges[currentTarget].Neutralize(kinda); } else if (spray == red) { allSmudges[currentTarget].Neutralize(bad); } } if (smudge == green) { if (spray == red) { allSmudges[currentTarget].Neutralize(kinda); } else if (spray == yellow) { allSmudges[currentTarget].Neutralize(bad); } } }
// begins the spray animation process public bool AnimateSpray(Smudge.SmudgeType spray, bool showSprayParticles) { if (!CharacterMover.targeting) { return(false); } if (animating) { //animation cancel StopCoroutine(coroutine); } handRenderer.sprite = sprayBottle[spray]; // aim the spraying arm Vector3 closest = ClosestRelativeToArm(); StretchArm(closest.magnitude / 2); transform.LookAt(closest + transform.position); // spray particles if (showSprayParticles) { ParticleSystem.MainModule particlesMain = particles.main; particlesMain.startColor = sprayColor[spray]; particles.Play(); //if there's enough fluid (showSprayParticles), then play the spray sound effect if (spray == Smudge.SmudgeType.SmudgeJ || spray == Smudge.SmudgeType.SmudgeK) { // play normal sfx int choice = Random.Range(2, 4); // to allow spray1, change this to Random.Range(1, 4) if (choice == 1) { spray1.Play(); // TODO temporarily disabled until spray1 is cut shorter } else if (choice == 2) { spray2.Play(); } else if (choice == 3) { spray3.Play(); } } else if (spray == Smudge.SmudgeType.SmudgeL) { // play heavy sfx int choice = Random.Range(1, 4); if (choice == 1) { spraycreamy.Play(); } else if (choice == 2) { spraythick.Play(); } else if (choice == 3) { spraysquirt.Play(); } } } coroutine = FinishSpray(); StartCoroutine(coroutine); return(true); }