append() public method

appends a Tween at the end of the current flow
public append ( AbstractGoTween, tween ) : GoTweenChain,
tween AbstractGoTween,
return GoTweenChain,
    public void TweenText(Transform t)
    {
        Debug.Log("Tweening text " + t.name);
        GoTweenChain chain = new GoTweenChain();

        chain.append(Go.to(t, 0.5f, new GoTweenConfig().position(Vector3.down * 5, true).setEaseType(GoEaseType.QuadInOut)));
        chain.appendDelay(1);
        chain.append(Go.to(t, 0.5f, new GoTweenConfig().position(Vector3.up * 5, true).setEaseType(GoEaseType.QuadInOut)));
        chain.play();
    }
    // Use this for initialization
    void Start()
    {
        TurnManager.Instance.OnRoundStart.AddListener(newRound);
        TurnManager.Instance.OnGameEnd.AddListener(gameOver);
        RoundPanel.anchoredPosition = new Vector2(0, 150);

        // Movement fun
        movementTween = new GoTweenChain();
        movementTween.append(new GoTween(RoundPanel, 0.5f, new GoTweenConfig().anchoredPosition(new Vector2(0, -50))));
        movementTween.appendDelay(1);
        movementTween.append(new GoTween(RoundPanel, 0.5f, new GoTweenConfig().anchoredPosition(new Vector2(0, 150))));
    }
Esempio n. 3
0
    private IEnumerator Blink_Coroutine(Vector3 direction, Vector3 mousePos, bool charge)
    {
        _blink = true;
        Vector3 pos = transform.position;

        pos.y      = 0;
        mousePos.y = 0;
        Vector3 bodyScale = body.localScale;
        float   yPos      = transform.position.y;

        Go.to(body, 0.25f, new GoTweenConfig().scale(Vector3.one * 0.25f).setEaseType(GoEaseType.BackIn));

        yield return(new WaitForSeconds(0.25f));

        Vector3 newPos = mousePos;

        newPos.y = yPos;

        Go.to(transform, 0.5f, new GoTweenConfig().position(newPos).setEaseType(GoEaseType.BackInOut));

        yield return(new WaitForSeconds(0.5f));

        transform.position = newPos;

        Go.to(body, 0.25f, new GoTweenConfig().scale(bodyScale).setEaseType(GoEaseType.BackOut));

        if (charge)
        {
            GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube);
            punch.GetComponent <MeshRenderer>().material = attackMaterial;
            punch.transform.position   = transform.position;
            punch.transform.localScale = Vector3.zero;

            GoTweenChain chain       = new GoTweenChain();
            GoTween      growTween   = Go.to(punch.transform, chargeBlinkFXTime * 0.25f, new GoTweenConfig().scale(Vector3.one * 3).setEaseType(GoEaseType.BackOut));
            GoTween      shrinkTween = Go.to(punch.transform, chargeBlinkFXTime * 0.75f, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn));
            chain.append(growTween);
            chain.append(shrinkTween);
            chain.play();

            yield return(new WaitForSeconds(chargeBlinkFXTime));

            yield return(new WaitForSeconds(blinkRecoverTime));
        }
        else
        {
            yield return(new WaitForSeconds(0.25f));
        }

        Go.killAllTweensWithTarget(body.GetChild(0).GetComponent <MeshRenderer>());
        Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0)));
        _blink = false;
    }
Esempio n. 4
0
    void playSounds(List <KeyValuePair <string, int> > sortedSounds, List <AudioClip> clips)
    {
        AudioSource[] src = this.gameObject.GetComponents <AudioSource> ();

        audioGtc = new GoTweenChain();
        audioGtc.autoRemoveOnComplete = true;
        float accTime = 0;

        _curClipIndex = 0;
        for (int i = 0; i < sortedSounds.Count; ++i)
        {
            var   sd    = sortedSounds [i];
            float delay = sd.Value / 24.0f - accTime;
            if (delay > 0)
            {
                audioGtc.appendDelay(delay);
            }
            var cbcon = new GoTweenConfig();
            audioGtc.append(new GoTween(
                                gameObject.transform,
                                0.01f,
                                cbcon.onComplete(delegate(AbstractGoTween obj) {
                int ri                = _curClipIndex % maxChannels;
                src [ri].clip         = clips [_curClipIndex];
                src [ri].loop         = false;
                src [ri].spatialBlend = 0;
                src [ri].Play();
                ++_curClipIndex;
            })
                                ));
            accTime += delay;
        }

        // for some reason the last play callback
        // is not invoked, so I add one more tween
        // to ensure the last sound is played.
        audioGtc.appendDelay(0.5f);
        GoTweenConfig gtcfg = new GoTweenConfig();

        audioGtc.append(new GoTween(
                            gameObject.transform,
                            0.01f,
                            gtcfg.onComplete(delegate(AbstractGoTween obj) {
        })
                            ));

        audioGtc.play();
    }
