/// <summary> /// 设置主界面当前选中的选项 /// </summary> /// <param name="index"></param> private void SetSelectIndex(int index) { if (_selectIndex != -1) { TitleItem item = _itemList[_selectIndex]; TweenManager.GetInstance().RemoveTweenByGo(item.img.gameObject); item.img.color = new Color(1, 1, 1, 1); } _selectIndex = index; if (_selectIndex != -1) { TitleItem item = _itemList[_selectIndex]; TweenColor tween = TweenManager.GetInstance().Create <TweenColor>(); tween.SetParas(item.img.gameObject, 0, 30, ePlayMode.PingPong); tween.SetParas(new Color(1, 1, 1, 1), new Color(0.5f, 0, 0, 1), InterpolationMode.Linear); TweenManager.GetInstance().AddTween(tween); } }
/// <summary> /// index取值为0或者1,代表yes or no /// </summary> /// <param name="index"></param> private void SetCurYesNoItem(int index) { if (_curYesNoItem != null) { // 移除当前选择的item的特效 TweenManager.GetInstance().RemoveTweenByGo(_curYesNoItem); ResetImgColor(_curYesNoItem); } // 切换 _curYesNoIndex = index; _curYesNoItem = _yesNoItems[index]; // 添加特效 TweenColor tween = TweenManager.GetInstance().Create <TweenColor>(); tween.SetParas(_curYesNoItem, 0, 60, ePlayMode.PingPong); tween.SetParas(new Color(1, 1, 1, 1), new Color(0.5f, 0, 0, 1), InterpolationMode.Linear); TweenManager.GetInstance().AddTween(tween); }
/// <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); }