void Awake() { if (isSheepFlock) { sheepFlock = this; } }
void Start() { body = GetComponent <Rigidbody2D>(); manager = GameObject.Find("Boid Manager").GetComponent <BoidManager>(); liner = gameObject.AddComponent <LineRenderer>(); //velocity = Vector3.zero; }
private PointAttractDriver _pointAttractDriver; // makes boids chase the cursor (or whatever) private void Awake() { gameUI.onCoherenceValueChange += HandleCoherenceValueChange; gameUI.onSeperationValueChange += HandleSeperationValueChange; gameUI.onAlignmentValueChange += HandleAlignmentValueChange; _boidManager = new BoidManager(); boidViewManager.boidManager = _boidManager; _boidManager.count = 50; _flockDriver = new FlockDriver(); _alignDriver = new AlignDriver(); _seperateDriver = new SeperateDriver(); _pointAttractDriver = new PointAttractDriver(); // To make the boids follow a coursor or whatnot, See: Update() foreach (Boid boid in _boidManager.Boids) { boid.drivers.Add(_flockDriver); boid.drivers.Add(_alignDriver); boid.drivers.Add(_seperateDriver); boid.drivers.Add(_pointAttractDriver); } // set initial values HandleCoherenceValueChange(gameUI.slider_Coherence.value); HandleSeperationValueChange(gameUI.slider_Seperation.value); HandleAlignmentValueChange(gameUI.slider_Alignment.value); }
//For dependency injection. public void SetManager(BoidManager tank, int d, int num, Texture2D tex) { manager = tank; id = d; _numBoids = num; _relativeValues = tex; }
/* MY CODE */ void Update() { // generate boids while the space key is held and the mouse cursor is on a collider of the level if (Input.GetKey("space")) { // create a ray from the camera in the direction fo the mouse cursor Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // cast the ray and check if it hits a collider if (Physics.Raycast(ray, out hit)) { // instantiate a boid at the hit position + a little vertical offset Boid boid = Instantiate(prefab); Vector3 pos = new Vector3(hit.point.x, hit.point.y + 2, hit.point.z); boid.transform.position = pos; boid.transform.forward = Random.insideUnitSphere; boid.SetColour(Random.ColorHSV()); // add the new boid to the BoidManager BoidManager manager = FindObjectOfType <BoidManager>(); manager.AddBoid(boid); boidsCount++; } } }
void Awake() { Instance = this; BoidList = new List <BoidUtil>(); MenaceList = new List <GameObject>(); FoodList = new List <GameObject>(); WaypointsList = new List <Vector3>(); }
void Update() { time -= Time.deltaTime; if (time <= 0) { BoidManager.Get().FoodList.Remove(this.gameObject); Destroy(this.gameObject); } }
//****************************************************** // // FUNCTIONS // //****************************************************** /// <summary> // Called when the object is created, before Start(). /// </summary> private void Awake() { // Initialize singleton if (Instance != null && Instance != this) { Destroy(this.gameObject); return; } Instance = this; }
private void GetBoidsGameObject() { boidGameObject = GameObject.Find("Boid Manager"); if (boidGameObject) { boidManager = boidGameObject.GetComponent <BoidManager>(); SetupBoidsActions(); } }
void Start() { this.boidManager = new BoidManager { BoidPrefab = this.BoidPrefab }; this.Reset(); // TODO: Remove this.SetBoidBrush(); this.SetSphereBrush(); }
public void Initialize(CellGrid cellGrid) { this.cellGrid = cellGrid; if (Instance == null) { Instance = this; } seekTimer = timeTillSeekTargetChange; }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
private void TransformIntoMenace() { GameObject menace = Instantiate(MenacePrefab); menace.transform.position = transform.position; BoidManager boidGet = BoidManager.Get(); boidGet.MenaceList.Add(menace); boidGet.BoidList.Remove(this); Destroy(this.gameObject); }
protected override void Init() { base.Init(); fishSettings = (FishSettings)consumerSettings; if (DoesSchool) { Environment.Instance.AddBoidManagerToFishContainters(this); boidManager = GetComponentInParent <BoidManager>(); } }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } }
static void Main(string[] args) { var engine = new RenderEngine(1080, 1920, "Boids"); engine.UseShaders(@"./Shaders"); engine.ShaderManager.OnLoad(); var boidManager = new BoidManager(engine.ShaderManager.Shaders.FirstOrDefault(x => x.Name.ToLower() == "boid") as IShader, 10); boidManager.OnLoad(); engine.Run(); }
private void OnTriggerEnter(Collider other) { if (other.transform.tag == "Food") { BoidManager.Get().FoodList.Remove(other.gameObject); Destroy(other.gameObject); foodCount++; if (foodCount >= MaxFood) { TransformIntoMenace(); } } }
public void Initialize(BoidSettings settings, List <Target> targets, BoidManager manager) { // this.target = target; this.targets = targets; this.settings = settings; position = cachedTransform.position; forward = cachedTransform.forward; float startSpeed = (settings.minSpeed + settings.maxSpeed) / 2; velocity = transform.forward * startSpeed; this.manager = manager; SetColour(manager.color); }
void Awake() { // The following code makes the game manager a singleton. I.e. there can only be one instance in the game at any given time. // This is a good thing as the game manager keeps track of score etc. and therefor there shouldnt be more than one if (instance == null) { instance = this; //If no game managers exists, this game object becomes the game manager. } //If instance already exists and it's not this: else if (instance != this) { Destroy(gameObject); //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. } DontDestroyOnLoad(gameObject); //when changing scenes Unity normally destorys all gameobject. However sincethe game manager keeps track of score it should not be destoyed when new scenes are loaded }
void Spawn(GameObject prefab, string tipo) { GameObject obj = Instantiate(prefab); float xPos = Random.Range(BoxBounds.min.x, BoxBounds.max.x); float zPos = Random.Range(BoxBounds.min.z, BoxBounds.max.z); float yPos = Random.Range(BoxBounds.min.y, BoxBounds.max.y); obj.transform.position = new Vector3(xPos, yPos, zPos); if (tipo == "Food") { BoidManager.Get().FoodList.Add(obj); } else if (tipo == "Menace") { BoidManager.Get().MenaceList.Add(obj); } }
internal void SetController(BoidManager boidManager) { manager = boidManager; }
void Awake() { spawners = GetComponentsInChildren<PlantManager>(); boidManager = FindObjectOfType<BoidManager>(); //miniBoidManager = FindObjectOfType<MiniBoidManager>(); player = FindObjectOfType<PlayerPhysicsBehaviour>(); }
void Start() { Instance = this; if ( !useInteractions ) { for ( int i = 0; i < numOfBoids; i++ ) { GameObject.Instantiate(boidPrefab, Random.insideUnitSphere * spawnRadius, Quaternion.identity); } } else { for ( int i = 0; i < blueNum; i++ ) { GameObject.Instantiate(blueBoid, Random.insideUnitSphere * spawnRadius, Quaternion.identity); } for ( int i = 0; i < blackNum; i++ ) { GameObject.Instantiate(blackBoid, Random.insideUnitSphere * spawnRadius, Quaternion.identity); } for ( int i = 0; i < greenNum; i++ ) { GameObject.Instantiate(greenBoid, Random.insideUnitSphere * spawnRadius, Quaternion.identity); } for ( int i = 0; i < redNum; i++ ) { GameObject.Instantiate(redBoid, Random.insideUnitSphere * spawnRadius, Quaternion.identity); } } foreach ( GameObject obj in GameObject.FindGameObjectsWithTag("Boid")) { Boid boid = obj.GetComponent<Boid>(); if (boid != null) { boid.canCollide = true; } } StartCoroutine(BoidInteraction()); }
private void Awake() { S = this; target = transform; }
// Start is called before the first frame update void Start() { boidManager = FindObjectOfType <BoidManager>(); spriteRenderer = GetComponent <SpriteRenderer>(); }
private void Awake() { manager = BoidManager.instance; }
// Use this for initialization void Start() { manager = GetComponent <BoidManager>(); avgPosDist = new List <Sample>(); }
// Use this for initialization void Start() { noBoids = BoidManager.getBoids(); displayNoBoids.text = noBoids.ToString(); }
public void updateBoids() { noBoids = BoidManager.getBoids(); displayNoBoids.text = noBoids.ToString(); }
public void setBoidManager(GameObject manager) { boidManager = manager.GetComponent <BoidManager>(); }
private void Awake() { boidManager = GetComponentInParent <BoidManager>(); sprite = GetComponentInChildren <SpriteRenderer>(); }
/// <summary> /// Manage boid count and stepping. /// </summary> /// <param name="mngr">The (flock) manager. Contains utils for driver functions.</param> /// <param name="pos">Initial position</param> /// <param name="vel">Initial velocity</param> public Boid(BoidManager mngr, Vector2 pos, Vector2 vel) { Manager = mngr; Position = pos; Velocity = vel; }