void SetupDefaultFlock()
    {
        for (int i = 0; i < mNumOfBoids; i++)
        {
            GameObject newAgent = Instantiate(mBoidPrefab, new Vector3(Random.Range(18, 22), Random.Range(18, 22), Random.Range(18, 22)), Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)));
            newAgent.name             = "Boid " + i;
            newAgent.transform.parent = mAgentContainer.transform;
            Boids agentScript = newAgent.GetComponent <Boids>();
            agentScript.SetManager(this);
            agentScript.SetShouldFlock(true);

            AddBoid(agentScript);
            agentScript.SetTarget(mFlockTarget.transform.position);
        }
    }
示例#2
0
    public void SetupAgentForSpawning(float health, float energy, Vector3 position)
    {
        if (mBoidController == null)
        {
            mBoidController = this.gameObject.GetComponent <Boids>();
        }

        mBoidController.SetManager(GameConstants.Instance.BoidsManager);
        GameConstants.Instance.BoidsManager.AddBoid(mBoidController);

        mHealth = health;
        mEnergy = energy;

        transform.position = position;
    }