public override void GetTileData(Vector3Int location, ITilemap tilemap, ref TileData tileData)
    {
        tileData.sprite = GrowthLevels[0].Texture;
        FarmManager mgr = FarmManager.GetInstance();

        if (mgr != null)
        {
            int         tileAge = mgr.GetTileAge(location);
            GrowthLevel level   = GetGrowthLevel(tileAge);
            if (level != null)
            {
                tileData.sprite = level.Texture;
            }
        }
    }
    GrowthLevel GetGrowthLevel(int age)
    {
        if (age < 0)
        {
            return(null);
        }
        GrowthLevel level = null;

        for (int i = 0; i < GrowthLevels.Length; ++i)
        {
            if (GrowthLevels[i].DaysTillUpgrade <= age)
            {
                level = GrowthLevels[i];
            }
        }
        return(level);
    }
Beispiel #3
0
    void TriggerGameOver()
    {
        const string SurvivalString = "Time: ";
        const string GrowthString   = "Size: ";

        // TODO implement effects outside of this class
        DamageBar.percent           = 0;
        gameOverTime                = Time.realtimeSinceStartup;
        GameOverCanvas.interactable = true;
        if (CurrentGameMode == GameMode.Survival)
        {
            float seconds = gameOverTime % 60;
            int   minutes = (int)gameOverTime / 60;

            GameOverScoreText.text = SurvivalString + minutes.ToString() + ':' + seconds.ToString("00");
        }
        else if (CurrentGameMode == GameMode.Growth)
        {
            GameOverScoreText.text = GrowthString + GrowthLevel.ToString();
        }
    }
Beispiel #4
0
    void Update()
    {
        CurrentDifficulty = ComputeTimeBasedDifficulty();

        GrowthLevel = (int)Mathf.Floor(ProtectedAmoeba.MaxStressLevel / GrowthLevelIncrement);

        if (CurrentGameMode == GameMode.Growth)
        {
            GrowthLevelText.text = GrowthLevel.ToString();
        }

        if (ProtectedAmoeba.IsLashingOut && gameOverTime < 0)
        {
            LashoutDuration += Time.deltaTime;

            if (LashoutDuration > MaxLashoutLength)
            {
                TriggerGameOver();
            }
            else
            {
                DamageBar.percent = 1f - LashoutDuration / MaxLashoutLength;
            }
        }
        else if (gameOverTime > 0 && (Time.timeScale > 0 || GameOverCanvas.alpha < 1))
        {
            if (Time.timeScale > 0)
            {
                float newScale = 1f - Mathf.Sqrt(Time.realtimeSinceStartup - gameOverTime);
                Time.timeScale = Mathf.Max(newScale, 0f);
            }

            // TODO fix problem where alpha doesn't technically reach 1.0 before we stop entering this branch
            float newAlpha = (Time.realtimeSinceStartup - gameOverTime);
            GameOverCanvas.alpha = newAlpha;
        }
    }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     growthLevel = GrowthLevel.stage1;
 }