コード例 #1
0
ファイル: Player.cs プロジェクト: Jerjerzanne/FoodChain
    protected void UpdateGrowth()
    {
        if (maxGrowth <= 15)
        {
            growthMeter += 1;

            if (growthMeter >= maxGrowMeter)
            {
                maxGrowth  += 1;
                growthMeter = 0;

                if (maxGrowth % thresholdInterval == 0)
                {
                    int growthIndex = (int)maxGrowth / thresholdInterval;
                    if (growthIndex < 3)
                    {
                        CurrentGrowth = growthIndex;
                        SpriteRenderer[] renderers = gameObject.GetComponentsInChildren <SpriteRenderer>();
                        gameObject.GetComponent <SphereCollider>().radius = defaultColliderRadius + growthIndex * 0.25f;

                        foreach (SpriteRenderer r in renderers)
                        {
                            r.sprite = playerSprites[growthIndex];
                        }
                        playerGun = playerGuns[growthIndex];
                    }
                }
                else if (maxGrowth % thresholdInterval == 1)
                {
                    maxHealth      += 10;
                    refreshAmmoRate = 1f;
                }
                else if (maxGrowth % thresholdInterval == 2)
                {
                    TopdownController moveScript = gameObject.GetComponent <TopdownController>();
                    moveScript.speed += 2;
                    refreshAmmoRate   = 0.5f;
                }
                else if (maxGrowth % thresholdInterval == 3)
                {
                    playerGun.damage += 1;
                }
                else if (maxGrowth % thresholdInterval == 4)
                {
                    playerGun.burstSize++;
                }
            }
        }

        if (growthBar != null)
        {
            Debug.Log(this.name + " has fill amount" + growthMeter + " " + maxGrowMeter);
            growthBar.fillAmount = (float)growthMeter / maxGrowMeter;
            Debug.Log(this.name + " has fill amount" + growthBar.fillAmount);
        }
        growthText.text = "Growth Level: " + maxGrowth.ToString();
    }
コード例 #2
0
 private void Awake()
 {
     character = GetComponent <TopdownController>();
 }