Esempio n. 5
0
    void Start()
    {
        // create a TweenConfig that we will use on all 4 cubes
        var config = new GoTweenConfig()
                     .setEaseType(GoEaseType.QuadIn)         // set the ease type for the tweens
                     .materialColor(Color.magenta)           // tween the material color to magenta
                     .eulerAngles(new Vector3(0, 360, 0))    // do a 360 rotation
                     .position(new Vector3(2, 8, 0), true)   // relative position tween so it will be start from the current location
                     .setIterations(2, GoLoopType.PingPong); // 2 iterations with a PingPong loop so we go out and back

        // create the chain and set it to have 2 iterations
        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(2));

        // add a completion handler for the chain
        chain.setOnCompleteHandler(c => Debug.Log("chain complete"));

        // create a Tween for each cube and it to the chain
        foreach (var cube in cubes)
        {
            var tween = new GoTween(cube, 0.5f, config);
            chain.append(tween);
        }

        _tween = chain;
    }
Esempio n. 6
0
        public override void ApplyPattern(Transform transform, ref AbstractGoTween tween)
        {
            var path = new GoSpline("little_curve_r");
            var move = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true));

            var path2 = new GoSpline("forward_top_bot");
            var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true));

            var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

            chain.append(move);
            chain.append(move3);

            tween = chain;
            tween.play();
        }
Esempio n. 7
0
	void Start()
	{
		// create a TweenConfig that we will use on all 4 cubes
		var config = new GoTweenConfig()
			.setEaseType( GoEaseType.QuadIn ) // set the ease type for the tweens
			.materialColor( Color.magenta ) // tween the material color to magenta
			.eulerAngles( new Vector3( 0, 360, 0 ) ) // do a 360 rotation
			.position( new Vector3( 2, 8, 0 ), true ) // relative position tween so it will be start from the current location
			.setIterations( 2, GoLoopType.PingPong ); // 2 iterations with a PingPong loop so we go out and back
		
		// create the chain and set it to have 2 iterations
		var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations( 2 ));
		
		// add a completion handler for the chain
		chain.setOnCompleteHandler( c => Debug.Log( "chain complete" ) );

		// create a Tween for each cube and it to the chain
		foreach( var cube in cubes )
		{
			var tween = new GoTween( cube, 0.5f, config );
			chain.append( tween );
		}
		
		_tween = chain;
	}
Esempio n. 8
0
    private IEnumerator ChargeStomp_Coroutine(Vector3 direction)
    {
        _chargeStomp = true;
        bool         effect = false;
        GoTweenChain chain  = new GoTweenChain();
        GameObject   stomp  = GameObject.CreatePrimitive(PrimitiveType.Cube);

        stomp.GetComponent <MeshRenderer>().material = attackMaterial;
        stomp.transform.localScale = Vector3.zero;

        Go.to(body, chargeStompFXDuration * 0.3f, new GoTweenConfig().localPosition(Vector3.up * 0.5f, true).setEaseType(GoEaseType.BackOut));
        Go.to(body, chargePunchFXDuration * 0.3f, new GoTweenConfig().rotation(Quaternion.LookRotation(direction)));

        yield return(new WaitForSeconds(chargeStompFXDuration * 0.3f));

        Go.to(body, chargeStompFXDuration * 0.7f, new GoTweenConfig().localPosition(Vector3.zero).setEaseType(GoEaseType.BackOut));
        float time = 0;

        while (chargeStompFXDuration * 0.7f > time)
        {
            if (!effect && time > chargeStompFXDuration * 0.2f)
            {
                effect = true;
                stomp.transform.position = transform.position + (Vector3.down * 0.25f);

                GoTween effectGrow   = new GoTween(stomp.transform, 0.2f, new GoTweenConfig().scale(new Vector3(3, 0.5f, 3)).setEaseType(GoEaseType.BackOut));
                GoTween effectShrink = new GoTween(stomp.transform, 1f, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn));
                chain.append(effectGrow);
                chain.append(effectShrink);
                chain.play();
            }

            time += Time.deltaTime;
            yield return(null);
        }

        yield return(chain.waitForCompletion());

        Destroy(stomp);

        yield return(new WaitForSeconds(chargeStompRecoverTime));

        Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0)));
        _chargeStomp = false;
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        var path = new GoSpline("little_curve");
        var move = Go.to(transform, 1f, new GoTweenConfig()
                         .positionPath(path, true));

        var move2 = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true));

        var path2 = new GoSpline("forward_top_bot");
        var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true));

        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

        chain.append(move);
        chain.append(move2);
        chain.append(move3);

        _tween = chain;
        _tween.play();
    }
