示例#1
0
    private EntityManager CreateNewFish(EntityManager parent = null)
    {
        Vector3 startPosition;

        do
        {
            startPosition = new Vector3(
                Random.Range(-spawnBoundaryRaduis, spawnBoundaryRaduis),
                Random.Range(-spawnBoundaryRaduis, spawnBoundaryRaduis),
                Random.Range(-spawnBoundaryRaduis, spawnBoundaryRaduis)
                ) + spawnBoundaryCenter;
        } while (IsCloseToOthers(startPosition));

        GameObject newFish = Instantiate(FishPrototype, startPosition, Quaternion.identity, FisheContainer.transform);

        EntityManager fishManager = newFish.GetComponent <EntityManager>();

        NeuralNet brain = manager.CreateNewBrain(parent != null ? parent.Brain : null);

        fishManager.AssignBrain(brain);

        return(fishManager);
    }