Inheritance: AbstractGoTween
    public void Event()
    {
        if(firstRun) {
            firstRun = false;
            spline = new GoSpline(eventPath);
            var pathProperty = new PositionPathTweenProperty(spline);

            var config = new GoTweenConfig();
            config.addTweenProperty(pathProperty);

            var tween = new GoTween(PoPCamera.instance.transform, pathLength, config);
            Go.addTween(tween);
            if(multipleTargets) {
                focusTimer = focusPoints[0].time;
            }
        }

        if(multipleTargets) {
            if(focusTimer >= focusPoints[focusIndex].time && focusIndex != focusPoints.Count - 1) {
                focusIndex++;
            }
            Quaternion rotation = Quaternion.LookRotation(focusPoints[focusIndex].focus - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        } else {
            Quaternion rotation = Quaternion.LookRotation(singleTargetPos - PoPCamera.instance.transform.position);
            PoPCamera.instance.transform.rotation = Quaternion.Slerp(PoPCamera.instance.transform.rotation, rotation, 0.4f);
        }

        if(pathLength < 0) {
            PoPCamera.State = Camera_2.CameraState.Normal;
            Destroy(this.gameObject);
        } else
            pathLength -= Time.deltaTime;
    }
Exemple #2
0
	public static GoTween MakeTween(
		Transform TheTransform, 
		Vector3 Position, 
		Quaternion Rotation, 
		float MoveTime = 0.5f, 
		bool IsLocal = false, 
		GoEaseType Ease = GoEaseType.Linear,
		VoidDelegate OnCompleteFunction = null
		)
	{
		GoTweenConfig Config = new GoTweenConfig();
		Config.addTweenProperty(new PositionTweenProperty(Position, false, IsLocal));
		//Config.addTweenProperty(new EulerAnglesTweenProperty(Rotation, false, IsLocal));
		Config.addTweenProperty(new RotationQuaternionTweenProperty(Rotation, false, IsLocal));
		Config.setEaseType(Ease);
		if(OnCompleteFunction != null){
			Config.onComplete(c => {
				OnCompleteFunction();
			});
		}
		GoTween NewTween = new GoTween(TheTransform, MoveTime, Config);
		Go.addTween(NewTween);
		
		return NewTween;
	}
    void Start()
    {
        Application.targetFrameRate = 60;

        Go.defaultEaseType = GoEaseType.Linear;
        Go.duplicatePropertyRule = GoDuplicatePropertyRuleType.None;
        Go.validateTargetObjectsEachTick = true;
        var sharedTweenConfig = new GoTweenConfig();

        for( i = 0; i < cubes.Length; i++ )
        {

            var cube = GameObject.CreatePrimitive( PrimitiveType.Cube );
            //int r = Random.Range(0, Buildings.Count);
            //var cube = (GameObject)Instantiate(Buildings[r]);
            Destroy( cube.GetComponent<BoxCollider>() );
            cube.transform.position = new Vector3( i * 0.1f - 10, cube.transform.position.y, i % 100 );
            cubes[i] = cube;
            origPos[i] = cube.transform.position;

            props[i] = new PositionTweenProperty( Vector3.zero );
            tweens[i] = new GoTween( cubes[i].transform, 1.0f, sharedTweenConfig );
            tweens[i].autoRemoveOnComplete = false;
            tweens[i].addTweenProperty( props[i] );
            tweens[i].pause();
            Go.addTween( tweens[i] );
        }

        StartCoroutine( runTest() );
    }
Exemple #4
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 flow and set it to have 2 iterations
        var flow = new GoTweenFlow(new GoTweenCollectionConfig().setIterations( 2 ));

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

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

            // increment our startTime so that the next tween starts when this one is halfway done
            startTime += 0.25f;
        }

        _tween = flow;
    }
 public override void init( GoTween owner )
 {
     base.init(owner);
     //Init owner of _tweenProperty and force ease type to linear
     _tweenProperty.setEaseType(GoEaseType.Linear);
     _tweenProperty.init(owner);
 }