Esempio n. 10
0
    internal static GoTweenChain animateJellyInfinite(this Transform transform, float time, float value, GoEaseType ease = GoEaseType.QuadInOut)
    {
        GoTweenChain chain = new GoTweenChain();

        Vector3 scaleAtStart = transform.localScale;
        Vector3 target       = new Vector3(scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z);

        transform.localScale = target;

        target = new Vector3(scaleAtStart.x + value, scaleAtStart.y - value, scaleAtStart.z);
        chain.append(transform.scaleTo(time, target).eases(ease));

        target = new Vector3(scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z);
        chain.append(transform.scaleTo(time, target).eases(ease));

        chain.loopCount = -1;
        chain.play();

        return(chain);
    }
Esempio n. 11
0
    IEnumerator DoEffect()
    {
        while (base.isActive())
        {
            float lightningDuration = Random.Range(m_minFlashDuration, m_maxFlashDuration );
            float delayUntilNextFlash = Random.Range(0.21f, 1.5f);

            gtc = new GoTweenChain();
            gtc.append(Go.to(m_lightningSprite, lightningDuration, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, Random.Range(m_minLightningOpacity, m_maxLightningOpacity)))));
            gtc.append(Go.to(m_lightningSprite, lightningDuration, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, 0))));
            gtc.autoRemoveOnComplete = true;

            lightningDuration = (2*lightningDuration ) + delayUntilNextFlash;
            gtc.appendDelay(delayUntilNextFlash);
            gtc.play();
            //Go.to(m_lightningSprite, 0, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, Random.Range(m_minLightningOpacity, m_maxLightningOpacity))));
            //m_lightningSprite
            //transform.shake(shakeDuration, new Vector3(m_shakeAmount, m_shakeAmount));
            yield return new WaitForSeconds(lightningDuration);
        }
    }
Esempio n. 12
0
    internal static GoTweenChain animateJelly(this Transform transform, float time, float value, int repeatCount = 1, GoEaseType ease = GoEaseType.QuadInOut)
    {
        Vector3 scaleAtStart = transform.localScale;

        GoTweenChain chain = new GoTweenChain();

        for (int i = repeatCount; i > 0; i--)
        {
            float factor = ((float)i) / repeatCount;

            Vector3 target = new Vector3(scaleAtStart.x + (value * factor), scaleAtStart.y - (value * factor), scaleAtStart.z);
            chain.append(transform.scaleTo(time * factor, target).eases(ease));

            target = new Vector3(scaleAtStart.x - (value * factor), scaleAtStart.y + (value * factor), scaleAtStart.z);
            chain.append(transform.scaleTo(time * factor, target).eases(ease));
        }

        chain.append(transform.scaleTo(time / repeatCount, scaleAtStart).eases(ease));
        chain.play();

        return(chain);
    }
    public override void ApplyPattern(Transform transform, ref AbstractGoTween tween)
    {
        var path = new GoSpline("top_to_bot_one_third");
        var move = Go.to(transform, 2f, new GoTweenConfig().positionPath(path, true));

        var path2 = new GoSpline("diag_right_to_left_one_square");
        var move2 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path2, true));

        var path3 = new GoSpline("top_to_bot_one_third");
        var move3 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true));
        var move4 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true));

        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

        chain.append(move);
        chain.append(move2);
        chain.append(move3);
        chain.append(move4);

        tween = chain;
        tween.play();
    }
