Example #1
0
    protected override void OnGotShot(int damage, string source)
    {
        if (shieldHealth.health > 0)
        {
            shieldHealth.health -= damage;
            UpdateShield();

            if (shieldHealth.health <= 0)
            {
                shield.gameObject.SetActive(false);
            }

            RezTween.Destroy(ref rechargeTween);
            rechargeTween = RezTween.DelayedCall(GameData.Instance.shieldRechargeRate, () =>
            {
                shield.gameObject.SetActive(true);
                rechargeTween = RezTween.ValueRange(shieldHealth.health, shieldHealth.maximumHealth, 0.5f, progress =>
                {
                    shieldHealth.health = progress;
                    UpdateShield();
                });
                rechargeTween.OnComplete = UpdateShield;
            });
        }
        else
        {
            livesPanel.live--;
            if (livesPanel.live == 0)
            {
                Scene.SendEvent("OnGameOver");
            }
        }
    }
Example #2
0
    void ResetState()
    {
        SessionData.Reset();

        playerScore.text = SessionData.score.ToString();
        killCount.text   = SessionData.enemiesKilled.ToString();
        rocketCount.text = SessionData.rocket.ToString();
        coinDisplay.text = SessionData.coins.ToString();

        playerShip.Initialize();
        playerShip.allowInput = true;

        UICanvas.SetActive(true);
        isShowingEndingUI = false;

        secondsElapsed = 0;
        roundTimer     = new RezTween.Timer(1, roundDuration)
        {
            onTick     = LogSeconds,
            onComplete = OnTimeUp
        };

        // Increase enemy linearly
        if (enemyManager.spawnInterval > 1)
        {
            enemyManager.spawnInterval -= 1;
        }

        if (firstTimePlay)
        {
            tutorialDialog.onClose = () =>
            {
                firstTimePlay = false;
                enemyManager.StartSpawn();
                roundTimer.Start();
                Destroy(tutorialDialog.gameObject);
            };
            RezTween.DelayedCall(0.5f, () => tutorialDialog.Show());
        }
        else
        {
            roundTimer.Start();
            enemyManager.StartSpawn();
        }
    }
Example #3
0
    /// <summary>
    /// Fire the bullet.
    /// </summary>
    void Fire()
    {
        GameObject closestShip = FindClosestShip();

        if (closestShip != null)
        {
            spriteTransform.rotation = Util.GetRotationTo(closestShip.transform.position, transform.position, 90);
            GetComponent <Rigidbody2D>().AddForce((closestShip.transform.position - transform.position) * 10, ForceMode2D.Force);
            RezTween.DelayedCall(1f, () =>
            {
                spriteTransform.rotation = Util.GetRotationTo(closestShip.transform.position, transform.position, 90);
                ShootTo(closestShip.transform.position);
            });
        }
        else
        {
            Debug.Log("No closest ship found. Maybe you forgot to set the tag.");
        }
    }
Example #4
0
    void ShowEnding(string text, Action onComplete)
    {
        if (!isShowingEndingUI)
        {
            roundTimer.Stop(17);
            endingText.text       = text;
            playerShip.allowInput = false;
            RezTween.To(endingOverlay, 0.5f, "alpha:1").OnComplete = () =>
            {
                playerShip.transform.position = Vector2.zero;
                enemyManager.StopSpawnAndDestroyEnemies();
                BulletManager.Instance.ClearBullets();
                UICanvas.SetActive(false);

                RezTween.To(endingOverlay, 0.5f, "alpha:0", RezTweenOptions.Delay(2f)).OnStart = onComplete;
            };

            isShowingEndingUI = true;
        }
    }
Example #5
0
 // Start is called before the first frame update
 void Start()
 {
     RezTween.DelayedCall(delay, () => Destroy(gameObject));
 }
Example #6
0
    public void SpawnCoinAt(Vector3 position)
    {
        GameObject coin = Instantiate(coinPrefab, position, Quaternion.identity, transform);

        RezTween.ScaleFromTo(coin, 0.5f, 0, 1, RezTweenEase.SPRING);
    }
Example #7
0
 void UpdateText(Text text, int value)
 {
     text.text = value.ToString();
     RezTween.ScaleFromTo(text.gameObject, 0.5f, 0.5f, 1f, RezTweenEase.BACK_OUT);
 }