Exemple #6
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;
	}
    public void Wider()
    {
        if ( zoomTween != null )
            zoomTween.destroy ();

        zoomTween = Go.to ( this, kFovChangeDuration, new GoTweenConfig ().floatProp ("zoom", 0).onComplete ( t => OnWidened ()));
    }
    public override void init ( GoTween owner )
    {
        // setup our target before initting
        if ( owner.target is Renderer )
            _target = ( Renderer ) owner.target;

        base.init( owner );
    }
	/// <summary>
	/// called by a Tween just after this property is validated and added to the Tweens property list
	/// </summary>
	public virtual void init( GoTween owner )
	{
		_isInitialized = true;
		_ownerTween = owner;
		
		// if we dont have an easeFunction use the owners type
		if( _easeFunction == null )
			setEaseType( owner.easeType );
	}
Exemple #10
0
    public void TweenVolumeTo( float newVolume, float duration )
    {
        if ( volumeTween != null )
            volumeTween.destroy();

        volumeTween = Go.to(this, duration, new GoTweenConfig()
                                        .floatProp("volume", newVolume)
                                        .onComplete( t => { volumeTween = null; } ));
    }
Exemple #11
0
    void Start()
    {
        if ( Path != null )
        {
            tween = Path.GetComponent<PointPath> ().Animate ( gameObject, Duration, Ease, LoopInfinitely, IsRelative );

            if ( StartTime != 0 )
                tween.goTo ( StartTime );
        }
    }
Exemple #12
0
    public void SetToDark()
    {
        if ( fadeTween != null )
            fadeTween.destroy();

        fadeTween = null;
        isFading = false;

        alpha = 1;
    }