Esempio n. 14
0
 static public int append(IntPtr l)
 {
     try {
         GoTweenChain    self = (GoTweenChain)checkSelf(l);
         AbstractGoTween a1;
         checkType(l, 2, out a1);
         var ret = self.append(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 15
0
    public void MoveWindow(int easeType)
    {
        switch (easeType)
        {
            case 0:
                Go.defaultEaseType = GoEaseType.Linear;
                break;
            case 1:
                Go.defaultEaseType = GoEaseType.BackOut;
                break;
            case 2:
                Go.defaultEaseType = GoEaseType.BounceOut;
                break;
            case 3:
                Go.defaultEaseType = GoEaseType.CircInOut;
                break;
            case 4:
                Go.defaultEaseType = GoEaseType.SineOut;
                break;
            default:
                Go.defaultEaseType = GoEaseType.Linear;
                break;
        }

        float move = 0;

        if (goScreen)
        {
            move = -length;
        }
        else
        {
            move = length;
        }


        var moveUpConfig = new GoTweenConfig().position(new Vector3(move, 0), true);
        moveUpConfig.onComplete(orginalTween => Done());

        var tweenOne = new GoTween(this.transform, duration, moveUpConfig);

        var chain = new GoTweenChain();
        chain.append(tweenOne);

        chain.play();
    }
Esempio n. 16
0
    IEnumerator SwimAway()
    {
        anim.SetBool("TurnBool", true);
        anim.SetBool("SwimmingBool", false);

        yield return(new WaitForSeconds(2f));

        var config = new GoTweenConfig().localPosition(origPosition);

        var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1));

        chain.setOnCompleteHandler(
            c => MoveBack());

        var tween = new GoTween(transform, 4f, config);

        chain.append(tween);

        chain.play();

        MonsterStabbed.Invoke();
    }
Esempio n. 17
0
    public void ScaleWindow()
    {

        if (goScreen)
        {
            Go.defaultEaseType = GoEaseType.BounceOut;
            scale = Vector3.one;
        }
        else
        {
            Go.defaultEaseType = GoEaseType.BounceIn;
            scale = Vector3.zero;
        }
        var scaleConfig = new GoTweenConfig().scale(scale, false);
        scaleConfig.onComplete(orginalTween => ScaleDone());

        var tweenOne = new GoTween(this.transform, duration, scaleConfig);

        var chain = new GoTweenChain();
        chain.append(tweenOne);

        chain.play();
    }
Esempio n. 18
0
    private IEnumerator Blink_Coroutine ( Vector3 direction , Vector3 mousePos , bool charge )
    {
        _blink = true;
        Vector3 pos = transform.position;
        pos.y = 0;
        mousePos.y = 0;
        Vector3 bodyScale = body.localScale;
        float yPos = transform.position.y;

        Go.to( body , 0.25f , new GoTweenConfig().scale( Vector3.one * 0.25f ).setEaseType( GoEaseType.BackIn ) );

        yield return new WaitForSeconds( 0.25f );
        Vector3 newPos = mousePos;
        newPos.y = yPos;

        Go.to( transform , 0.5f , new GoTweenConfig().position( newPos ).setEaseType( GoEaseType.BackInOut ) );

        yield return new WaitForSeconds( 0.5f );
        transform.position = newPos;

        Go.to( body , 0.25f , new GoTweenConfig().scale( bodyScale ).setEaseType( GoEaseType.BackOut ) );

        if ( charge )
        {
            GameObject punch = GameObject.CreatePrimitive( PrimitiveType.Cube );
            punch.GetComponent<MeshRenderer>().material = attackMaterial;
            punch.transform.position = transform.position;
            punch.transform.localScale = Vector3.zero;

            GoTweenChain chain = new GoTweenChain();
            GoTween growTween = Go.to( punch.transform , chargeBlinkFXTime * 0.25f , new GoTweenConfig().scale( Vector3.one * 3 ).setEaseType( GoEaseType.BackOut ) );
            GoTween shrinkTween = Go.to( punch.transform , chargeBlinkFXTime * 0.75f , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ) );
            chain.append( growTween );
            chain.append( shrinkTween );
            chain.play();

            yield return new WaitForSeconds( chargeBlinkFXTime );
            yield return new WaitForSeconds( blinkRecoverTime );
        }
        else
            yield return new WaitForSeconds( 0.25f );

        Go.killAllTweensWithTarget( body.GetChild( 0 ).GetComponent<MeshRenderer>() );
        Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) );
        _blink = false;
    }
Esempio n. 19
0
    private IEnumerator ChargeStomp_Coroutine ( Vector3 direction )
    {
        _chargeStomp = true;
        bool effect = false;
        GoTweenChain chain = new GoTweenChain();
        GameObject stomp = GameObject.CreatePrimitive( PrimitiveType.Cube );
        stomp.GetComponent<MeshRenderer>().material = attackMaterial;
        stomp.transform.localScale = Vector3.zero;

        Go.to( body , chargeStompFXDuration * 0.3f , new GoTweenConfig().localPosition( Vector3.up * 0.5f , true ).setEaseType( GoEaseType.BackOut ) );
        Go.to( body , chargePunchFXDuration * 0.3f , new GoTweenConfig().rotation( Quaternion.LookRotation( direction ) ) );

        yield return new WaitForSeconds( chargeStompFXDuration * 0.3f );

        Go.to( body , chargeStompFXDuration * 0.7f , new GoTweenConfig().localPosition( Vector3.zero ).setEaseType( GoEaseType.BackOut ) );
        float time = 0;

        while ( chargeStompFXDuration * 0.7f > time )
        {
            if ( !effect && time > chargeStompFXDuration * 0.2f )
            {
                effect = true;
                stomp.transform.position = transform.position + ( Vector3.down * 0.25f );

                GoTween effectGrow = new GoTween( stomp.transform , 0.2f , new GoTweenConfig().scale( new Vector3( 3 , 0.5f , 3 ) ).setEaseType( GoEaseType.BackOut ) );
                GoTween effectShrink = new GoTween( stomp.transform , 1f , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ) );
                chain.append( effectGrow );
                chain.append( effectShrink );
                chain.play();
            }

            time += Time.deltaTime;
            yield return null;
        }

        yield return chain.waitForCompletion();
        Destroy( stomp );

        yield return new WaitForSeconds( chargeStompRecoverTime );
        Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) );
        _chargeStomp = false;
    }
