Ejemplo n.º 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");
            }
        }
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 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.");
        }
    }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     RezTween.DelayedCall(delay, () => Destroy(gameObject));
 }