Exemple #1
0
    //Create boomerang bodies
    private void CreateBoomerangBodies()
    {
        // Set the food position to a random point
        hex.transform.position = new Vector2(Random.Range(-37, 37), Random.Range(-15, 15));
        // if our boomerang list is not null
        if (boomerangList != null)
        {
            // Destroy every Boomerang
            for (int i = 0; i < boomerangList.Count; i++)
            {
                GameObject.Destroy(boomerangList[i].gameObject);
            }
        }

        // Create a new boomerang list
        boomerangList = new List <Boomerang>();

        // Iterate through the population size
        for (int i = 0; i < populationSize; i++)
        {
            // Instantiate a boomerang at a random position and get the component
            Boomerang boomer = ((GameObject)Instantiate(boomerPrefab, new Vector3(UnityEngine.Random.Range(-10f, 10f), UnityEngine.Random.Range(-10f, 10f), 0), boomerPrefab.transform.rotation)).GetComponent <Boomerang>();
            //Call the Init method
            boomer.Init(nets[i], hex.transform);
            //Add it the list
            boomerangList.Add(boomer);
        }
    }
Exemple #2
0
    private void CreateBoomerangBodies()
    {
        if (boomerangList != null)
        {
            for (int i = 0; i < boomerangList.Count; i++)
            {
                GameObject.Destroy(boomerangList[i].gameObject);
            }
        }

        boomerangList = new List <Boomerang>();

        for (int i = 0; i < populationSize; i++)
        {
            Boomerang boomer = ((GameObject)Instantiate(boomerPrefab)).GetComponent <Boomerang>();
            boomer.Init(nets[i], hex.transform);
            boomerangList.Add(boomer);
        }
    }
Exemple #3
0
    private void CreateBoomerangBodies()
    {
        if (boomerangList != null)
        {
            for (int i = 0; i < boomerangList.Count; i++)
            {
                GameObject.Destroy(boomerangList[i].gameObject);
            }
        }

        boomerangList = new List <Boomerang>();

        for (int i = 0; i < populationSize; i++)
        {
            Boomerang boomer = ((GameObject)Instantiate(boomerPrefab, new Vector3(UnityEngine.Random.Range(-10f, 10f), UnityEngine.Random.Range(-10f, 10f), 0), boomerPrefab.transform.rotation)).GetComponent <Boomerang>();
            boomer.Init(nets[i], hex.transform);
            boomerangList.Add(boomer);
        }
    }
Exemple #4
0
    public void CreateBoomerangBodies() //creates boomerang bodies (duh again)
    {
        //destroys all boomerangs
        if (boomerangList != null)
        {
            for (int i = 0; i < boomerangList.Count; i++)
            {
                GameObject.Destroy(boomerangList[i].gameObject);
            }
        }

        boomerangList = new List <Boomerang>();
        //creates new boomerangs
        for (int i = 0; i < populationSize; i++)
        {
            Boomerang boomer = (Instantiate(boomerPrefab, new Vector3(UnityEngine.Random.Range(-30f, 30f), UnityEngine.Random.Range(-30f, 30f), 0), boomerPrefab.transform.rotation)).GetComponent <Boomerang>();
            boomer.Init(nets[i], hex.transform, stacy.transform);
            boomerangList.Add(boomer);
        }
    }
Exemple #5
0
    private void CreateBoomerangBodies()
    {
        if (boomerangList != null)
        {
            for (int i = 0; i < boomerangList.Count; i++)
            {
                Destroy(boomerangList[i].gameObject);
            }
        }

        boomerangList = new List <Boomerang>();

        for (int i = 0; i < populationSize; i++)
        {
            Boomerang boomerang = Instantiate(BoomerangObject,
                                              new Vector3(Random.Range(-10f, 10f),
                                                          Random.Range(-10f, 10f), 0),
                                              BoomerangObject.transform.rotation).GetComponent <Boomerang>();

            boomerang.Init(rNetworks[i], Hexagon.transform);

            boomerangList.Add(boomerang);
        }
    }