Esempio n. 1
0
        /// <inheritdoc />
        protected override void OnTick(GameTime gameTime, float delta)
        {
            //_swingValue2 +=
            _swingValue  += delta;
            _swingValue2 += delta * 10f;
            var progress = (1f / SwingDuration) * _swingValue;

            var prog = progress;

            if (prog > 1f)
            {
                prog = 2f - prog;
            }

            Bone.Rotation = new Vector3(EasingFunction.EaseInCubic(Initial.Rotation.X, 120f, prog), 0f, (MathF.Sin(_swingValue2) * 17.5f));

            if (progress >= 2f)
            {
                _finished = true;
            }
        }
Esempio n. 2
0
    public override void update(float time)
    {
        //Debug.Log("rush main update________________________________________");
        if (transform == null)
        {
            waste = true;
            return;
        }
        anim_time += time;
        if (anim_time <= animTime)
        {
            //Debug.Log("anim_time=" + anim_time + " animTime=" + animTime);
            float process = anim_time / animTime;
            process = EasingFunction.EaseInCubic(0, 1, process);
            Vector2 nowOffset = offset;
            if (nowTraget == null)
            {
                transform.position = oriPos;
                waste = true;
                return;
            }
            Vector2 dist = nowTraget.transform.position - transform.position;
            if (Mathf.Abs(dist.x) < nowOffset.x)
            {
                nowOffset.x = Mathf.Abs(dist.x);
            }
            if (Mathf.Abs(dist.y) < nowOffset.y)
            {
                nowOffset.y = Mathf.Abs(dist.y);
            }
            //Debug.Log("count"+count+" tragetPos:" + (Vector2)nowTraget.transform.position + " oriPos:" + oriPos+" ans:" + ((Vector2)nowTraget.transform.position - oriPos) * process);


            Vector2 toTraget = ((Vector2)nowTraget.transform.position - oriPos);
            if (toTraget.x > 0)
            {
                toTraget.x -= nowOffset.x;
            }
            else
            {
                toTraget.x += nowOffset.x;
            }
            if (toTraget.y > 0)
            {
                toTraget.y -= nowOffset.y;
            }
            else
            {
                toTraget.y += nowOffset.y;
            }
            transform.position = oriPos + toTraget * process;

            /*if (stay_time >=  stayTime && !triggerEff)
             * {
             *  GameObject neweff= Instantiate(objectList.main.prafebList[0], transform);
             *  neweff.transform.localPosition = Vector2.zero;
             *  toTraget = (Vector2)transform.position - (Vector2)nowTraget.transform.position;
             *  neweff.transform.right = toTraget;
             *  triggerEff = true;
             * }*/
        }
        else if (stay_time < stayTime)
        {
            if (!triggerEff)
            {
                Debug.Log("觸發效果");
                onTriggerEff();
                triggerEff = true;
            }
            //Debug.Log("count" + count + "staying");
            stay_time += time;
        }
        else
        {
            transform.position = oriPos;
            waste = true;
        }
    }