Esempio n. 20
0
    internal ComboPaneResolution TryResolvingState( Player player, List<InputActionName> inputs )
    {
        if ( isCompleted )
            return ComboPaneResolution.Completed;

        bool isFailed = false;

        int activatedCount = 0;
        for ( int i = 0; i < combo.actions.Count; i++ )
        {
            if ( i < inputs.Count )
                if ( inputs[i] == combo.actions[i] )
                    activatedCount++;
                else
                {
                    isFailed = true;
                    break;
                }
        }

        if ( player.playerSide == PlayerSide.Left )
            activatedCountPlayerLeft = activatedCount;

        if ( player.playerSide == PlayerSide.Right )
            activatedCountPlayerRight = activatedCount;

        if ( isFailed )
        {
            return ComboPaneResolution.Failed;
        }

        isCompleted = ( activatedCount == buttons.Count );
        if ( isCompleted )
        {
            state = ComboPaneState.Absorbed;

            player.PrepareAttack ( Size );

            GoTweenChain chain = new GoTweenChain();
            chain.append ( transform.scaleTo ( 0.125f, 1.5f ).eases ( GoEaseType.Linear ) );
            chain.append ( transform.scaleTo ( 0.125f, 1.0f ).eases ( GoEaseType.Linear ) );

            chain.insert ( 0.25f, transform.scaleTo ( 1.25f, 0.25f ).eases ( GoEaseType.QuadInOut ) );
            chain.insert ( 0.25f, transform.positionTo ( 1.25f,
                player.ComboCollectPosition
                ).eases ( GoEaseType.QuadInOut ) );
            chain.setOnCompleteHandler ( c => {
                gameObject.DestroySelf ();
                } );
            chain.Start ();

            return ComboPaneResolution.Completed;
        }
        else
        {
            return ComboPaneResolution.NotCompleted;
        }
    }
Esempio n. 21
0
    void applyJumpSkillMove(List <Dictionary <string, string> > boxDataDict)
    {
        var rigidBody = gameObject.GetComponent <Rigidbody>();

        //rigidBody.velocity = testVelocity;

        gtc = new GoTweenChain();
        gtc.autoRemoveOnComplete = true;

        List <Dictionary <string, float> > atkOffsets = new List <Dictionary <string, float> >();

        int bi = 0;

        foreach (var boxData in boxDataDict)
        {
            if (boxData["self_aff"] != "跳跃")
            {
                break;
            }

            char[]   delimiterChars = { ',' };
            string[] sdata          = boxData["self_param"].Split(delimiterChars);

            if (sdata.Length < 3)
            {
                break;
            }

            List <float> fdata = new List <float>();
            foreach (string s in sdata)
            {
                fdata.Add(Convert.ToSingle(s));
            }
            float startTime = fdata[0];
            float angle     = fdata[1];
            float speed     = fdata[2];

            float vx = speed * Mathf.Cos(Mathf.Deg2Rad * angle);
            float vy = speed * Mathf.Sin(Mathf.Deg2Rad * angle);

            Dictionary <string, float> offsetData = new Dictionary <string, float>();
            offsetData["startTime"] = startTime;
            offsetData["velocityX"] = vx;
            offsetData["velocityY"] = vy;
            atkOffsets.Add(offsetData);

            var curData = atkOffsets[bi];
            if (bi >= 1)
            {
                var preData = atkOffsets[bi - 1];
                curData["delay"] = startTime - preData["startTime"];
            }
            else
            {
                if (startTime > 0)
                {
                    curData["delay"] = startTime;
                }
            }
            ++bi;
        }

        foreach (var v in atkOffsets)
        {
            if (v.ContainsKey("delay"))
            {
                var gtconfig = new GoTweenConfig();
                gtc.append(new GoTween(
                               gameObject.transform,
                               v["delay"],
                               gtconfig.onComplete(delegate(AbstractGoTween obj)
                {
                    rigidBody.velocity = new Vector3(v["velocityX"], v["velocityY"], 0.0f);
                })
                               ));
            }
        }

        var cbcon = new GoTweenConfig();

        gtc.append(new GoTween(
                       gameObject.transform,
                       0.01f,
                       cbcon.onComplete(delegate(AbstractGoTween obj)
        {
            //DestroyEfx ();
        })
                       ));

        gtc.appendDelay(2.0f);
        var con = new GoTweenConfig();

        gtc.append(new GoTween(
                       gameObject.transform,
                       0.01f,
                       con.position(Vector3.zero, false).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate)
                       ));
        gtc.play();
    }
