public override void Start()
 {
     base.Start();
     woodpecker  = FindObjectOfType <Woodpecker>();
     hummingbird = FindObjectOfType <Hummingbird>();
     penguin     = FindObjectOfType <Penguin>();
 }
Beispiel #2
0
    public override void perform(Controller c)
    {
        Hummingbird bird = State.cast <Hummingbird> (c);

        PatrolNode n = bird.getPatrolTarget();

        bird.facePoint(n.transform.position, bird.getTurnSpeed() * Time.deltaTime);
    }
Beispiel #3
0
        public HSeed(Controller c) : base(c)
        {
            Hummingbird h = State.cast <Hummingbird>(c);

            currentNode   = h.patrolStart;
            defaultState  = h.defaultState;
            pursuitTarget = h.pursuitTarget;
        }
Beispiel #4
0
    public override bool check(Controller c)
    {
        Hummingbird bird = State.cast <Hummingbird> (c);

        PatrolNode p = bird.getPatrolTarget();

        return(Vector3.Angle(bird.transform.position - p.transform.position, -bird.transform.up) < tolerance);
    }
Beispiel #5
0
    public override bool check(Controller c)
    {
        Hummingbird bird = State.cast <Hummingbird> (c);

        RaycastHit2D[] hits;
        hits = Physics2D.CircleCastAll(c.transform.position, bird.getSightRange(), Vector2.zero, 0f, bird.getTargetMask());
        for (int i = 0; i < hits.Length; i++)
        {
            Entity e = hits [i].collider.GetComponent <Entity> ();
            if (e != null && e.getFaction() == Entity.Faction.player)
            {
                Vector3 dir = (hits [i].collider.transform.position + (Vector3)hits [i].collider.offset) - c.transform.position;

                if (Vector3.Angle(dir, c.transform.up) < bird.getFOV() / 2f)
                {
                    RaycastHit2D wallCheck;
                    float        dist = Vector2.Distance(c.transform.position, hits [i].collider.transform.position + (Vector3)hits [i].collider.offset);

                    bool saveQHT = Physics2D.queriesHitTriggers;
                    Physics2D.queriesHitTriggers = false;
                    wallCheck = Physics2D.Raycast(c.transform.position, dir, dist, bird.getObstMask());
                    Physics2D.queriesHitTriggers = saveQHT;

                    if (wallCheck.collider == null || wallCheck.collider.isTrigger)
                    {
                        bird.setPursuitTarget(hits [i].collider.transform);
                        bird.setInPursuit(true);
                        return(true);
                    }
                }

                Vector3 centerDir = hits [i].collider.transform.position - c.transform.position;

                if (Vector3.Angle(centerDir, c.transform.up) < bird.getFOV() / 2f)
                {
                    RaycastHit2D wallCheck;
                    float        dist = Vector2.Distance(c.transform.position, hits [i].collider.transform.position);

                    bool saveQHT = Physics2D.queriesHitTriggers;
                    Physics2D.queriesHitTriggers = false;
                    wallCheck = Physics2D.Raycast(c.transform.position, centerDir, dist, bird.getObstMask());
                    Physics2D.queriesHitTriggers = saveQHT;

                    if (wallCheck.collider == null || wallCheck.collider.isTrigger)
                    {
                        bird.setPursuitTarget(hits [i].collider.transform);
                        bird.setInPursuit(true);
                        return(true);
                    }
                }
            }
        }

        bird.setInPursuit(false);
        return(false);
    }
Beispiel #6
0
        /// <summary>
        /// Creates an instance of the zoo class and configures it as the Como Zoo.
        /// </summary>
        private void CreateComoZoo()
        {
            // Create an instance of the Zoo class.
            this.comoZoo = new Zoo("Como Zoo", 1000, 4, 0.75m, 15.00m, 3640.25m, new Employee("Sam", 42), new Employee("Flora", 98), 3);

            // Add money to the animal snack machine.
            this.comoZoo.AnimalSnackMachine.AddMoney(42.75m);

            // Define an animal variable.
            Animal animal;

            // Create Dolly.
            animal = new Dingo("Dolly", 4, 35.3);

            // Make Dolly pregnant.
            animal.MakePregnant();

            // Add Dolly to the zoo's animal list.
            this.comoZoo.AddAnimal(animal);

            // Create Dixie.
            animal = new Dingo("Dixie", 3, 33.8);

            // Make Dixie pregnant.
            animal.MakePregnant();

            // Add Dixie to the zoo's animal list.
            this.comoZoo.AddAnimal(animal);

            // Create Patty.
            animal = new Platypus("Patty", 2, 15.5);

            // Make Patty pregnant.
            animal.MakePregnant();

            // Add Patty to the zoo's animal list.
            this.comoZoo.AddAnimal(animal);

            // Create Harold.
            animal = new Hummingbird("Harold", 1, 0.5);

            // Add Harold to the zoo's animal list.
            this.comoZoo.AddAnimal(animal);

            // Create a guest.
            Guest guest = new Guest("Greg", 44, 150.35m, "Brown");

            // Add the guest and sell the ticket to the guest.
            this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest));

            // Create a guest.
            guest = new Guest("Darla", 11, 25.25m, "Salmon");

            // Add the guest and sell the ticket to the guest.
            this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest));
        }
