public void SpawnReward() { ftc.CreateScoreText(score); GameManager.instance.Score += score; if (_rewards.Length == 0) { return; } // chance if it is possible to spawn reward int chance = Random.Range(0, 100); if (chance > changeToSpawnReward) { return; } // chance whitch object will spawn SumRewardsProbability(); int randomChance = Random.Range(1, totalProbability + 1); int randomIndex = FindRewardIndex(randomChance); GameObject go = Instantiate(_rewards[randomIndex].reward, transform.position, Quaternion.identity); go.transform.localScale *= _rewards[randomIndex].scale; }
protected override void OnTriggerEnter2D(Collider2D collision) { base.OnTriggerEnter2D(collision); if (collision.tag.Equals("Player")) { ftc = GetComponent <FloatingTextController>(); ftc.CreateScoreText(value, type); string valueStr = value.ToString(); if (type == EPICKUP.cash) { GameManager.instance.Score += value; } else if (type == EPICKUP.Consumable) { collision.GetComponent <PlayerHealth>().AddHealth(value); } else if (type == EPICKUP.Ammo) { collision.GetComponent <PlayerAttack>().AddAmmo(value); } else if (type == EPICKUP.ProtectedShield) { collision.GetComponent <ProtectedShield>().ActiveShield(value); } else if (type == EPICKUP.DamageShield) { collision.GetComponent <DamageShield>().ActiveShield(value); } PlayerPickedUp(); } }