Ejemplo n.º 1
0
    /// <summary>
    /// 离开时做一个惯性动画
    /// </summary>
    /// <param name="context"></param>
    void OnSwipeEnd(EventContext context)
    {
        SwipeGesture gesture = (SwipeGesture)context.sender;
        Vector3      v       = new Vector3();

        if (Mathf.Abs(gesture.velocity.x) > Mathf.Abs(gesture.velocity.y))
        {
            //手指离开时,左右旋转时的加速度
            v.y = -Mathf.Round(Mathf.Sign(gesture.velocity.x) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.x)));
            if (Mathf.Abs(v.y) < 2)
            {
                return;
            }
        }
        else
        {
            v.x = -Mathf.Round(Mathf.Sign(gesture.velocity.y) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.y)));
            if (Mathf.Abs(v.x) < 2)
            {
                return;
            }
        }
        //做一个TO数值过度从V->0经过0.3秒  ,设置目标对象是地球, 每帧调用 lambda表达式传入一个GTweener对象
        //差值旋转
        GTween.To(v, Vector3.zero, 0.3f).SetTarget(_ball).OnUpdate(
            (GTweener tweener) =>
        {
            _ball.Rotate(tweener.deltaValue.vec3, Space.World);
        });
    }
Ejemplo n.º 2
0
    void StartTween()
    {
        _turningAmount = 0;
        RenderPages();
        Vector2 source = GetCornerPosition(_draggingCorner, _coverTurningOp != CoverTurningOp.None);
        Vector2 target;

        if (_draggingCorner == Corner.TL || _draggingCorner == Corner.BL)
        {
            target = GetCornerPosition(_draggingCorner + 2, _coverTurningOp != CoverTurningOp.None);
        }
        else
        {
            target = GetCornerPosition(_draggingCorner - 2, _coverTurningOp != CoverTurningOp.None);
        }

        if (_turningPath == null)
        {
            _turningPath = new GPath();
        }
        Vector2 mid = new Vector2(source.x + (target.x - source.x) / 2, target.y - 50);

        _turningPath.Create(new GPathPoint(source), new GPathPoint(mid), new GPathPoint(target));
        GTween.To(source, target, EffectDuration).SetUserData(true).SetTarget(this)
        .SetPath(_turningPath)
        .OnUpdate(OnTurnUpdate).OnComplete(OnTurnComplete);
    }
Ejemplo n.º 3
0
    void OnSwipeEnd(EventContext context)
    {
        SwipeGesture gesture = (SwipeGesture)context.sender;
        Vector3      v       = new Vector3();

        if (Mathf.Abs(gesture.velocity.x) > Mathf.Abs(gesture.velocity.y))
        {
            v.y = -Mathf.Round(Mathf.Sign(gesture.velocity.x) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.x)));
            if (Mathf.Abs(v.y) < 2)
            {
                return;
            }
        }
        else
        {
            v.x = -Mathf.Round(Mathf.Sign(gesture.velocity.y) * Mathf.Sqrt(Mathf.Abs(gesture.velocity.y)));
            if (Mathf.Abs(v.x) < 2)
            {
                return;
            }
        }

        GTween.To(v, Vector3.zero, 0.3f).SetTarget(_ball).OnUpdate(
            (GTweener tweener) =>
        {
            _ball.Rotate(tweener.deltaValue.vec3, Space.World);
        });
    }