Beispiel #7
0
        /// <summary>
        /// The button that births an aniaml.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void birthAnimalButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a new bird.
            Animal bird = new Hummingbird("Jeffery", 23, 23, Gender.Male);

            // Make the bird pregnant. Then reprodudce. Lay egg.
            bird.MakePregnant();
            IReproducer baby = bird.Reproduce();

            // Create a new dingo, and make the dingo reproduce.
            Animal      dude    = new Dingo("jim", 32, 23, Gender.Male);
            IReproducer babyTwo = dude.Reproduce();
        }
Beispiel #8
0
    public override void perform(Controller c)
    {
        Hummingbird bird = State.cast <Hummingbird> (c);

        source = c.GetComponent <AudioSource>();
        c.facePoint(bird.getPursuitTarget().position, bird.getTurnSpeed() * Time.deltaTime);

        float moveDist = c.getSelf().getMovespeed() * Time.deltaTime;

        c.transform.Translate(
            (bird.getPursuitTarget().position - c.transform.position).normalized *
            moveDist, Space.World);

        if (Vector3.Distance(c.transform.position, bird.getPursuitTarget().position) < killDistance)
        {
            bird.getPursuitTarget().GetComponent <Entity>().onDeath();

            if (source != null)
            {
                source.PlayOneShot(AudioLibrary.inst.hummingBirdAttacking);
            }
        }
    }
 public HasUnconvertableConstuctorParameter(Hummingbird hummingbird)
 {
 }
Beispiel #10
0
        /// <summary>
        /// Creates an instance of the zoo class and configures it as the Como Zoo.
        /// </summary>
        private void CreateComoZoo()
        {
            // Create an instance of the Zoo class.
            this.comoZoo = new Zoo("Como Zoo", 1000, 4, 0.75m, 15.00m, 3640.25m, new Employee("Sam", 42), new Employee("Flora", 98), 3);

            // Add money to the animal snack machine.
            this.comoZoo.AnimalSnackMachine.AddMoney(42.75m);

            // Define an animal variable.
            Animal animal;

            // Create a new Dingo and add him to the list of animals.
            animal = new Dingo("Dolly", 4, 35.3);

            animal.MakePregnant();

            this.comoZoo.AddAnimal(animal);

            // Create a new Dingo and add him to the list of animals.
            animal = new Dingo("Dixie", 3, 33.8);

            animal.MakePregnant();

            this.comoZoo.AddAnimal(animal);

            // Create a new platypus and add him to the list of animals.
            animal = new Platypus("Patty", 2, 15.5);

            animal.MakePregnant();

            this.comoZoo.AddAnimal(animal);

            // Create a new Hummingbird and add him to the list of animals.
            animal = new Hummingbird("Harold", 1, 0.5);

            this.comoZoo.AddAnimal(animal);

            // Create a new chimp and add him to the list of animals.
            animal = new Chimpanzee("Noah", 12, 500);

            this.comoZoo.AddAnimal(animal);

            // Create a new eagle and add him to the list of animals.
            animal = new Eagle("Tracy", 300, 10);

            this.comoZoo.AddAnimal(animal);

            // Create a new kangaroo and add him to the list of animals.
            animal = new Kangaroo("Jeff", 25, 30);

            this.comoZoo.AddAnimal(animal);

            // Create a new ostrich and add him to the list of animals.
            animal = new Ostrich("Jake", 40, 200);

            this.comoZoo.AddAnimal(animal);

            // Create a new shark and add him to the list of animals.
            animal = new Shark("Max", 23, 185);

            this.comoZoo.AddAnimal(animal);

            // Create a new squirrel and them to the list.
            animal = new Squirrel("Matt", 21, 200);

            this.comoZoo.AddAnimal(animal);

            // Create a guest.
            Guest guest = new Guest("Greg", 44, 150.35m, "Brown");

            // Add the guest and sell the ticket to the guest.
            this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest));

            // Create a guest.
            guest = new Guest("Darla", 11, 25.25m, "Salmon");

            // Add the guest and sell the ticket to the guest.
            this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest));
        }
 public void FeedTheBirds(Hummingbird bird)
 {
     WhichMethod = "Hummingbird";
 }
Beispiel #12
0
    public override void perform(Controller c)
    {
        Hummingbird bird = State.cast <Hummingbird> (c);

        bird.nextPatrolNode();
    }