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; }
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 Throw(Direction direction) { transform.SetScale(0.25f); transform.localEulerAngles = new Vector3(0, 0, direction.ToRotationAngle()); Vector2 localMoveVector = direction.ToVector2() * shootDistance; if (tween != null) { Debug.LogError("Tween is already running"); gameObject.DestroySelf(); } tween = new GoTweenChain(); tween.insert(0, transform.localPositionTo(shootDuration, localMoveVector, true).eases(shootEase)); tween.insert(0, transform.scaleTo(0.125f, 1).eases(GoEaseType.QuartIn)); tween.insert(0.25f, transform.scaleTo(0.5f, 0).eases(GoEaseType.QuadOut)); tween.insertAction(timeBetweenWeapons, () => { if (onEnd != null) { onEnd(); } }); tween.Start(); tween.setOnCompleteHandler(c => gameObject.DestroySelf()); }
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(); }
internal virtual void TakeDamage() { if (state == MonsterState.Living) { Vector3 splashVector = (transform.position - Player.Instance.transform.position).normalized; life -= 1; if (life == 0) { ApplySound(); state = MonsterState.Dying; GoTweenChain chain = new GoTweenChain(); chain.insert(0, transform .scaleTo(0.5f, 0.75f, true) .eases(GoEaseType.QuartOut) ); chain.insert(0, transform .localEularAnglesTo(0.5f, new Vector3(0, 0, RandomFloat.Range(-180, 180))) .eases(GoEaseType.QuadOut) ); chain.insert(0.25f, gameObject .alphaTo(0.25f, 0, GoEaseType.QuartOut) ); chain.setOnCompleteHandler(c => gameObject.DestroySelf()); chain.Start(); } transform.position += splashVector * 25; // bool isDying = ( life == 0 ); // transform.position += splashVector * ( isDying ? 100 : 25 ); } }
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; } }