Esempio n. 1
0
    public float breedBunny(GameObject bunnyOne, GameObject bunnyTwo)
    {
        BunnyAI bunnyOneAI = bunnyOne.GetComponent<BunnyAI>();
        BunnyAI bunnyTwoAI = bunnyTwo.GetComponent<BunnyAI>();
        string genderOne = bunnyOneAI.gender;
        string genderTwo = bunnyTwoAI.gender;

        if (genderOne != genderTwo && genderOne == "Female")
        {
            playerHand = bunnyOne.GetComponent<BunnyPickup>().playerHand;
            Transform bunnyOneTransform = bunnyOne.transform;
            Transform bunnyTwoTransform = bunnyTwo.transform;
            float posX = (bunnyOneTransform.position.x + bunnyTwoTransform.position.x) / 2;
            float posY = (bunnyOneTransform.position.y + bunnyTwoTransform.position.y) / 2;

            string breedOne = bunnyOneAI.breed;
            string breedTwo = bunnyTwoAI.breed;

            // Debug.Log("Creating bunny at " + posX + ", " + posY + ".");
            // Debug.Log("With Parents " + breedOne + ", " + breedTwo + ".");
            string resultBreed = "";
            if (breedingMap.ContainsKey((breedOne, breedTwo)))
            {
                resultBreed = breedingMap[(breedOne, breedTwo)];
            }
            else if (breedingMap.ContainsKey((breedTwo, breedOne)))
            {
                resultBreed = breedingMap[(breedTwo, breedOne)];
            }
Esempio n. 2
0
    public bool addBunny(GameObject bunny)
    {
        if (bunnies.Sum(x => x.Value) >= holdingLimit)
        {
            return(false);
        }

        BunnyAI bunnyAiScript = bunny.GetComponent <BunnyAI>();
        string  key           = bunnyAiScript.breed + "-" + bunnyAiScript.gender;

        if (bunnies.ContainsKey(key))
        {
            bunnies[key]++;
            Stack <GameObject> bunnyStack = bunnyGameObjects[key];
            bunnyStack.Push(bunny);
            bunnyGameObjects[key] = bunnyStack;
        }
        else
        {
            bunnies.Add(key, 1);
            Stack <GameObject> bunnyStack = new Stack <GameObject>();
            bunnyStack.Push(bunny);
            bunnyGameObjects.Add(key, bunnyStack);
        }

        inventoryUIHandler.GetComponent <InventoryUIHandler>().refresh(bunnies);

        return(true);
    }
Esempio n. 3
0
 public DoISeeCarrot(IDecision trueBranch, IDecision falseBranch, BunnyAI bunny)
 {
     if (bunny.carrotSpotted) //collider dependant
     {
         value           = true;
         this.trueBranch = trueBranch;
     }
     else
     {
         value            = false;
         this.falseBranch = falseBranch;
     }
 }
Esempio n. 4
0
 public DidIMeetFence(IDecision trueBranch, IDecision falseBranch, BunnyAI bunny)
 {
     if (bunny.trapped) //collider dependant
     {
         value           = true;
         this.trueBranch = trueBranch;
     }
     else
     {
         value            = false;
         this.falseBranch = falseBranch;
     }
 }
Esempio n. 5
0
    public AmINearCarrot(IDecision trueBranch, IDecision falseBranch, BunnyAI bunny)
    {
        float minDistance = Mathf.Infinity;
        float newDist     = 0;
        int   index       = 0;

        for (int i = 0; i < bunny.carrots.Capacity; i++)
        {
            newDist = Vector3.Distance(bunny.transform.position, bunny.carrots[i].gameObject.transform.position); // looks for the distance betw bunny and all carrots

            if (newDist < minDistance)
            {
                minDistance = newDist;
                index       = i;
            }
        }

        if (bunny.carrots.Count > 0)
        {
            if (Vector3.Distance(bunny.transform.position, bunny.carrots[index].gameObject.transform.position) < 1.5f) //check the distance between all carrots and player/collider dependant
            {
                value           = true;
                this.trueBranch = trueBranch;
            }
            else
            {
                value            = false;
                this.falseBranch = falseBranch;
            }
        }
        else
        {
            value            = false;
            this.falseBranch = falseBranch;
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        bossHealth = status.enemyHealth;
        if (bossHealth <= 0)
        {
            dying = true;
            anim.SetBool("dying", true);
        }
        if (dying)
        {
            deathcounter++;
            if (deathcounter == 60)
            {
                Destroy(this.gameObject);
            }
        }
        if (!dying)
        {
            if (!JustAttacked)
            {
                if (!BossAttackDecision)
                {
                    BossAttack = Random.Range(0, 3);
                    //BossAttack = 0;
                    BossAttackDecision = true;
                    anim.SetBool("cooldown", false);
                    anim.SetBool("bossAttacking", true);
                    //Reset the Timer for when attacks happen
                    CurrentAttackTimer = 0;
                }
                if (BossAttackDecision)
                {
                    switch (BossAttack)
                    {
                    case 0:                     //SmashAttack;
                        CurrentAttackLimit = 300;
                        CurrentAttackTimer++;
                        if (CurrentAttackTimer < 240)
                        {
                            vine.enabled = true;
                        }
                        if (CurrentAttackTimer == 280)
                        {
                            vine.enabled = false;
                        }
                        if (CurrentAttackTimer == CurrentAttackLimit)
                        {
                            SmashAttack.SetActive(true);
                            Instantiate(crater, this.transform.position, this.transform.rotation);
                            CurrentAttackTimer = 0;
                            BossAttackDecision = false;
                            JustAttacked       = true;
                            anim.SetBool("cooldown", true);
                            anim.SetBool("bossAttacking", false);
                            cooldownlimit = 180;
                        }
                        break;

                    case 1:                     //Summon Underlings
                        CurrentAttackLimit = 60;

                        //Create the minions
                        if (CurrentAttackTimer == 0)
                        {
                            GameObject a = (Instantiate(minion, this.transform.position, this.transform.rotation)) as GameObject;
                            GameObject b = (Instantiate(minion, this.transform.position, this.transform.rotation)) as GameObject;
                            //Have them spawn on the left and right side of the boss
                            a.transform.Translate(new Vector3(10, 0, 0));
                            b.transform.Translate(new Vector3(-10, 0, 0));
                            BunnyAI acon = a.GetComponent <BunnyAI> ();
                            BunnyAI bcon = b.GetComponent <BunnyAI> ();
                            //acon.player = GameObject.FindWithTag ("Player");
                            //bcon.player = GameObject.FindWithTag ("Player");
                            //Make them detect the player wherever he is in the arena
                            acon.viewRange = 100;
                            bcon.viewRange = 100;
                        }
                        CurrentAttackTimer++;
                        if (CurrentAttackTimer == CurrentAttackLimit)
                        {
                            CurrentAttackTimer = 0;
                            BossAttackDecision = false;
                            JustAttacked       = true;
                            anim.SetBool("cooldown", true);
                            anim.SetBool("bossAttacking", false);
                            cooldownlimit = 360;
                        }
                        break;

                    case 2:                     //Ring of Thorns
                        CurrentAttackLimit = 240;
                        CurrentAttackTimer++;
                        Rotator r = this.GetComponentInChildren <Rotator> ();
                        r.rotate = true;
                        Debug.Log("set rotate");
                        if (CurrentAttackTimer == CurrentAttackLimit)
                        {
                            r.rotate           = false;
                            CurrentAttackTimer = 0;
                            BossAttackDecision = false;
                            JustAttacked       = true;
                            anim.SetBool("cooldown", true);
                            anim.SetBool("bossAttacking", false);
                            cooldownlimit = 240;
                        }
                        break;
                    }
                }
            }
            else
            {
                cooldowncounter++;
                if (cooldowncounter == 2)
                {
                    SmashAttack.SetActive(false);
                }
                if (cooldowncounter == cooldownlimit)
                {
                    JustAttacked    = false;
                    cooldowncounter = 0;
                }
            }
        }
    }
Esempio n. 7
0
 private void Awake()
 {
     aiBunny = FindObjectOfType <BunnyAI>();
     rabbit  = GetComponent <NavMeshAgent>();
     ground  = GameObject.FindGameObjectWithTag("Ground");
 }
Esempio n. 8
0
 public KeepWalking(BunnyAI _bunny)
 {
     bunny = _bunny;
 }
Esempio n. 9
0
 public EatCarrot(BunnyAI _bunny)
 {
     bunny = _bunny;
 }
Esempio n. 10
0
 public GoToCarrot(BunnyAI _bunny)
 {
     bunny = _bunny;
 }
Esempio n. 11
0
 public BiteFence(BunnyAI _bunny)
 {
     bunny = _bunny;
 }
Esempio n. 12
0
 public void Init(float speed, BunnyAI AI)
 {
     runSpeed = speed / 2.5f;
     ai       = AI;
 }