void ShowPotrait(SpriteRenderer main, Potrait potrait) { // Add sprite and set alpha to 0. main.sprite = potrait.sprite; main.enabled = true; FadeController.sSingleton.SetAlpha(main, 0); main.transform.position = potrait.startPlacement.position; StartCoroutine(IEAppearSequence(main, potrait)); }
// <Potrait Name="PotraitLeft" Texture="Conversation/GUI_Destination_Forbidden" /> public static bool ParsePotrit( XmlNode _PotraitNode , out Potrait _Potrait ) { _Potrait = null ; if( "Potrait" == _PotraitNode.Name ) { _Potrait = new Potrait() ; if( null != _PotraitNode.Attributes[ "Name" ] ) { _Potrait.m_PotraitName = _PotraitNode.Attributes[ "Name" ].Value ; } if( null != _PotraitNode.Attributes[ "Texture" ] ) { _Potrait.m_TextureName = _PotraitNode.Attributes[ "Texture" ].Value ; } } return ( null != _Potrait ) ; }
// Move sprite into and out of screen. IEnumerator IEAppearSequence(SpriteRenderer sr, Potrait potrait) { potrait.isCoroutine = true; Vector3 defaultPos = sr.transform.position; float alphaVal = 0, currOffsetVal = 0, totalTime = 0; while (currOffsetVal < potrait.offset) { totalTime += Time.unscaledDeltaTime; currOffsetVal = totalTime / potrait.moveTime * potrait.offset; sr.transform.position = defaultPos; if (currOffsetVal > potrait.offset) { currOffsetVal = potrait.offset; } sr.transform.position = OffsetPosition(sr.transform.position, potrait.moveDirection, currOffsetVal); alphaVal = currOffsetVal / potrait.offset; if (alphaVal > potrait.maxAlpha) { alphaVal = potrait.maxAlpha; } FadeController.sSingleton.SetAlpha(sr, alphaVal); yield return(null); } if (potrait.stayMethod == Potrait.Stay.NONE) { yield return(StartCoroutine(CoroutineUtil.WaitForRealSeconds(potrait.stayDuration))); } else if (potrait.stayMethod == Potrait.Stay.CONTINUE_MOVE) { float timer = 0; while (timer < potrait.stayDuration) { timer += Time.unscaledDeltaTime; sr.transform.position = OffsetPosition(sr.transform.position, potrait.moveDirection, Time.unscaledDeltaTime * potrait.stayMoveSpeed); yield return(null); } } Transform currTrans = sr.transform; Vector3 defaultScale = currTrans.localScale; if (potrait.closeMethod == Potrait.Closing.EXPAND) { alphaVal = sr.color.a; while (sr.color.a > 0) { Vector3 temp = currTrans.localScale; temp.x += Time.unscaledDeltaTime * potrait.closeSpeed; temp.y += Time.unscaledDeltaTime * potrait.closeSpeed; currTrans.localScale = temp; alphaVal -= Time.unscaledDeltaTime; FadeController.sSingleton.SetAlpha(sr, alphaVal); yield return(null); } } else if (potrait.closeMethod == Potrait.Closing.MOVE_AND_FLATTEN) { float totalYScale = currTrans.localScale.y; while (currTrans.localScale.y > 0) { sr.transform.position = OffsetPosition(sr.transform.position, potrait.moveDirection, Time.unscaledDeltaTime * potrait.closeMoveSpeed); Vector3 temp = currTrans.localScale; temp.y -= Time.unscaledDeltaTime * potrait.closeSpeed; if (temp.y < 0) { temp.y = 0; } currTrans.localScale = temp; alphaVal = temp.y / totalYScale; FadeController.sSingleton.SetAlpha(sr, alphaVal); yield return(null); } } currTrans.localScale = defaultScale; sr.enabled = false; potrait.isCoroutine = false; }
public Potrait( Potrait _src ) { m_PotraitName = _src.m_PotraitName ; m_TextureName = _src.m_TextureName ; }