Esempio n. 22
0
    void applyNonJumpSkillMove(List <Dictionary <string, string> > boxDataDict)
    {
        gtc = new GoTweenChain();
        gtc.autoRemoveOnComplete = true;

        List <Dictionary <string, float> > atkOffsets = new List <Dictionary <string, float> >();

        int bi = 0;

        foreach (var boxData in boxDataDict)
        {
            if (boxData["self_aff"] != "位移")
            {
                break;
            }

            char[]   delimiterChars = { ',' };
            string[] sdata          = boxData["self_param"].Split(delimiterChars);

            if (sdata.Length < 3)
            {
                break;
            }

            List <float> fdata = new List <float>();
            foreach (string s in sdata)
            {
                fdata.Add(Convert.ToSingle(s));
            }
            float startTime = fdata[0] / 24;
            float speed     = fdata[1];
            float dist      = fdata[2];
            float duration  = Mathf.Abs(dist / speed);

            speed = dist / duration;

            Dictionary <string, float> offsetData = new Dictionary <string, float>();
            offsetData["startTime"] = startTime;
            offsetData["endTime"]   = startTime + duration;
            offsetData["curTime"]   = 0;
            offsetData["totalTime"] = duration;
            offsetData["speed"]     = speed;
            atkOffsets.Add(offsetData);

            if (bi >= 1)
            {
                var preData = atkOffsets[bi - 1];
                if (preData["endTime"] > startTime)
                {
                    preData["endTime"]   = startTime;
                    preData["totalTime"] = startTime - preData["startTime"];
                }
                else
                {
                    preData["delay"] = startTime - preData["endTime"];
                }
            }
            else
            {
                var curData = atkOffsets[bi];
                if (startTime > 0)
                {
                    curData["delay"] = startTime;
                }
            }

            ++bi;
        }

        foreach (var v in atkOffsets)
        {
            if (v.ContainsKey("delay"))
            {
                gtc.appendDelay(v["delay"]);
            }

            var gtconfig = new GoTweenConfig();
            if (v["totalTime"] > 0)
            {
                var dirInc = new Vector3(v["speed"] * v["totalTime"], 0, 0);
                gtc.append(new GoTween(
                               gameObject.transform,
                               v["totalTime"],
                               gtconfig.position(dirInc, true).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate)
                               ));
            }
        }



        var cbcon = new GoTweenConfig();

        gtc.append(new GoTween(
                       gameObject.transform,
                       0.01f,
                       cbcon.onComplete(delegate(AbstractGoTween obj)
        {
            //DestroyEfx ();
        })
                       ));

        gtc.appendDelay(2.0f);
        var con = new GoTweenConfig();

        gtc.append(new GoTween(
                       gameObject.transform,
                       0.01f,
                       con.position(Vector3.zero, false).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate)
                       ));
        gtc.play();
    }
Esempio n. 23
0
    public void go(FSprite node, float period, Color toColor  )
    {
        Cancel (node);

        //Debug.Log ("OscilColorUtil node="+node);
        chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong));
        chain.autoRemoveOnComplete=true;
        //chain.setIterations( -1, LoopType.PingPong );
        GoTweenConfig config0=new GoTweenConfig();
        config0.colorProp("color",toColor);
        config0.setEaseType(GoEaseType.SineInOut);

        chain.append( new GoTween( node, period, config0 ) );
        chain.play();

        memoColor=node.color;
        pendings.Add(node,this);
    }
Esempio n. 24
0
    public void go(FSprite sprite_,FAtlasElement element,float duration_)
    {
        Cancel(sprite_);

        _switchToElment=element;
        _sprite=sprite_;
        _scaleY=_sprite.scaleY;

        pendings.Add(_sprite,this);

        _chain=new GoTweenChain(new GoTweenCollectionConfig().setIterations(1,GoLoopType.PingPong));
        _chain.autoRemoveOnComplete=true;

        GoTweenConfig config;

        config=new GoTweenConfig().floatProp("scaleY",0f).onComplete(HandleSwitchElement);
        config.easeType=GoEaseType.ExpoOut;

        _chain.append(Go.to(sprite_,duration_*0.5f,config));

        config=new GoTweenConfig().floatProp("scaleY",_scaleY).onComplete(HandleEndAnim);
        config.easeType=GoEaseType.ExpoOut;
        _chain.append(Go.to(sprite_,duration_*0.5f,config));

        _chain.play();
    }
Esempio n. 25
0
    private void Move(Transform target, Vector3 to, Vector3 back, float duration)
    {
       
        animationReady = false;

        Go.defaultEaseType = GoEaseType.Linear;
        var moveUpConfig = new GoTweenConfig().position( to, true );
        var moveBackConfig = new GoTweenConfig().position( -back, true );
        moveBackConfig.onComplete(orginalTween => Done());

        var tweenOne = new GoTween( target, duration, moveUpConfig);
        var tweenTwo = new GoTween( target, duration, moveBackConfig);


        var chain = new GoTweenChain();
        chain.append(tweenOne).append(tweenTwo);

        chain.play();

    }
