public WindAdv GetWind() { if ( wind != null ) return wind; GameObject windObj = GameObject.FindWithTag( "Wind"); if ( windObj != null ) { wind = windObj.GetComponent<WindAdv>(); } return wind; }
public WindAdv GetWind() { if (wind != null) { return(wind); } GameObject windObj = GameObject.FindWithTag("Wind"); if (windObj != null) { wind = windObj.GetComponent <WindAdv>(); } return(wind); }
void UpdateWindTest() { // update velocity velocity += windVelocity * WindVelSense * Time.deltaTime * 30f; velocity = Vector2.ClampMagnitude(velocity, maxVel * (1f + windVelocity.magnitude / 2f)); velocity *= 0.98f; rotateVel += Vector3.Cross(transform.up, windVelocity * WindRotateSense).z *Time.deltaTime * 30f; rotateVel = Mathf.Clamp(rotateVel, maxRotVel, -maxRotVel); rotateVel *= 0.98f; // update position & rotation Vector3 pos = transform.localPosition; pos += Global.V2ToV3(velocity) * Time.deltaTime; if (wind == null) { wind = GetComponentInParent <WindAdv>(); } if (wind != null) { if (pos.x > wind.GetSize().x / 2 + 0.1f) { pos.x -= wind.GetSize().x; } if (pos.x < -wind.GetSize().x / 2 - 0.1f) { pos.x += wind.GetSize().x; } if (pos.y > wind.GetSize().y / 2 + 0.1f) { pos.y -= wind.GetSize().y; } if (pos.y < -wind.GetSize().y / 2 - 0.1f) { pos.y += wind.GetSize().y; } } pos.z = Global.WIND_UI_Z; transform.localPosition = pos; model.transform.Rotate(rotateToward * rotateVel * Time.deltaTime); }
public void OnWindButton() { if (Time.time - windButtonTime < 2f) { return; } WindAdv wind = LogicManager.LevelManager.GetWind(); if (wind.UIShowed) { wind.HideUI(); } else { wind.ShowUI(); } windButtonTime = Time.time; }
void UpdateWindTest() { // update velocity velocity += windVelocity * WindVelSense * Time.deltaTime * 30f ; velocity = Vector2.ClampMagnitude( velocity , maxVel * ( 1f + windVelocity.magnitude / 2f ) ); velocity *= 0.98f; rotateVel += Vector3.Cross(transform.up, windVelocity * WindRotateSense ).z * Time.deltaTime * 30f; rotateVel = Mathf.Clamp(rotateVel, maxRotVel, -maxRotVel); rotateVel *= 0.98f; // update position & rotation Vector3 pos = transform.localPosition; pos += Global.V2ToV3( velocity ) * Time.deltaTime; if ( wind == null ) { wind = GetComponentInParent<WindAdv>(); } if ( wind != null ) { if ( pos.x > wind.GetSize().x / 2 + 0.1f ) pos.x -= wind.GetSize().x ; if ( pos.x < - wind.GetSize().x / 2 - 0.1f ) pos.x += wind.GetSize().x ; if ( pos.y > wind.GetSize().y / 2 + 0.1f) pos.y -= wind.GetSize().y ; if ( pos.y < - wind.GetSize().y / 2 - 0.1f ) pos.y += wind.GetSize().y ; } pos.z = Global.WIND_UI_Z; transform.localPosition = pos; model.transform.Rotate( rotateToward * rotateVel * Time.deltaTime ); }
void OnDoubleTapBack(TapGesture g) { WindAdv wind = LogicManager.LevelManager.GetWind(); wind.UISwitch(); }