void Start() { timeElapsed = 0; currentMode = lastMode = this.GetComponent <GhostSpecialization> ().GetStartMode(); this.GetComponent <Renderer> ().material.shader = Shader.Find("Transparent/Diffuse"); }
public void Reset() { this.GetComponent <Renderer> ().material.color = this.GetComponent <GhostSpecialization> ().GetBaseColor(); lastDirection = GameController.direction.kLeft; currentMode = lastMode = this.GetComponent <GhostSpecialization> ().GetStartMode(); transform.localScale = Vector3.one; timeElapsed = 0; }
public void Kill() { Color currColor = Color.white; currColor.a = 0.5f; this.transform.localScale = Vector3.one * 0.5f; this.GetComponent <Renderer> ().material.color = currColor; currentMode = ghostMode.kDead; }
public void StartPowerup() { if (currentMode == ghostMode.kDead || currentMode == ghostMode.kInHouse || currentMode == ghostMode.kLeavingHouse) { return; } this.GetComponent <Renderer> ().material.color = new Color(0.5f, 0.5f, 1.0f); lastMode = currentMode; currentMode = ghostMode.kFrightened; }
public void EndPowerup() { if (currentMode == ghostMode.kDead || currentMode == ghostMode.kInHouse || currentMode == ghostMode.kLeavingHouse) { return; } this.GetComponent <Renderer> ().material.color = this.GetComponent <GhostSpecialization> ().GetBaseColor(); lastMode = currentMode; currentMode = ghostMode.kScatter; timeElapsed = 0; }
public void EndPowerup() { if (currentMode == ghostMode.kDead || currentMode == ghostMode.kInHouse || currentMode == ghostMode.kLeavingHouse) { return; } this.GetComponent <Renderer> ().material.color = this.GetComponent <GhostSpecialization> ().GetBaseColor(); lastMode = currentMode; //currentMode = // What mode do you change to? currentMode = ghostMode.kChase; timeElapsed = 0; }
public GameController.direction GetAction(GameMaze m, GameController c, xyLoc myLoc) { timeElapsed += Time.deltaTime; // Ghosts are forced to reverse direction by the system anytime the mode changes from: // chase-to-scatter // chase-to-frightened // scatter-to-chase // scatter-to-frightened if ((lastMode == ghostMode.kChase && currentMode == ghostMode.kScatter) || (lastMode == ghostMode.kChase && currentMode == ghostMode.kFrightened) || (lastMode == ghostMode.kScatter && currentMode == ghostMode.kChase) || (lastMode == ghostMode.kScatter && currentMode == ghostMode.kFrightened)) { lastMode = currentMode; lastDirection = c.InvertDirection(lastDirection); return(lastDirection); } if (!c.AtIntersection(myLoc)) { return(lastDirection); } GameController.direction forbiddenDirection = c.InvertDirection(lastDirection); int targetx, targety; switch (currentMode) { case ghostMode.kChase: if (timeElapsed >= 20) // Implement: when do you leave chase mode? { lastMode = currentMode; //currentMode = // What mode do you change to? currentMode = ghostMode.kScatter; timeElapsed = 0; } GetTarget(out targetx, out targety, c); lastDirection = MoveToTarget(targetx, targety, myLoc, forbiddenDirection, c); return(lastDirection); case ghostMode.kScatter: if (timeElapsed >= 7) // Implement: when do you leave chase mode? { lastMode = currentMode; //currentMode = // What mode do you change to? currentMode = ghostMode.kChase; timeElapsed = 0; } GetTarget(out targetx, out targety, c); lastDirection = MoveToTarget(targetx, targety, myLoc, forbiddenDirection, c); return(lastDirection); case ghostMode.kDead: GetTarget(out targetx, out targety, c); // Reached home location if (myLoc.x / 8 == targetx && myLoc.y / 8 == targety) { lastMode = currentMode; //currentMode = // What mode do you change to? Debug.Log("Reached target from death"); currentMode = ghostMode.kChase; this.GetComponent <Renderer> ().material.color = this.GetComponent <GhostSpecialization> ().GetBaseColor(); this.transform.localScale = Vector3.one; timeElapsed = 0; } else { lastDirection = MoveToTarget(targetx, targety, myLoc, forbiddenDirection, c); } return(lastDirection); case ghostMode.kFrightened: lastDirection = MakeRandomAction(myLoc, forbiddenDirection, c); return(lastDirection); case ghostMode.kLeavingHouse: // Ready to leave home area GetTarget(out targetx, out targety, c); if (myLoc.x / 8 == targetx && myLoc.y / 8 == targety) { lastMode = currentMode; //currentMode = // What mode do you change to? currentMode = ghostMode.kScatter; timeElapsed = 0; } else { lastDirection = MoveToTarget(targetx, targety, myLoc, forbiddenDirection, c); } return(lastDirection); case ghostMode.kInHouse: if (timeElapsed > this.GetComponent <GhostSpecialization> ().GetStartDelay()) { lastMode = currentMode; //currentMode = // What mode do you change to? currentMode = ghostMode.kLeavingHouse; timeElapsed = 0; } break; } // Should never get here return(GameController.direction.kNone); }