Ejemplo n.º 4
0
    public void SetHurt(Transform owner, int type, long hurt, bool isPlayer, bool critical)
    {
        _owner = owner;

        TextFormat tf = _numberText.textFormat;

        tf.color = Color.red;
        tf.size  = 24;
        if (type == 0)
        {
            tf.font = EmitManager.inst.hurtFont1;
        }
        else
        {
            tf.font = EmitManager.inst.hurtFont2;
        }
        if (isPlayer)
        {
            tf.size = 60;
        }

        if (hurt < 0)
        {
            tf.color = Color.green;
            _numberText.textFormat = tf;
            _numberText.text       = "+" + (-hurt);
        }
        else
        {
            tf.color = Color.red;
            _numberText.textFormat = tf;
            _numberText.text       = "-" + hurt;
        }



        if (critical)
        {
            _symbolLoader.url = EmitManager.inst.criticalSign;
        }
        else
        {
            _symbolLoader.url = "";
        }

        UpdateLayout();

        this.alpha = 1;
        UpdatePosition(Vector2.zero);
        Vector2 rnd = Vector2.Scale(UnityEngine.Random.insideUnitCircle, JITTER_FACTOR);
        int     toX = (int)rnd.x * 2;
        int     toY = (int)rnd.y * 2;



        EmitManager.inst.view.AddChild(this);
        GTween.To(Vector2.zero, new Vector2(toX, toY), 1f).SetTarget(this)
        .OnUpdate((GTweener tweener) => { this.UpdatePosition(tweener.value.vec2); }).OnComplete(this.OnCompleted);
        this.TweenFade(0, 0.5f).SetDelay(0.5f);
    }
Ejemplo n.º 5
0
    void __touchEnd(EventContext context)
    {
        if (_draggingCorner != Corner.INVALID)
        {
            bool    suc = _turningAmount > 0.4f || (Time.unscaledTime - _touchDownTime < 0.35f);
            Vector2 target;
            if (suc)
            {
                if (_draggingCorner == Corner.TL || _draggingCorner == Corner.BL)
                {
                    target = GetCornerPosition(_draggingCorner + 2, _coverTurningOp != CoverTurningOp.None);
                }
                else
                {
                    target = GetCornerPosition(_draggingCorner - 2, _coverTurningOp != CoverTurningOp.None);
                }
            }
            else
            {
                target = GetCornerPosition(_draggingCorner, _coverTurningOp != CoverTurningOp.None);
            }

            float duration = Mathf.Max(EffectDuration * 0.5f, Mathf.Abs(target.x - _dragPoint.x) / (_pageWidth * 2) * EffectDuration);
            GTween.To(_dragPoint, target, duration).SetTarget(this).SetUserData(suc)
            .OnUpdate(OnTurnUpdate).OnComplete(OnTurnComplete);
        }
    }
Ejemplo n.º 6
0
    public void Turn()
    {
        if (GTween.IsTweening(this))
        {
            return;
        }

        bool toOpen = !_front.visible;

        GTween.To(0, 180, 0.8f).SetTarget(this).SetEase(EaseType.QuadOut).OnUpdate(TurnInTween).SetUserData(toOpen);
    }
Ejemplo n.º 7
0
    public void ChargeSceneToLight(GTweenCallback onComplete)
    {
        SimpleBlit simpleBlit = _panel.container.renderCamera.gameObject.GetComponent <SimpleBlit>();

        GTween.To(0, 1, 1.0f).SetTarget(this).SetEase(EaseType.Linear).OnUpdate(
            (GTweener tweener) => {
            simpleBlit._cutoff = 1 - tweener.value.x;
        }
            ).OnComplete(() => {
            // DestroyImmediate(simpleBlit);
            simpleBlit.enabled = false;
            onComplete();
        });
    }
Ejemplo n.º 8
0
 protected override void DoShowAnimation()
 {
     if (!IsShowEffect)
     {
         base.DoShowAnimation();
         return;
     }
     visible = false;
     GTween.To(new Vector2(0, 0), new Vector2(1, 1), 0.3f)
     .SetEase(EaseType.BackOut)
     .OnUpdate((GTweener tweener) =>
     {
         visible = true;
         scale   = new Vector2(tweener.value.x, tweener.value.y);
         base.DoShowAnimation();
     });
 }
