public void Start() { GameObject ghostBody = transform.Find(Tags.GhostBody).gameObject; bodyRenderer = ghostBody.GetComponent <Renderer>(); chaseMaterial = bodyRenderer.materials[0]; frightenedMaterial = bodyRenderer.materials[1]; materialIndex = 0; ai = GetComponent <VirusAI>(); lastState = VirusAIState.Chase; }
protected override void setAnimationState() { VirusWalker virus = walker as VirusWalker; if (virus.chase()) { if (lastState == VirusAIState.Frightened || lastState == VirusAIState.Dead) { setMaterial(0); } lastState = VirusAIState.Chase; } if (virus.scatter()) { if (lastState == VirusAIState.Frightened || lastState == VirusAIState.Dead) { setMaterial(0); } lastState = VirusAIState.Scatter; } if (virus.frightened()) { if (lastState != VirusAIState.Frightened) { setMaterial(1); } else { // 5 flashes double t = ai.remainingFrightenedTime; if (t <= 1.5) { setMaterial((int)(t / 0.15) % 2 == 0 ? 1 : 0); } } lastState = VirusAIState.Frightened; } if (virus.dead()) { if (lastState != VirusAIState.Dead) { bodyRenderer.enabled = false; GameObject.FindGameObjectWithTag("Pacman").GetComponent <RobertSounds> ().virusEaten(); } lastState = VirusAIState.Dead; } }
public float virusSpeedMultiplier(VirusAIState virusState) { if (virusState != VirusAIState.Dead) { if (_currentScene == Tags.Scene01) { return(virusState == VirusAIState.Frightened ? .4f : .75f); } if (_currentScene == Tags.Scene02) { return(virusState == VirusAIState.Frightened ? .45f : .85f); } if (_currentScene == Tags.Scene04 || _currentScene == Tags.Scene05) { return(virusState == VirusAIState.Frightened ? .5f : .95f); } } return(1f); }