public void InitWolf(Vector3 endPosition, Vector3 startPostion, WolfController controller) { moveToPositionTrigger = true; destination = endPosition; startPoint = startPostion; this.m_wolfController = controller; }
// Generates a blank genome public Genome(WolfController manager) { //Fitness always begins at 0 fitness = 0; this.manager = manager; chromosomes = new Dictionary<string, Chromosome>(); }
/// <summary> /// Check if any scary Things are around /// </summary> private GameObject[] CheckScaryThingsAround() { scaredOfObjects.Clear(); RaycastHit[] surroundingObjects = GetVisibleObjects(); //TODO: Make sure to run away from the closest enemy foreach (RaycastHit hit in surroundingObjects) { FlammableTrait flammableTrait = hit.transform.GetComponent <FlammableTrait>(); if (flammableTrait) { if (flammableTrait.isBurning) { scaredOfObjects.Add(flammableTrait.gameObject); } continue; } WolfController wolfController = hit.transform.GetComponent <WolfController>(); if (wolfController) { scaredOfObjects.Add(wolfController.gameObject); continue; } //Other scary traits for a sheep (Like wolves, coming soon) } return(scaredOfObjects.ToArray()); }
// Use this for initialization void Start() { _animator = this.GetComponentInChildren <tk2dSpriteAnimator>(); _sprite = this.GetComponentInChildren <tk2dSprite>(); _wolfController = this.GetComponent <WolfController>(); _spriteDefaultScale = _sprite.scale; }
/// <summary> /// Gets all the food things that are alive, edible, attackable, not a wolf and not self /// </summary> /// <param name="hits"></param> /// <returns></returns> private AttackableTrait[] GetAllAliveAttackableFoodTraits(RaycastHit[] hits) { List <AttackableTrait> attackingTraits = new List <AttackableTrait>(); foreach (RaycastHit hit in hits) { if (ReferenceEquals(hit.transform.gameObject, this.gameObject)) { continue; } //Is the thing edible? EdibleTrait edibleTrait = hit.transform.GetComponent <EdibleTrait>(); if (edibleTrait) { // wolves won't eat wolves WolfController wolfController = hit.transform.GetComponent <WolfController>(); if (!wolfController) { // They aren't vegetarien MeatTrait meatTrait = hit.transform.GetComponent <MeatTrait>(); if (meatTrait) { AttackableTrait attackableTrait = hit.transform.GetComponent <AttackableTrait>(); if (attackableTrait) { attackingTraits.Add(attackableTrait); } } } } } return(attackingTraits.ToArray()); }
private EdibleTrait[] GetEdibleTraits(RaycastHit[] hits) { List <EdibleTrait> edibleTraits = new List <EdibleTrait>(); foreach (RaycastHit hit in hits) { if (ReferenceEquals(hit.transform.gameObject, this.gameObject)) { continue; } //Is the thing edible? EdibleTrait edibleTrait = hit.transform.GetComponent <EdibleTrait>(); if (edibleTrait) { // wolves won't eat wolves WolfController wolfController = hit.transform.GetComponent <WolfController>(); if (!wolfController) { // They aren't vegetarien MeatTrait meatTrait = hit.transform.GetComponent <MeatTrait>(); if (meatTrait) { HealthTrait healthTrait = hit.transform.GetComponent <HealthTrait>(); if (healthTrait && !healthTrait.isAlive) { edibleTraits.Add(edibleTrait); } } } } } return(edibleTraits.ToArray()); }
private void OnCollisionStay(Collision collision) { if (collision.collider.tag == "Player") { WolfController wolf = GetComponent <WolfController>(); wolf.Attack1 = true; } }
private void OnCollisionEnter2D(Collision2D collision) { WolfController player = collision.gameObject.GetComponent <WolfController>(); if (player != null) { menuHandler.GetComponent <MenuHandler>().ActivateLoseMenu(); } }
private void OnTriggerEnter2D(Collider2D collision) { WolfController player = collision.GetComponent <WolfController>(); if (player != null) { menuHandler.GetComponent <MenuHandler>().ActivateLoseMenu(); } }
// Generates a mutated genome from an existing one public Genome(Genome genome, float mutationRate, WolfController manager) { this.manager = manager; fitness = 0; chromosomes = genome.copyChromosomes(); foreach(Chromosome gene in chromosomes.Values) { gene.mutate(mutationRate); } }
private void OnTriggerExit2D(Collider2D other) { if (other.tag == GameConfiguration.PLAYER_TAG) { _pigController = null; } else if (other.tag == GameConfiguration.ENEMY_TAG) { _wolfController = null; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == GameConfiguration.PLAYER_TAG) { _pigController = other.GetComponent <PigController>(); } else if (other.tag == GameConfiguration.ENEMY_TAG) { _wolfController = other.GetComponent <WolfController>(); } }
// Use this for initialization void Start() { if (GetComponentInParent <WolfController>() != null) { parent = GetComponentInParent <WolfController>(); } else { parent2 = GetComponentInParent <pirateController>(); } }
private void OnTriggerEnter2D(Collider2D collision) // Should this live here or on the sheep/wolf? { if (collision.gameObject.CompareTag("Sheep")) { SheepController sheep = collision.gameObject.GetComponent <SheepController>(); if (sheep) { sheep.UnpanicSheep(); sheep.ChangeVelocity(transform.position, velocity); } // unpanic sheep from dashjump } else if (collision.gameObject.CompareTag("Wolf")) { WolfController wolf = collision.gameObject.GetComponent <WolfController>(); wolf.Die(); } }
private void OnTriggerEnter2D(Collider2D collision) { // lightning hits sheep if (collision.gameObject.CompareTag("Sheep")) { SheepController sheep = collision.gameObject.GetComponent <SheepController>(); if (sheep.isPanicked == false) { sheep.PanicSheep(); sheep.ChangeVelocity(transform.position, sheepHitVelocity); } else if (collision.gameObject.CompareTag("Wolf")) { WolfController wolf = collision.gameObject.GetComponent <WolfController>(); wolf.Die(); } } }
// Setup this wolf-pack by initializing fields void Start() { this.rigidBody = GetComponent <Rigidbody2D>(); // Create four points in formation arround this formation controller // these four points will be seeked by the members of the formation // spawn agents at each point and set them to be part of a formation Vector2 startPos = transform.position; formationPoints = new List <Vector2>(); formationPoints.Add(new Vector2(-1, 1)); formationPoints.Add(new Vector2(-2, 2)); formationPoints.Add(new Vector2(-1, -1)); formationPoints.Add(new Vector2(-2, -2)); wolves = new List <WolfController>(); for (int i = 0; i < formationPoints.Count; i++) { Vector2 loc = transform.position + (transform.right * this.formationPoints[i].x) + (transform.up * this.formationPoints[i].y); WolfController wolf = Instantiate(WOLF, loc, Quaternion.identity); wolf.inPack = true; wolf.formationPoint = loc; wolves.Add(wolf); } // Setup the insistance fields, growth rates, etc. setupInsistance(); // Setup the actions that the wolf can take setupActions(); // Initialize base agent initialize(); // Set arriving at to a dummy vector of (-1, -1) this.target = new Vector2(-1, -1); }
// Use this for initialization void Start() { myController = transform.parent.GetComponent<WolfController>(); }
private IEnumerator SetWolfAsParalized(WolfController wolf) { yield return(new WaitForSeconds(1f)); wolf.Paralize(); }
// Use this for initialization void Start() { parent = GetComponentInParent <WolfController>(); }
// Use this for initialization void Start() { player = gameObject.GetComponentInParent<WolfController> (); }
// Use this for initialization void Start() { player = gameObject.GetComponentInParent <WolfController> (); }