Ejemplo n.º 9
0
    private void OnSwipeEnd(EventContext context)
    {
        if (EnableSwipe)
        {
            SwipeGesture gesture = (SwipeGesture)context.sender;
            Vector3      offset  = new Vector3(gesture.velocity.x, 0, -gesture.velocity.y);
            Vector3      v       = SceneRotate * offset / InertiaingRatio;
            GTween.To(1, 0, 0.3f).SetTarget(m_CameraCenter).OnUpdate(
                (GTweener tweener) =>
            {
                v = v * 0.8f; v.y = 0;

                Vector3 position = m_CameraCenter.transform.position - v;
                position.x       = Mathf.Clamp(position.x, 0.8f, 38.5f);
                position.z       = Mathf.Clamp(position.z, 0, 40f);
                m_CameraCenter.transform.position = position;
            });
        }
    }
 public void DownLine(int limit)
 {
     if (_lineIndex + limit < _textField.lines.Count)
     {
         var       line0 = _textField.lines[_lineIndex];
         var       line1 = _textField.lines[_lineIndex + limit];
         var       y0    = line0.y + line0.height;
         var       y1    = line1.y + line1.height;
         Container c     = _containerDownline;
         c.clipRect = new Rect(0, y0, c.width, y1 - y0);
         // c.y = _rectRaw.y - y0;
         GTween.Kill(this);
         GTween.To(c.y, _rectRaw.y - y0, 0.05f).SetTarget(this).SetEase(EaseType.Linear).OnUpdate(
             (GTweener tweener) => {
             c.y = tweener.value.x;
         }
             );
         _lineIndex++;
     }
 }
Ejemplo n.º 11
0
    public void ChargeSceneToDark(GTweenCallback onComplete)
    {
        Debug.Log("Charge Scene");
        SimpleBlit simpleBlit = _panel.container.renderCamera.gameObject.GetComponent <SimpleBlit>();

        if (simpleBlit == null)
        {
            simpleBlit = _panel.container.renderCamera.gameObject.AddComponent <SimpleBlit>();
            Object prefab = Resources.Load("BattleTransitions");
            // simpleBlit.TransitionMaterial = (Material)prefab;
            simpleBlit.TransitionMaterial = (Material)Object.Instantiate(prefab);
        }
        simpleBlit.enabled = true;
        GTween.To(0, 1, 1.0f).SetTarget(this).SetEase(EaseType.Linear).OnUpdate(
            (GTweener tweener) => {
            simpleBlit._cutoff = tweener.value.x;
        }
            ).OnComplete(() => {
            onComplete();
        });
    }
Ejemplo n.º 12
0
 protected override void DoHideAnimation()
 {
     if (!IsShowEffect)
     {
         base.DoHideAnimation();
         __OnClosed();
         return;
     }
     GTween.To(new Vector2(1, 1), new Vector2(0, 0), 0.3f)
     .SetTarget(this)
     .SetEase(EaseType.Custom)
     .OnUpdate((GTweener tweener) =>
     {
         scale = new Vector2(tweener.value.x, tweener.value.y);
     }).OnComplete((tweener =>
     {
         base.DoHideAnimation();
         //如果有动画,那么关闭动画播放完毕后才触发__OnClosed
         __OnClosed();
     }));
 }
Ejemplo n.º 13
0
        public void StartMovement()
        {
            loopingMove       = true;
            nextRoundPostion += RoundAddtion;

            if (nextRoundPostion >= maxPostion)
            {
                nextRoundPostion = maxPostion;
                returnBack       = true;
            }

            Vector2 targetPostion = new Vector2(nextRoundPostion, target.anchoredPosition.y);

            GTween.To(target.anchoredPosition, targetPostion, 1).SetTarget(target).
            OnUpdate((tweener) =>
            {
                target.anchoredPosition = tweener.value.vec2;
            }).
            OnComplete(() => {
            });
        }
    public void MoveCamTo(float _camXAngle_to, float _y_to, float _distance_to, Vector3 _target_to, GTweenCallback _onComplete)
    {
        float   _camXAngle_from = camXAngle;
        float   _camXAngle_a    = _camXAngle_to - _camXAngle_from;
        float   _y_from         = yCam;
        float   _y_a            = _y_to - _y_from;
        float   _distance_from  = distance;
        float   _distance_a     = _distance_to - _distance_from;
        float   _targetHeight   = targetHeight;
        Vector3 _target_from    = targetPos;

        target = null;
        GTween.Kill(this);
        // Debug.Log("_target_from: " + _target_from.ToString());
        // Debug.Log("_target_to: " + _target_to.ToString());
        GTween.To(0.0f, 1.0f, 1.0f).SetTarget(this).SetEase(EaseType.Linear).OnUpdate(
            (GTweener tweener) => {
            float mu = tweener.value.x;
            if (mu >= 1)
            {
                mu = 1;
            }
            float _camXAngle = _camXAngle_from + _camXAngle_a * mu;
            float _y         = _y_from + _y_a * mu;
            float _distance  = _distance_from + _distance_a * mu;
            Vector3 _target  = Vector3.Lerp(_target_from, _target_to, mu);
            ForceSetCam(_camXAngle, _y, _distance, _target, _targetHeight);
        }
            ).OnComplete(() => {
            ForceSetCam(_camXAngle_to, _y_to, _distance_to, _target_to, _targetHeight);
            if (_onComplete != null)
            {
                _onComplete();
            }
        });
    }
