void Start()
    {
        CenterSilo = CenterSilo.GetComponent <SiloController>();
        LeftSilo   = LeftSilo.GetComponent <SiloController>();
        RightSilo  = RightSilo.GetComponent <SiloController>();

        AllSilos = new SiloController[] { CenterSilo, LeftSilo, RightSilo };
    }
    private Vector2 ChooseSiloDestination(double chanceDestroyed)
    {
        SiloController[] silos = (SiloController[])Object.FindObjectsOfType(typeof(SiloController));

        SiloController chosenSilo = silos[MyRandom.Next(silos.Length)];

        for (int tries = 0; tries < silos.Length; tries++)
        {
            double chance = MyRandom.NextDouble();
            if (chance < chanceDestroyed && chosenSilo.IsDestroyed)
            {
                return(chosenSilo.gameObject.transform.position);
            }
            else if (!chosenSilo.IsDestroyed)
            {
                return(chosenSilo.gameObject.transform.position);
            }

            // Try again to see if we can fit the specifications.
            chosenSilo = silos[MyRandom.Next(silos.Length)];
        }
        return(chosenSilo.gameObject.transform.position);
    }
Ejemplo n.º 3
0
 void Start()
 {
     silo = new SiloController().setMissile(missilePrefab);
 }