// Use this for initialization void Start() { // set initial states manager = GameObject.Find("GameManager").GetComponent<GameManagerInit>(); wheel = manager.Wheel; currentLane = Location.lane.middle; // Set initial lane SetRandomLane(); }
// Sets a random lane void SetRandomLane() { Location.lane newLane = (Location.lane)Random.Range(0, 3); // decides where the new lane will be gameObject.transform.Translate(new Vector3(9 * ((float)newLane - (float)currentLane), 0, 0)); // shift the object to the new lane currentLane = newLane; // set the current lane to be the new lane }
// Use this for initialization void Start() { stage = 0; currentLane = Location.lane.middle; // start in the middle lane timer = 0; // reset time laneTransitionTimer = 0; LANE_TRANSITION_TIME = 0.1f; playerPosition = 0; // lane 0 is the center lane curState = playerState.inLane; laneWidthInt = (int)laneWidth; playerFrame = 0; animationTimer = 0; jumpHeight = 18f; initialHeight = gameObject.transform.position.y; playerImage = GameObject.FindGameObjectWithTag("PlayerFrame"); beenHit = false; playerHealth = PlayerMaxHealth; source = GetComponent<AudioSource>(); previousHitPitch = 1.4f; previousJumpPitch = 1.0f; pFrames = playerFrames; }
// moves one lane to the left based on what lane the player is in public void MoveLeft() { switch (currentLane) { case Location.lane.left: break; case Location.lane.middle: currentLane = Location.lane.left; curState = playerState.movingLeft; break; case Location.lane.right: currentLane = Location.lane.middle; curState = playerState.movingLeft; break; default: break; } }
// moves one lane to the right based on what lane the player is in public void MoveRight() { switch (currentLane) { case Location.lane.left: currentLane = Location.lane.middle; curState = playerState.movingRight; laneTransitionTimer = 0; break; case Location.lane.middle: currentLane = Location.lane.right; curState = playerState.movingRight; laneTransitionTimer = 0; break; case Location.lane.right: break; default: break; } }