/// <summary> /// 设置主界面当前选中的选项 /// </summary> /// <param name="index"></param> private void SetSelectIndex(int index, int appearDir) { _selectIndex = index; SelCharacterData data = _charDatas[_selectIndex]; _charCGImg.sprite = ResourceManager.GetInstance().GetSprite("SelCharView", data.spName); _charDesImg.sprite = ResourceManager.GetInstance().GetSprite("SelCharView", data.desSp); if (appearDir == Consts.DIR_NULL) { _viewState = eViewState.Wait; _stateTime = 0; } else { TweenRotation tween0 = TweenManager.GetInstance().Create <TweenRotation>(); tween0.SetParas(_charDesTf.gameObject, 0, 30, ePlayMode.Once); TweenAnchoredPos tween1 = TweenManager.GetInstance().Create <TweenAnchoredPos>(); tween1.SetParas(_charCGTf.gameObject, 0, 30, ePlayMode.Once); if (appearDir == Consts.DIR_LEFT) { _charDesTf.localEulerAngles = new Vector3(0, 270, 0); tween0.SetParas(new Vector3(0, 360, 0), InterpolationMode.Linear); _charCGTf.anchoredPosition = CGLeftAppearPos; } else { _charDesTf.localEulerAngles = new Vector3(0, 90, 0); tween0.SetParas(Vector3.zero, InterpolationMode.Linear); _charCGTf.anchoredPosition = CGRightAppearPos; } tween1.SetParas(CGDefaultPos, InterpolationMode.EaseInQuad); tween1.SetFinishCallBack(SelCharTweenCallback); TweenManager.GetInstance().AddTween(tween0); TweenManager.GetInstance().AddTween(tween1); _viewState = eViewState.ChangeCharAni; } }
/// <summary> /// 根据栈顶的table创建对应的tween /// </summary> /// <param name="luaState"></param> /// <returns></returns> private TweenBase CreateTweenByTable(ILuaState luaState) { luaState.GetField(-1, "type"); // 缓动类型 eTweenType type = (eTweenType)luaState.ToInteger(-1); luaState.Pop(1); // delay and duration int delay, duration; luaState.GetField(-1, "delay"); delay = luaState.ToInteger(-1); luaState.GetField(-2, "duration"); duration = luaState.ToInteger(-1); luaState.Pop(2); switch (type) { case eTweenType.Alhpa: { TweenAlpha tween = TweenManager.GetInstance().Create <TweenAlpha>(); float begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = (float)luaState.ToNumber(-1); luaState.GetField(-2, "endValue"); end = (float)luaState.ToNumber(-1); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } case eTweenType.Color: { TweenColor tween = TweenManager.GetInstance().Create <TweenColor>(); Color begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = InterpreterManager.GetInstance().TranslateTableToColor(luaState); luaState.GetField(-2, "endValue"); end = InterpreterManager.GetInstance().TranslateTableToColor(luaState); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } case eTweenType.Pos2D: { TweenPos2D tween = TweenManager.GetInstance().Create <TweenPos2D>(); Vector2 begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = InterpreterManager.GetInstance().TranslateTableToVector2(luaState); luaState.GetField(-2, "endValue"); end = InterpreterManager.GetInstance().TranslateTableToVector2(luaState); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } case eTweenType.Pos3D: { TweenPos3D tween = TweenManager.GetInstance().Create <TweenPos3D>(); Vector3 begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-2, "endValue"); end = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } case eTweenType.Rotation: { TweenRotation tween = TweenManager.GetInstance().Create <TweenRotation>(); Vector3 begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-2, "endValue"); end = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } case eTweenType.Scale: { TweenScale tween = TweenManager.GetInstance().Create <TweenScale>(); Vector3 begin, end; InterpolationMode mode; luaState.GetField(-1, "beginValue"); begin = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-2, "endValue"); end = InterpreterManager.GetInstance().TranslateTableToVector3(luaState); luaState.GetField(-3, "mode"); mode = (InterpolationMode)luaState.ToInteger(-1); luaState.Pop(3); tween.SetParas(_charCGGo, delay, duration, ePlayMode.Once); tween.SetParas(begin, end, mode); return(tween); } } Logger.LogError("Create Tween by table fail! eTweenType not match!"); return(null); }