/// <summary> /// Sets the reference to the manager, and assigns the bird to the foreground or background /// </summary> public void Initialize(BirdManager man, bool isForeground) { manager = man; isForegroundBird = isForeground; isInitialized = true; flyToPos = manager.GetNewFlyPos(transform.position, transform.forward, isForegroundBird); }
// Use this for initialization void Start() { mainCamera = Camera.main.GetComponent <Camera>(); b_Manager = GameObject.Find("Bird Manager").GetComponent <BirdManager>(); // lines = GameObject.Find("Goal Manager").GetComponent<>() }
private void GetBirdsGameObject() { birdGameObject = GameObject.Find("Birds"); if (birdGameObject) { birdManager = birdGameObject.GetComponent <BirdManager>(); SetupBirdsActions(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); BirdManager birdManager = (BirdManager)target; if (GUILayout.Button("UpdateLandingSpots")) { birdManager.UpdateListOfLandingSpots(); } }
void Start() { rb = GetComponent <Rigidbody2D>(); playerSprite = GetComponent <SpriteRenderer>(); birdManager = GameObject.Find("Bird Manager"); b_Manager = birdManager.GetComponent <BirdManager>(); currentForce = force; }
void Awake() { if (hasInitialized) { return; } Instance = this; birdList = new List <Bird>(); hasInitialized = true; }
void Awake() { instance = this; goodBounds = new Bounds(); badBounds = new Bounds(); foreach (var child in GoodPrefab.GetComponentsInChildren<SpriteRenderer>()) { goodBounds.Encapsulate (child.bounds); } foreach (var child in BadPrefab.GetComponentsInChildren<SpriteRenderer>()) { badBounds.Encapsulate (child.bounds); } }
void PerformCurrentAction() { switch (currentAction) { default: break; case Action.FLY_AWAY: acceleration = new Vector2(direction * 1, 1); if (velocity.magnitude >= maxSpeed) { velocity = velocity.normalized * maxSpeed; } break; case Action.SCARED: Vector2 directionVector = (fleeTarget.getRandomPos(transform.localScale / 2) - transform.position); if (directionVector.magnitude <= manager.birdFleeRadius) { manager.removeBird(this); manager = fleeTarget; manager.addBird(this); currentAction = Action.STAY; RandomizeWaitTime(); velocity = Vector2.zero; fleeTime = Time.fixedTime; return; } acceleration = (directionVector.normalized * maxSpeed) - velocity; acceleration = acceleration.normalized * 0.3f; Debug.DrawRay(transform.position, velocity.normalized * 10f, Color.green); Debug.DrawRay(transform.position, acceleration.normalized * 10f, Color.red); Debug.DrawRay(transform.position, directionVector.normalized * 10f, Color.yellow); if (velocity.magnitude >= maxSpeed) { velocity = velocity.normalized * maxSpeed; } break; } }
private void Awake() { instance = this; bounding = new AABB(transform.position, size); for (int i = 0; i < birdCount; i++) { Vector3 pos = transform.position + new Vector3(size.x * Random.value, size.y * Random.value, size.z * Random.value) - (size / 2); Bird bird = Instantiate(birdPrefab, pos, Quaternion.identity); bird.aabb = bounding; } }
public void FlyToNewZone() { BirdManager zone = manager.getNewZone(); if (zone == null) { currentAction = Action.FLY_AWAY; return; } fleeTarget = zone; velocity = Vector2.up * maxSpeed; waitTime = manager.birdMaxFleeTime; }
private void Awake() { if (!birdManager) { birdManager = FindObjectOfType <BirdManager>(); } birds = new List <BirdBehavior>(); landingSpots = new List <BirdLandingSpot>(); if (!cam) { cam = Camera.main; } }
// Update is called once per frame void Update() { float averageVx = 0; float averageVy = 0; foreach (GameObject bird in birds) { bird.GetComponent <BirdManager>().ClearVector(); averageVx += bird.GetComponent <BirdManager>().GetVx(); averageVy += bird.GetComponent <BirdManager>().GetVy(); } averageVx /= N; averageVy /= N; foreach (GameObject bird in birds) { bird.GetComponent <BirdManager>().Rotate(GetCenter()); } if (Input.GetMouseButtonDown(0)) { BirdManager.SetCenter(Camera.main.ScreenToWorldPoint(Input.mousePosition)); } }
private void Awake() { lineRenderer = GetComponent <LineRenderer>(); animator = GetComponent <Animator>(); birdManager = FindObjectOfType <BirdManager>(); }
void Awake() { instance = this; }