override protected void spawnEnemies() { TweenProperties enterUp = new SingleTween("5_enterUp", enterDuration); TweenProperties enterDown = new SingleTween("5_enterDown", enterDuration); TweenProperties cruiseUp = new LoopTween(LoopTween.Loop.reverse, new SingleTween("5_cruiseUp", cruiseDuration, cruiseDelay)); TweenProperties cruiseDown = new LoopTween(LoopTween.Loop.reverse, new SingleTween("5_cruiseDown", cruiseDuration, cruiseDelay)); for (int i = 1; i <= enemiesToSpawn; i++) { bool left = (i == 2 || i == 3); bool up = (i <= 2); TweenProperties enter = (up ? enterUp : enterDown).Clone(); TweenProperties cruise = (up ? cruiseUp : cruiseDown).Clone(); if (left) { Vector2 offset = new Vector2(-horizontalOffset, (up ? -1 : 1) * verticalOffset); enter.OffsetByXY(offset); cruise.OffsetByXY(offset); } EnemyType type = (left) ? EnemyObjectPool.type_enemy1 : EnemyObjectPool.type_enemy2; spawnEnemy(type, enter, cruise); } }
protected override void spawnEnemies() { // TweenProperties enterPath = new SingleTween ("8_enter", enterDuration); TweenProperties cruisePath = new SingleTween("8_cruise", cruiseDuration, cruiseDelay); TweenProperties cruisePathRev = cruisePath.Clone().Reverse(); for (int i = 0; i < enemiesToSpawn; i++) { float yOffset = -i * enemyDistance; int enterPathIndex = ((i % 3) + 1); float enterDelay = enterMaxDelay * Random.value; TweenProperties preEnterDelay = new DelayTween(enterDelay); TweenProperties enter = new SingleTween("8_enter" + enterPathIndex, enterDuration).OffsetByY(yOffset); TweenProperties postEnterDelay = new DelayTween(enterMaxDelay - enterDelay); TweenProperties preCruiseDelay = new DelayTween((enemiesToSpawn - i) * cruiseDuration); TweenProperties postCruiseDlay = new DelayTween(cruiseDuration * i); TweenProperties cruise = cruisePath.Clone().OffsetByY(yOffset); TweenProperties cruiseRev = cruisePathRev.Clone().OffsetByY(yOffset); TweenProperties loop = new LoopTween(preCruiseDelay, cruise, postCruiseDlay, postCruiseDlay, cruiseRev, preCruiseDelay); spawnEnemy(EnemyObjectPool.type_enemy2, preEnterDelay, enter, postEnterDelay, loop); } }
public override TweenProperties Clone() { TweenProperties[] tweens = new TweenProperties[this.tweens.Length]; for (int i = 0; i < tweens.Length; i++) { tweens [i] = (TweenProperties)this.tweens [i].Clone(); } return(new LoopTween(delay, loop, tweens)); }
IEnumerator Animate() { if (tweenQueue.Count > 0) { TweenProperties tween = tweenQueue.Dequeue(); tween.Apply(gameObject, tweenQueue); yield return(new WaitForSeconds(tween.getDuration())); } tweenInProgress = false; }
override protected void spawnEnemies() { TweenProperties enter = new SingleTween("9_enter", enterDuration); TweenProperties postEnterDelay = new DelayTween(loopDelay); TweenProperties goDown = new SingleTween("9_changeSide", changeSideDuration); TweenProperties goUp = goDown.Clone().Reverse(); TweenProperties attackUp = new SingleTween("9_attackUp", attackDuration); TweenProperties attackUpRev = attackUp.Clone().Reverse(); TweenProperties attackDown = new SingleTween("9_attackDown", attackDuration); TweenProperties attackDownRev = attackDown.Clone().Reverse(); TweenProperties loop = new LoopTween(attackUp, attackUpRev, goDown, attackDown, attackDownRev, goUp); spawnEnemy(EnemyObjectPool.type_boss, enter, postEnterDelay, loop); }
override protected void spawnEnemies() { TweenProperties enter = new SingleTween("simpleEnter", enterDuration); TweenProperties cruiseUp = new LoopTween(LoopTween.Loop.reverse, new SingleTween("4_cruiseUp", cruiseDuration, cruiseDelay)); TweenProperties cruiseDown = new LoopTween(LoopTween.Loop.reverse, new SingleTween("4_cruiseDown", cruiseDuration, cruiseDelay)); for (int i = 1; i <= 4; i++) { TweenProperties divide = new SingleTween("4_divide" + i, divideDuration); //first two enemies use cruiseUp tween TweenProperties cruise = (i <= 2) ? cruiseUp : cruiseDown; //second and third are translated down by cruiseOffset if (i % 2 == 0) { cruise = cruise.Clone().OffsetByY(-cruiseOffset); } spawnEnemy(EnemyObjectPool.type_enemy1, enter, divide, cruise); } }