Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        float distanceGoal = Vector3.Distance(goal.transform.position, this.transform.position);

        if (distanceGoal < 5)
        {
            target = goal;
        }
        float   distance  = Vector3.Distance(target.transform.position, this.transform.position);
        Vector3 direction = (target.transform.position - this.transform.position);

        if (distance <= attractionRadius)
        {
            rb.AddForce(speed * direction * ((distance * distance * 0.3f) + 1));
        }

        if (this.transform.position.y <= -1 || distanceGoal < .65)
        {
            if (distanceGoal <= .65)
            {
                cs.raiseScore();
            }
            Destroy(this.gameObject, 0);
            cnt.Remove(this.gameObject);
            SphereSpawner.SetColorWhite(rendSpawner);
        }
    }
 private bool CanSpawnSphereBurst(SphereSpawner spawner)
 {
     if (spawner.TimesUpgraded < spawner.MinUpgradesToBurst)
     {
         return(false);
     }
     return(randomGenerator.NextFloat() < spawner.ChanceToBurst);
 }
    private bool TrySkipSpawn(SphereSpawner spawner)
    {
        if (spawner.TimesUpgraded < spawner.UpgradesToSkipSpawn)
        {
            return(false);
        }
        float chanceToSkipSpawn = spawner.ChanceToSkipSpawnPerUpgrade * spawner.TimesUpgraded;

        chanceToSkipSpawn = math.min(spawner.MaxChanceToSkipSpawn, chanceToSkipSpawn);

        if (randomGenerator.NextFloat() < chanceToSkipSpawn)
        {
            Logger.Log("Skipping spawn");
            return(true);
        }
        else
        {
            return(false);
        }
    }
 // Use this for initialization
 void Start()
 {
     SS = GameObject.FindGameObjectWithTag("GameController").GetComponent <SphereSpawner>();
 }