Ejemplo n.º 15
0
    //-----------------------------
    private void PlayGraph()
    {
        GComponent obj = _demoObjects["Graph"];

        Shape shape;

        shape = obj.GetChild("pie").asGraph.shape;
        EllipseMesh ellipse = shape.graphics.GetMeshFactory <EllipseMesh>();

        ellipse.startDegree = 30;
        ellipse.endDegreee  = 300;
        shape.graphics.SetMeshDirty();

        shape = obj.GetChild("trapezoid").asGraph.shape;
        PolygonMesh trapezoid = shape.graphics.GetMeshFactory <PolygonMesh>();

        trapezoid.usePercentPositions = true;
        trapezoid.points.Clear();
        trapezoid.points.Add(new Vector2(0f, 1f));
        trapezoid.points.Add(new Vector2(0.3f, 0));
        trapezoid.points.Add(new Vector2(0.7f, 0));
        trapezoid.points.Add(new Vector2(1f, 1f));
        trapezoid.texcoords.Clear();
        trapezoid.texcoords.AddRange(VertexBuffer.NormalizedUV);
        shape.graphics.SetMeshDirty();
        shape.graphics.texture = (NTexture)UIPackage.GetItemAsset("Basics", "change");

        shape = obj.GetChild("line").asGraph.shape;
        LineMesh line = shape.graphics.GetMeshFactory <LineMesh>();

        line.lineWidthCurve = AnimationCurve.Linear(0, 25, 1, 10);
        line.roundEdge      = true;
        line.gradient       = lineGradient;
        line.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0)),
            new GPathPoint(new Vector3(20, 120, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 30, 0)),
            new GPathPoint(new Vector3(100, 0, 0)),
            new GPathPoint(new Vector3(20, 30, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 120, 0)),
            new GPathPoint(new Vector3(200, 120, 0)),
        });
        shape.graphics.SetMeshDirty();
        GTween.To(0, 1, 5).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnUpdate((GTweener t) =>
        {
            ((NGraphics)t.target).GetMeshFactory <LineMesh>().fillEnd = t.value.x;
            ((NGraphics)t.target).SetMeshDirty();
        });

        shape = obj.GetChild("line2").asGraph.shape;
        LineMesh line2 = shape.graphics.GetMeshFactory <LineMesh>();

        line2.lineWidth = 3;
        line2.roundEdge = true;
        line2.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(60, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(80, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(140, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(160, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(220, 30, 0), GPathPoint.CurveType.Straight)
        });
        shape.graphics.SetMeshDirty();

        GObject  image = obj.GetChild("line3");
        LineMesh line3 = image.displayObject.graphics.GetMeshFactory <LineMesh>();

        line3.lineWidth = 30;
        line3.roundEdge = false;
        line3.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 30, 0), new Vector3(50, -30), new Vector3(150, -50)),
            new GPathPoint(new Vector3(200, 30, 0), new Vector3(300, 130)),
            new GPathPoint(new Vector3(400, 30, 0))
        });
        image.displayObject.graphics.SetMeshDirty();
    }
Ejemplo n.º 16
0
 private void Minus(int _minusValue)
 {
     GTween.To(balance, balance - _minusValue, 0.3f).SetEase(EaseType.Linear).OnUpdate((GTweener tweener) => { mainUI.GetChild("money").text = Mathf.Floor(tweener.value.x).ToString(); });
     balance = balance - _minusValue;
 }
