/// <summary> /// When the player clicks, we set the first point of the platform /// it's called "TryInitialize", because we call it every frame, /// but it doesn't do anything except on the frame that the player clicks the mouse /// </summary> /// <param name="position">the position of the mouse, in "world" coordinates</param> void TryInitialize(Vector2 position) { if (Input.GetMouseButtonDown(0) && !hoverBallSpawner) { //set the start position as the input position startPosition = position; //instantiate the prefab, and set it as our "currentPlatform" so we //don't make more than one at a time currentPlatform = Instantiate(platformModel) as Transform; if (currentPlatform.GetComponent <RhythmBounce>()) { RhythmBounce rhythmBounce = currentPlatform.GetComponent <RhythmBounce>(); rhythmBounce.platformRhythm = platformRhymicValue; rhythmBounce.maxSpeed = platformMaxVelocity; } //set the prefab's position accordingly currentPlatform.position = startPosition; } }
/// <summary> /// When the player clicks, we set the first point of the platform /// it's called "TryInitialize", because we call it every frame, /// but it doesn't do anything except on the frame that the player clicks the mouse /// </summary> /// <param name="position">the position of the mouse, in "world" coordinates</param> void TryInitialize(Vector2 position) { if (Input.GetMouseButtonDown(0)) { //set the start position as the input position startPosition = position; //instantiate the prefab, and set it as our "currentPlatform" so we //don't make more than one at a time currentPlatform = Instantiate(platformModel); //NEW ADDITION - for rhythmic version. //This sets the max speed and platform rhythm according to spawner values if (currentPlatform.GetComponent <RhythmBounce>()) { RhythmBounce rhythmBounce = currentPlatform.GetComponent <RhythmBounce>(); currentPlatform.GetComponent <pxStrax>().release = platformSynthRelease; rhythmBounce.platformRhythm = platformRhymicValue; rhythmBounce.maxSpeed = platformMaxVelocity; } //set the prefab's position accordingly currentPlatform.transform.position = startPosition; } }