public TouchGameSettings() { if (s_settings != null) { throw new System.InvalidProgramException("there is more than one game settings object!"); } s_settings = this; }
private void PickPosition() { TouchGameSettings settings = TouchGameSettings.settings(); m_position.x = m_rand.Next(settings.areaWidth) - settings.areaWidth / 2; m_position.z = m_rand.Next(settings.areaHeight); gameObject.transform.localPosition = m_position; }
void Update() { TouchGameSettings settings = TouchGameSettings.settings(); float l = 1.0f; //Time.deltaTime * 5.0f; float nx = m_gamepad.axes[HFTGamepad.AXIS_TOUCH_X] * 0.5f; // -0.5 <-> 0.5 float ny = m_gamepad.axes[HFTGamepad.AXIS_TOUCH_Y] * 0.5f + 0.5f; // 0 <-> 1 m_position.x = Mathf.Lerp(m_position.x, settings.areaWidth * nx, l); m_position.z = Mathf.Lerp(m_position.z, settings.areaHeight - (ny * settings.areaHeight) - 1, l); // because in 2D down is positive. gameObject.transform.localPosition = m_position; }
void Cleanup() { s_settings = null; }