Ejemplo n.º 17
0
 public void Rotate()
 {
     _ss[3].visible = true;
     GTween.To(0f, -45f, 0.4f).SetTarget(this)
     .OnUpdate((GTweener tweener) => { this.UpdateRotation(tweener.value.x); }).OnComplete(this.OnCompleted);
 }
 void __playNum()
 {
     GTween.To(_startValue, _endValue, 0.3f).SetEase(EaseType.Linear)
     .OnUpdate((GTweener tweener) => { _g5.GetChild("value").text = "" + Mathf.Floor(tweener.value.x); });
 }
Ejemplo n.º 19
0
    //-----------------------------
    private void PlayGraph()
    {
        GComponent obj = _demoObjects["Graph"];

        Shape shape;

        shape = obj.GetChild("pie").asGraph.shape;
        EllipseMesh ellipse = shape.graphics.GetMeshFactory <EllipseMesh>();

        ellipse.startDegree = 30;
        ellipse.endDegreee  = 300;
        shape.graphics.SetMeshDirty();

        shape = obj.GetChild("trapezoid").asGraph.shape;
        PolygonMesh trapezoid = shape.graphics.GetMeshFactory <PolygonMesh>();

        trapezoid.usePercentPositions = true;
        trapezoid.points.Clear();
        trapezoid.points.Add(new Vector2(0.3f, 0));
        trapezoid.points.Add(new Vector2(0.7f, 0));
        trapezoid.points.Add(new Vector2(1f, 1f));
        trapezoid.points.Add(new Vector2(0f, 1f));
        shape.graphics.SetMeshDirty();

        shape = obj.GetChild("polygon").asGraph.shape;
        shape.DrawPolygon(new Vector2[] {
            new Vector2(20, 30),
            new Vector2(80, 40),
            new Vector2(80, 15),
            new Vector2(140, 50),
            new Vector2(80, 85),
            new Vector2(80, 60),
            new Vector2(20, 70)
        }, shape.color);

        shape = obj.GetChild("polygon2").asGraph.shape;
        shape.DrawRegularPolygon(5, 2, Color.yellow, Color.black, shape.color, -18, null);

        shape = obj.GetChild("radial").asGraph.shape;
        shape.DrawRegularPolygon(6, 2, shape.color, new Color32(0xFF, 0x99, 0x00, 128), shape.color, 0, new float[] { 0.6f, 0.8f, 0.6f, 0.8f, 0.6f, 0.5f });

        shape = obj.GetChild("line").asGraph.shape;
        LineMesh line = shape.graphics.GetMeshFactory <LineMesh>();

        line.lineWidthCurve = AnimationCurve.Linear(0, 25, 1, 10);
        line.roundEdge      = true;
        line.gradient       = lineGradient;
        line.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0)),
            new GPathPoint(new Vector3(20, 120, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 30, 0)),
            new GPathPoint(new Vector3(100, 0, 0)),
            new GPathPoint(new Vector3(20, 30, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 120, 0)),
            new GPathPoint(new Vector3(200, 120, 0)),
        });
        shape.graphics.SetMeshDirty();
        GTween.To(0, 1, 5).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnUpdate((GTweener t) =>
        {
            ((NGraphics)t.target).GetMeshFactory <LineMesh>().fillEnd = t.value.x;
            ((NGraphics)t.target).SetMeshDirty();
        });

        shape = obj.GetChild("line2").asGraph.shape;
        LineMesh line2 = shape.graphics.GetMeshFactory <LineMesh>();

        line2.lineWidth = 3;
        line2.roundEdge = true;
        line2.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(60, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(80, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(140, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(160, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(220, 30, 0), GPathPoint.CurveType.Straight)
        });
        shape.graphics.SetMeshDirty();

        GObject  image = obj.GetChild("line3");
        LineMesh line3 = image.displayObject.graphics.GetMeshFactory <LineMesh>();

        line3.lineWidth = 30;
        line3.roundEdge = false;
        line3.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 30, 0), new Vector3(50, -30), new Vector3(150, -50)),
            new GPathPoint(new Vector3(200, 30, 0), new Vector3(300, 130)),
            new GPathPoint(new Vector3(400, 30, 0))
        });
        image.displayObject.graphics.SetMeshDirty();
    }