Esempio n. 26
0
    IEnumerator AnimateItems(IEnumerable <ItemMovementDetails> movementDetails)
    {
        List <GameObject> objectsToDestroy = new List <GameObject>();

        foreach (var item in movementDetails)
        {
            //calculate the new position in the world space
            var newGoPosition = new Vector3(item.NewColumn + item.NewColumn * distance,
                                            item.NewRow + item.NewRow * distance, ZIndex);

            //move it there
            var tween =
                item.GOToAnimatePosition.transform.positionTo(Globals.AnimationDuration, newGoPosition);
            tween.autoRemoveOnComplete = true;

            //the scale is != null => this means that this item will also move and duplicate
            if (item.GOToAnimateScale != null)
            {
                var duplicatedItem = matrix[item.NewRow, item.NewColumn];

                UpdateScore(duplicatedItem.Value);

                //check if the item is 2048 => game has ended
                if (duplicatedItem.Value == 2048)
                {
                    gameState = GameState.Won;
                    yield return(new WaitForEndOfFrame());
                }

                //create the duplicated item
                var newGO = Instantiate(GetGOBasedOnValue(duplicatedItem.Value), newGoPosition, Quaternion.identity) as GameObject;

                //make it small in order to animate it
                newGO.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
                newGO.transform.scaleTo(Globals.AnimationDuration, 1.0f);

                //assign it to the proper position in the array
                matrix[item.NewRow, item.NewColumn].GO = newGO;

                //we need two animations to happen in chain
                //first, the movement animation
                var moveTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().position(newGoPosition));
                //then, the scale one
                var scaleTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().scale(0.1f));

                var chain = new GoTweenChain();
                chain.autoRemoveOnComplete = true;
                chain.append(moveTween).appendDelay(Globals.AnimationDuration).append(scaleTween);
                chain.play();

                //destroy objects after the animations have ended
                objectsToDestroy.Add(item.GOToAnimateScale);
                objectsToDestroy.Add(item.GOToAnimatePosition);
            }
        }

        CreateNewItem();
        //hold on till the animations finish
        yield return(new WaitForSeconds(Globals.AnimationDuration * movementDetails.Count() * 3));

        foreach (var go in objectsToDestroy)
        {
            Destroy(go);
        }
    }
Esempio n. 27
0
    public void go(FNode node, float period, float scaleX, float scaleY)
    {
        Cancel (node);

        chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong));
        chain.autoRemoveOnComplete=true;
        //chain.setIterations( -1, LoopType.PingPong );
        GoTweenConfig config0=new GoTweenConfig();

        if (scaleX!=node.scaleX) config0.floatProp( "scaleX", scaleX );
        if (scaleY!=node.scaleY) config0.floatProp( "scaleY", scaleY );

        config0.setEaseType(GoEaseType.SineInOut);

        chain.append( new GoTween( node, period, config0 ) );
        chain.play();

        memoScaleX=node.scaleX;
        memoScaleY=node.scaleY;
        pendings.Add(node,this);
    }
Esempio n. 28
0
    internal static GoTweenChain animateJellyInfinite( this Transform transform, float time, float value, GoEaseType ease = GoEaseType.QuadInOut )
    {
        GoTweenChain chain = new GoTweenChain ();

        Vector3 scaleAtStart = transform.localScale;
        Vector3 target = new Vector3 ( scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z );
        transform.localScale = target;

        target = new Vector3 ( scaleAtStart.x + value, scaleAtStart.y - value, scaleAtStart.z );
        chain.append ( transform.scaleTo ( time, target ).eases ( ease ) );

        target = new Vector3 ( scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z );
        chain.append ( transform.scaleTo ( time, target ).eases ( ease ) );

        chain.loopCount = -1;
        chain.play ();

        return chain;
    }
Esempio n. 29
0
    public void go(FSprite node, float period, float toAlpha  )
    {
        Cancel (node);

        chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong));
        chain.autoRemoveOnComplete=true;
        //chain.setIterations( -1, LoopType.PingPong );
        GoTweenConfig config0=new GoTweenConfig();
        config0.floatProp("alpha",toAlpha);
        config0.setEaseType(GoEaseType.SineInOut);

        chain.append( new GoTween( node, period, config0 ) );
        chain.play();

        memoAlpha=node.alpha;
        pendings.Add(node,this);
    }