Exemple #13
0
 static public int get_easeCurve(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         pushValue(l, self.easeCurve);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    void Start()
    {
        var config = new GoTweenConfig().localRotation(new Vector3(-30, 0, 0)).setEaseType(GoEaseType.CubicInOut);
        config.loopType = GoLoopType.PingPong;
        config.setIterations(-1);

        float duration = 2;

        var tween = new GoTween(transform, duration, config);
        Go.addTween(tween);
    }
Exemple #15
0
    private void OnScoreChanged(int newScore)
    {
        if (GameController.I.GameMode == GameController.GameModeType.Endless)
        {
            if (newScore > PlayerData.HighScore)
            {
                PlayerData.SetHighscore(newScore);
                HeaderController.I.UpdateHighScore(newScore);
            }

            var milestoneProgress = GameController.I.MilestoneProgress(newScore);
            if (milestoneChangeTween != null && milestoneChangeTween.state == GoTweenState.Running)
            {
                milestoneChangeTween.destroy();
            }
            milestoneChangeTween = Go.to(milestoneScoreSlider, scoreChangeDuration,
                                         new GoTweenConfig().floatProp("value", milestoneProgress)
                                         .setEaseType(scoreChangeEaseType)
                                         .setDelay(scoreChangeDelay)
                                         );
            milestoneChangeTween.setOnCompleteHandler(t =>
            {
                if (newScore >= GameController.I.MilestonePoint)
                {
                    GameController.I.NextMilestone();
                }
            });
        }

        if (!GameController.I.HasTargetScore)
        {
            return;
        }

        var progress = (float)newScore / GameController.I.TargetScore;

        if (GameController.I.IsPlaying)
        {
            if (scoreChangeTween != null && scoreChangeTween.state == GoTweenState.Running)
            {
                scoreChangeTween.destroy();
            }
            scoreChangeTween = Go.to(targetScoreSlider, scoreChangeDuration,
                                     new GoTweenConfig().floatProp("value", progress)
                                     .setEaseType(scoreChangeEaseType)
                                     .setDelay(scoreChangeDelay)
                                     );
        }
        else
        {
            // instant change
            targetScoreSlider.value = progress;
        }
    }
Exemple #16
0
 static public int complete(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         self.complete();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #17
0
 static public int clearDidInitFlag(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         self.clearDidInitFlag();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #18
0
 static public int prepareAllTweenProperties(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         self.prepareAllTweenProperties();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #19
0
 static public int get_easeType(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         pushEnum(l, (int)self.easeType);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #20
0
    public static GoTween alphaTo(this Material self, float duration, float endValue)
    {
        GoTween tween = self.alphaTo(duration, endValue, MaterialUtils._ColorNameId, "_Color");

        if (self.HasProperty(MaterialUtils._EmissionColorNameId))
        {
            Go.to(self, duration, new GoTweenConfig().materialColor(Color.black, "_EmissionColor"));
        }

        return(tween);
    }
    /// <summary>
    /// called by a Tween just after this property is validated and added to the Tweens property list
    /// </summary>
    public virtual void init(GoTween owner)
    {
        _isInitialized = true;
        _ownerTween    = owner;

        // if we dont have an easeFunction use the owners type
        if (_easeFunction == null)
        {
            setEaseType(owner.easeType);
        }
    }
Exemple #22
0
 public void EndTalk()
 {
     background.Hide();
     if (kingAnimation != null)
     {
         kingAnimation.destroy();
     }
     kingAnimation = Go.to(king.transform, 0.6f, new GoTweenConfig().position(startPosition).setEaseType(GoEaseType.BackInOut));
     Go.to(bubble, 0.25f, new GoTweenConfig().colorProp("color", invisibleColor));
     Go.to(bubbleText, 0.25f, new GoTweenConfig().colorProp("color", noTextColor));
 }
Exemple #23
0
    public static GoTween from(object target, GoSpline path, float speed, GoTweenConfig config)
    {
        config.setIsFrom();
        path.buildPath();
        float duration = path.pathLength / speed;
        var   tween    = new GoTween(target, duration, config);

        addTween(tween);

        return(tween);
    }
Exemple #24
0
    // set up the tweens used in health behavior
    protected void InitializeTweens()
    {
        // Tween configuration
        MaterialColorTweenProperty red = new MaterialColorTweenProperty(Color.red);
        GoTweenConfig rConfig = new GoTweenConfig();
        rConfig.addTweenProperty(red);
        rConfig.setIterations(6);
        rConfig.loopType = GoLoopType.PingPong;

        // Make a tween to turn the gameObject red
        turnRed = new GoTween(this.gameObject, .5f, rConfig);
    }
    public void ConstantSpeedTo(float targetOpacity, float fadeSpeed)
    {
        this.targetOpacity = targetOpacity;
        this.fadeSpeed     = fadeSpeed;
        state = State.ConstantSpeed;

        if (fadeTween != null)
        {
            fadeTween.destroy();
            fadeTween = null;
        }
    }
Exemple #26
0
 static public int isValid(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         var     ret  = self.isValid();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #27
0
    private void DoSlide(float speedThisRound)
    {
        var   sliderStart   = barBeginXform.position;
        var   sliderEnd     = barEndXform.position;
        float slideDuration = Mathf.Abs(sliderEnd.x - sliderStart.x) / speedThisRound;
        var   tweenCfg      = new GoTweenConfig()
                              .position(sliderEnd)
                              .onComplete(OnSliderReachedEnd);

        slider.position = sliderStart;
        sliderTween     = Go.to(slider, slideDuration, tweenCfg);
    }
Exemple #28
0
    public void playSwapAnimation(SpriteRenderer render2)
    {
        SFXManager.instance.PlaySFX(Clip.Swap);
        Transform firstSpriteTransform  = transform;
        Transform secondSpriteTransform = render2.GetComponent <Tile>().transform;

        GoTween firstTransformTween  = transform.positionTo(0.3f, secondSpriteTransform.position);
        GoTween SecondTransformTween = secondSpriteTransform.positionTo(0.3f, firstSpriteTransform.position);

        firstTransformTween.setOnCompleteHandler(OnFirstCompleteHandler);
        SecondTransformTween.setOnCompleteHandler(OnSecondCompleteHandler);
    }
Exemple #29
0
    public override void DoClickToAct()
    {
        RotationTweenProperty rotationProperty = new RotationTweenProperty (new Vector3 (0, -90, 0), true, true);

        GoTweenConfig config = new GoTweenConfig();
        config.addTweenProperty( rotationProperty );

        var tween = new GoTween( transform, openingTime, config, OnOpenComplete );
        Go.addTween (tween);

        GetComponent<AudioSource>().PlayOneShot (doorOpenSound, doorOpenSoundVolume);
    }
    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;
    }
Exemple #31
0
 public static Func <float, float, float, float, float> EaseCurve(GoTween tween)
 {
     if (tween == null)
     {
         UnityEngine.Debug.LogError("no tween to extract easeCurve from");
     }
     if (tween.easeCurve == null)
     {
         UnityEngine.Debug.LogError("no curve found for tween");
     }
     return((float t, float b, float c, float d) => tween.easeCurve.Evaluate(t / d) * c + b);
 }
Exemple #32
0
    public void SetToDark()
    {
        if (fadeTween != null)
        {
            fadeTween.destroy();
        }

        fadeTween = null;
        isFading  = false;

        alpha = 1;
    }
Exemple #33
0
    public void ConstantSpeedTo( float targetOpacity, float fadeSpeed )
    {
        this.targetOpacity = targetOpacity;
        this.fadeSpeed = fadeSpeed;
        state = State.ConstantSpeed;

        if ( fadeTween != null )
        {
            fadeTween.destroy();
            fadeTween = null;
        }
    }
Exemple #34
0
 static public int allTweenProperties(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         var     ret  = self.allTweenProperties();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #35
0
    void FlapHandler( BirdMovement movement )
    {
        if( _tween != null )
        {
            _tween.destroy();
        }

        transform.localScale = new Vector3( 2f, 3f, 2f );
        _tween = Go.to( transform, 0.2f, new GoTweenConfig()
            .scale( Vector3.one )
            .setEaseType( GoEaseType.SineOut )
        );
    }
Exemple #36
0
 static public int set_easeType(IntPtr l)
 {
     try {
         GoTween    self = (GoTween)checkSelf(l);
         GoEaseType v;
         checkEnum(l, 2, out v);
         self.easeType = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #37
0
    /// <summary>
    /// helper function that creates a "to" Tween and adds it to the pool
    /// </summary>
    public static GoTween to(object target, float duration, GoTweenConfig config)
    {
        if (duration == 0)
        {
            throw new System.Exception("Duration is zero ! Tween on object " + target.ToString());
        }

        var tween = new GoTween(target, duration, config);

        addTween(tween);

        return(tween);
    }
Exemple #38
0
 static public int set_easeCurve(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         UnityEngine.AnimationCurve v;
         checkType(l, 2, out v);
         self.easeCurve = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #39
0
 static public int addTweenProperty(IntPtr l)
 {
     try {
         GoTween self = (GoTween)checkSelf(l);
         AbstractTweenProperty a1;
         checkType(l, 2, out a1);
         self.addTweenProperty(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    public void TweenPosition(Vector3 position)
    {
        if (currentTween != null)
        {
            StopTween();
        }

        currentTween = Go.to(transform, GM.options.tweenTime, new GoTweenConfig()
                             .position(position)
                             .setEaseType(GoEaseType.ExpoOut));

        currentTween.setOnCompleteHandler(c => { onMoveComplete(); });
    }
Exemple #41
0
    /// <summary>
    /// returns a list of all Tweens with the given target. TweenChains and TweenFlows can optionally
    /// be traversed and matching Tweens returned as well.
    /// </summary>
    public static List <GoTween> tweensWithTarget(object target, bool traverseCollections = false)
    {
        List <GoTween> list = new List <GoTween>();

        for (int i = 0; _tweens.Count > i; i++)
        {
            GoTween tween = _tweens[i] as GoTween;

            if (tween != null && tween.target == target)
            {
                list.Add(tween);
            }

            // optionally check TweenChains and TweenFlows. if tween is null we have a collection
            if (traverseCollections && tween == null)
            {
                AbstractGoTweenCollection tweenCollection = ( AbstractGoTweenCollection )_tweens[i];
                if (tweenCollection != null)
                {
                    List <GoTween> tweensInCollection = tweenCollection.tweensWithTarget(target);

                    if (tweensInCollection.Count > 0)
                    {
                        list.AddRange(tweensInCollection);
                    }
                }
            }
        }

        /*foreach ( var item in _tweens )
         * {
         *  // we always check Tweens so handle them first
         *  var tween = item as GoTween;
         *  if ( tween != null && tween.target == target )
         *      list.Add( tween );
         *
         *  // optionally check TweenChains and TweenFlows. if tween is null we have a collection
         *  if ( traverseCollections && tween == null )
         *  {
         *      var tweenCollection = item as AbstractGoTweenCollection;
         *      if ( tweenCollection != null )
         *      {
         *          var tweensInCollection = tweenCollection.tweensWithTarget( target );
         *          if ( tweensInCollection.Count > 0 )
         *              list.AddRange( tweensInCollection );
         *      }
         *  }
         * }*/

        return(list);
    }
Exemple #42
0
 public void StartTalk(List <string> talks, bool isIntro = false, bool generateStars = false)
 {
     FindObjectOfType <InputController>().HideButtons();
     this.talks         = talks;
     this.isIntro       = isIntro;
     this.generateStars = generateStars;
     background.Show();
     if (kingAnimation != null)
     {
         kingAnimation.destroy();
     }
     kingAnimation = Go.to(king.transform, 1.2f, new GoTweenConfig().position(talkPosition).setEaseType(GoEaseType.BackInOut));
     NextTalk();
 }
Exemple #43
0
 public void SignalMistake()
 {
     Progress           -= decreasePerMistake;
     delayTimeRemaining += mistakeDelayDuration;
     State = GameState.Delayed;
     if (backgroundAnimation != null)
     {
         backgroundAnimation.destroy();
     }
     backgroundAnimation = Go.to(Camera.main, mistakeDelayDuration / 2f, new GoTweenConfig()
                                 .colorProp("backgroundColor", mistakeColor)
                                 .setIterations(2, GoLoopType.PingPong)
                                 );
 }
    public void move(Vector3 pos, Vector3 scale)
    {
        if (gameLabelManager.moving) {

            currentTween.destroy();
        }

        currentTween = Go.to(transform, tweenTime, new GoTweenConfig()
            .position(pos)
            .scale(scale)
            .setEaseType(GoEaseType.ExpoOut));

        currentTween.setOnCompleteHandler(c => { onMoveComplete(); });
    }
Exemple #45
0
    // Update is called once per frame
    void Shrink()
    {
        var scaleProperty = new ScaleTweenProperty(new Vector3(0.1f, 0.1f, 0.1f));
        //var rotateProperty = new EulerAnglesTweenProperty(new Vector3(0f,0f,360f));
        var config = new GoTweenConfig();

        //config.addTweenProperty(rotateProperty);
        config.addTweenProperty(scaleProperty);

        tween = new GoTween(transform, fadeSpeed, config);


        Go.addTween(tween);
    }
	public override void init( GoTween owner )
	{
		// setup our target before initting
		if( owner.target is Material )
			_target = (Material)owner.target;
		else if( owner.target is GameObject )
			_target = ((GameObject)owner.target).renderer.material;
		else if( owner.target is Transform )
			_target = ((Transform)owner.target).renderer.material;
		else if( owner.target is Renderer )
			_target = ((Renderer)owner.target).material;
		
		base.init( owner );
	}
Exemple #47
0
    public override void DoClickToAct()
    {
        RotationTweenProperty rotationProperty = new RotationTweenProperty(new Vector3(0, -90, 0), true, true);

        GoTweenConfig config = new GoTweenConfig();

        config.addTweenProperty(rotationProperty);

        var tween = new GoTween(transform, openingTime, config, OnOpenComplete);

        Go.addTween(tween);

        GetComponent <AudioSource>().PlayOneShot(doorOpenSound, doorOpenSoundVolume);
    }
Exemple #48
0
    /// <summary>
    /// helper function that creates a "from" Tween and adds it to the pool
    /// </summary>
    public static GoTween from(object target, float duration, GoTweenConfig config)
    {
        if (duration == 0)
        {
            throw new System.Exception("Duration is zero !");
        }

        config.setIsFrom();
        var tween = new GoTween(target, duration, config);

        addTween(tween);

        return(tween);
    }
Exemple #49
0
    void OnMouseExit()
    {
        if (!StarManager.Instance.IsPlaying)
        {
            return;
        }

        if (moveAnimation != null)
        {
            moveAnimation.complete();
            moveAnimation.destroy();
        }
        moveAnimation = Go.to(transform, .4f, new GoTweenConfig().position(startPosition).setEaseType(GoEaseType.BackInOut));
    }
    public void move(Vector3 pos, Vector3 scale, float tweenTime)
    {
        if (playlistNavigationManager.moving && currentTween != null) {

            currentTween.destroy();
        }

        currentTween = Go.to(transform, tweenTime, new GoTweenConfig()
            .position(pos)
            .scale(scale)
            .setEaseType(GoEaseType.ExpoOut));

        currentTween.setOnCompleteHandler(c => { onMoveComplete(); });
    }
Exemple #51
0
    public void FadeOut( float duration=2, Action<CameraFader> onComplete = null )
    {
        if ( fadeTween != null )
            fadeTween.destroy();

        isFading = true;
        fadeTween = Go.to(this, duration, new GoTweenConfig()
                                .floatProp("alpha", 1f)
                                .setEaseType(GoEaseType.SineIn)
                                .onComplete( t => {
                                            isFading = false;
                                            fadeTween = null;
                                            if ( onComplete != null )
                                                onComplete(this);
                                            } ));
    }
Exemple #52
0
    public void HideGUI()
    {
        if ( notificationStatus != NotificationStatus.Nothing )
        {
            if (  notificationTween != null )
            {
                notificationTween.destroy ();
                notificationTween = null;
            }
            notificationText.text = "";
            notificationStatus = NotificationStatus.Nothing;
        }

        notificationText.gameObject.SetActive( false );

        fpsDisplay.showFPS = false;
    }
	public static Func<float, float, float, float, float> EaseCurve( GoTween tween )
	{
		if (tween == null)
		{
			Debug.LogError("no tween to extract easeCurve from");
		}

		if (tween.easeCurve == null)
		{
			Debug.LogError("no curve found for tween");
		}

		return delegate (float t, float b, float c, float d)
		{
			return tween.easeCurve.Evaluate(t / d) * c + b;
		};
	}
Exemple #54
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();
    }
Exemple #55
0
    private void Move(int index)
    {
        SetIndex(index);
        var target = (Vector2) pads.Pads[index].transform.position;

        jumpTween = Go.to(transform, manager.jumpDuration, new GoTweenConfig().position(target).setEaseType(manager.jumpEaseType));
        jumpTween.setOnBeginHandler(tween =>
        {
            frogAnimator.speed = 1f;
            canClick = false;
        });
        jumpTween.setOnCompleteHandler(tween =>
        {
            frogAnimator.speed = 0f;
            canClick = true;
        });
    }
Exemple #56
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();

    }
    void Awake()
    {
        text = ResolveTextSize (text, lineLenth);
        afterFetch = ResolveTextSize (afterFetch, lineLenth);
        _text = text;

        _originalScale = speechBubble.transform.localScale;
        speechBubble.enabled = false;
        textMesh.text = "";

        _twnExit = new GoTween (speechBubble.transform, 0.15f, new GoTweenConfig ().scale (_originalScale*0.001f).setEaseType(GoEaseType.ExpoOut).onComplete(OnExitComplete));
        speechBubble.transform.localScale = _originalScale * 0.001f;
        _twnEnter = new GoTween (speechBubble.transform, 0.15f, new GoTweenConfig ().scale (_originalScale).setEaseType(GoEaseType.BackOut).onComplete(OnEnterComplete));

        _twnEnter.pause ();
        _twnExit.pause ();
        _twnEnter.autoRemoveOnComplete = false;
        _twnExit.autoRemoveOnComplete = false;
        Go.addTween (_twnEnter);
        Go.addTween (_twnExit);
    }
Exemple #58
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);
    }
Exemple #59
0
    /// <summary>
    /// checks for duplicate properties. if one is found and the DuplicatePropertyRuleType is set to
    /// DontAddCurrentProperty it will return true indicating that the tween should not be added.
    /// this only checks tweens that are not part of an AbstractTweenCollection
    /// </summary>
    private static bool handleDuplicatePropertiesInTween( GoTween tween )
    {
        // first fetch all the current tweens with the same target object as this one
        var allTweensWithTarget = tweensWithTarget( tween.target );

        // store a list of all the properties in the tween
        var allProperties = tween.allTweenProperties();

        // loop through all the tweens with the same target
        foreach( var tweenWithTarget in allTweensWithTarget )
        {
            // loop through all the properties in the tween and see if there are any dupes
            foreach( var tweenProp in allProperties )
            {
                warn( "found duplicate TweenProperty {0} in tween {1}", tweenProp, tween );

                // check for a matched property
                if( tweenWithTarget.containsTweenProperty( tweenProp ) )
                {
                    // handle the different duplicate property rules
                    if( duplicatePropertyRule == GoDuplicatePropertyRuleType.DontAddCurrentProperty )
                    {
                        return true;
                    }
                    else if( duplicatePropertyRule == GoDuplicatePropertyRuleType.RemoveRunningProperty )
                    {
                        tweenWithTarget.removeTweenProperty( tweenProp );
                    }

                    return false;
                }
            }
        }

        return false;
    }
Exemple #60
0
    /// <summary>
    /// helper function that creates a "to" Tween and adds it to the pool
    /// </summary>
    public static GoTween to( object target, float duration, GoTweenConfig config )
    {
        var tween = new GoTween( target, duration, config );
        addTween( tween );

        return tween;
    }