Esempio n. 30
0
    public void go(FNode node, float period, float ampX, float ampY)
    {
        Cancel (node);

        chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong));
        chain.autoRemoveOnComplete=true;
        //chain.setIterations( -1, LoopType.PingPong );
        GoTweenConfig config0=new GoTweenConfig();

        if (ampX!=0) config0.floatProp( "x", node.x+ampX );
        if (ampY!=0) config0.floatProp( "y", node.y+ampY );

        config0.setEaseType(GoEaseType.SineInOut);

        chain.append( new GoTween( node, period, config0 ) );
        chain.play();

        pendings.Add(node,this);
    }
Esempio n. 31
0
    internal static GoTweenChain animateJelly( this Transform transform, float time, float value, int repeatCount = 1, GoEaseType ease = GoEaseType.QuadInOut )
    {
        Vector3 scaleAtStart = transform.localScale;

        GoTweenChain chain = new GoTweenChain ();
        for ( int i = repeatCount; i > 0; i-- )
        {
            float factor = ( (float)i ) / repeatCount;

            Vector3 target = new Vector3 ( scaleAtStart.x + ( value * factor ), scaleAtStart.y - ( value * factor ), scaleAtStart.z );
            chain.append ( transform.scaleTo ( time * factor, target ).eases ( ease ) );

            target = new Vector3 ( scaleAtStart.x - ( value * factor ), scaleAtStart.y + ( value * factor ), scaleAtStart.z );
            chain.append ( transform.scaleTo ( time * factor, target ).eases ( ease ) );
        }

        chain.append ( transform.scaleTo ( time / repeatCount, scaleAtStart ).eases ( ease ) );
        chain.play ();

        return chain;
    }
Esempio n. 32
0
    IEnumerator AnimateItems(IEnumerable<ItemMovementDetails> movementDetails)
    {
        List<GameObject> objectsToDestroy = new List<GameObject>();
        foreach (var item in movementDetails)
        {
            //calculate the new position in the world space
            var newGoPosition = new Vector3(item.NewColumn + item.NewColumn * distance,
                item.NewRow + item.NewRow * distance, ZIndex);

            //move it there
            var tween =
                item.GOToAnimatePosition.transform.positionTo(Globals.AnimationDuration, newGoPosition);
            tween.autoRemoveOnComplete = true;

            //the scale is != null => this means that this item will also move and duplicate
            if (item.GOToAnimateScale != null)
            {
                var duplicatedItem = matrix[item.NewRow, item.NewColumn];

                UpdateScore(duplicatedItem.Value);

                //check if the item is 2048 => game has ended
                if (duplicatedItem.Value == 2048)
                {
                    gameState = GameState.Won;
                    yield return new WaitForEndOfFrame();
                }

                //create the duplicated item
                var newGO = Instantiate(GetGOBasedOnValue(duplicatedItem.Value), newGoPosition, Quaternion.identity) as GameObject;

                //make it small in order to animate it
                newGO.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
                newGO.transform.scaleTo(Globals.AnimationDuration, 1.0f);

                //assign it to the proper position in the array
                matrix[item.NewRow, item.NewColumn].GO = newGO;

                //we need two animations to happen in chain
                //first, the movement animation
                var moveTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().position(newGoPosition));
                //then, the scale one
                var scaleTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().scale(0.1f));

                var chain = new GoTweenChain();
                chain.autoRemoveOnComplete = true; //important -> https://github.com/prime31/GoKit/wiki/5.-TweenChains:-Chaining-Multiple-Tweens
                chain.append(moveTween).appendDelay(Globals.AnimationDuration).append(scaleTween);
                chain.play();

                //destroy objects after the animations have ended
                objectsToDestroy.Add(item.GOToAnimateScale);
                objectsToDestroy.Add(item.GOToAnimatePosition);
            }
        }

        CreateNewItem();
        //hold on till the animations finish
        yield return new WaitForSeconds(Globals.AnimationDuration * movementDetails.Count() * 3);
        foreach (var go in objectsToDestroy)
            Destroy(go);
    }
Esempio n. 33
0
    public void go(FNode node,System.Action<FNode> action,float duration_)
    {
        Cancel(node);

        _action=action;
        _node=node;
        _scaleY=node.scaleY;

        pendings.Add(_node,this);

        _chain=new GoTweenChain(new GoTweenCollectionConfig().setIterations(1,GoLoopType.PingPong));
        _chain.autoRemoveOnComplete=true;

        GoTweenConfig config;

        config=new GoTweenConfig().floatProp("scaleY",0f).onComplete(HandleMidAnim);
        config.easeType=GoEaseType.ExpoOut;

        _chain.append(Go.to(_node,duration_*0.5f,config));

        config=new GoTweenConfig().floatProp("scaleY",_scaleY).onComplete(HandleEndAnim);
        config.easeType=GoEaseType.ExpoOut;
        _chain.append(Go.to(_node,duration_*0.5f,config));

        _chain.play();
    }