Exemple #1
0
    public override void UseInteractable(BeeSwarm bees)

    {
        base.UseInteractable(bees);
        GetComponent <Renderer>().material = AfterInteractColour;
        GameObject.Destroy(LockedDoor);
    }
Exemple #2
0
    public override void UseInteractable(BeeSwarm bees)
    {
        base.UseInteractable(bees);
        if (bees.numBees < beesRequired)
        {
            return;
        }
        if (brotherButton.pressed)
        {
            GameObject.Destroy(lockedDoor);
            GameObject.Destroy(countdownObj);

            changeColour(2);
            brotherButton.changeColour(2);

            countdownButtons = false;
            brotherButton.countdownButtons = false;
            brotherButton.DestroyTimer();
        }
        else if (this.pressed == false)
        {
            this.pressed = true;
            changeColour(1);
            countdownObj = (GameObject)Instantiate(uiTimer, gameObject.transform.position, gameObject.transform.rotation);
            countdownObj.transform.localPosition = uiTimerPos.transform.position;
            countdownObj.GetComponent <Countdown>().passParam(resetTime);
        }
    }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     targetedBees = NoticingSwarm();
     if (targetedBees != null)
     {
         if (countDown > 0)
         {
             countDown -= Time.deltaTime;
         }
         else
         {
             indicator.adjust = 1;
             agent.SetDestination(targetedBees.transform.position);
             if ((targetedBees.transform.position - agent.transform.position).magnitude < 2.5f)
             {
                 targetedBees.Hurt();
             }
         }
         //ToDo damage, pathfinding
     }
     else
     {
         countDown = ogCountdown;
         //ToDo normal behavior
     }
 }
Exemple #4
0
    public override void UseInteractable(BeeSwarm bees)

    {
        if (bees.numBees < beesRequired)
        {
            return;
        }
        Material col = colours[i % 2];

        i++;
        base.UseInteractable(bees);
        GetComponent <Renderer>().material = col;
        if (platform != null)
        {
            platform.toggleState();
        }
        if (platform2 != null)
        {
            platform2.toggleState();
        }
        if (platform3 != null)
        {
            platform3.toggleState();
        }
    }
    public override void UseInteractable(BeeSwarm bees)
    {
        base.UseInteractable(bees);
        if (bees.numBees < beesRequired)
        {
            return;
        }
        if (!this.pressed && brotherButton.pressed)
        {
            changeColour(2);
            brotherButton.changeColour(2);

            if (platform1 != null)
            {
                platform1.setState(true);
            }
            if (platform2 != null)
            {
                platform2.setState(true);
            }
            if (platform3 != null)
            {
                platform3.setState(true);
            }

            this.pressed = true;
        }
        else if (this.pressed && brotherButton.pressed)
        {
            this.pressed = false;
            changeColour(0);
            brotherButton.changeColour(1);
            if (platform1 != null)
            {
                platform1.setState(false);
            }
            if (platform2 != null)
            {
                platform2.setState(false);
            }
            if (platform3 != null)
            {
                platform3.setState(false);
            }
        }
        else if (this.pressed && !brotherButton.pressed)
        {
            this.pressed = false;
            changeColour(0);
        }
        else if (!this.pressed && !brotherButton.pressed)
        {
            this.pressed = true;
            changeColour(1);
        }
    }
 public void SetControlledBeeSwarm(BeeSwarm bees)
 {
     controlling = bees;
     controller  = bees.GetComponent <CharacterController>();
     if (cameraFollower == null)
     {
         cameraFollower = GetComponent <CameraFollower>();
     }
     cameraFollower.target = bees.cameraTarget;
 }
Exemple #7
0
    BeeSwarm NoticingSwarm()
    {
        noiseLevel = 0;
        float    maxConspicuousness = 0f;
        BeeSwarm mostConspicBee     = null;

        foreach (BeeSwarm bees in FindObjectsOfType <BeeSwarm>())
        {
            float tempVis = 0;

            if (inVision.Contains(bees))
            {
                tempVis = bees.Visibility(this);
            }

            float tempNoise = bees.Noise(this);

            noiseLevel += tempNoise;

            float tempConspic = tempVis + tempNoise;

            if (tempConspic > maxConspicuousness)
            {
                mostConspicBee     = bees;
                maxConspicuousness = tempConspic;
            }
        }

        if (noiseLevel > obliviousness)
        {
            alert = true;
        }
        else
        {
            alert = false;
        }

        if (alert)
        {
            indicator.adjust = Mathf.Clamp(maxConspicuousness / (obliviousness * .7f), 0f, 1f);
            if (maxConspicuousness > obliviousness * .7f)
            {
                return(mostConspicBee);
            }
        }
        else
        {
            indicator.adjust = Mathf.Clamp(maxConspicuousness / obliviousness, 0f, 1f);
            if (maxConspicuousness > obliviousness)
            {
                return(mostConspicBee);
            }
        }
        return(null);
    }
Exemple #8
0
 public void Die(BeeSwarm killer)
 {
     Debug.Log("Destroying!");
     if (destroyedHive != null)
     {
         Debug.Log("Adding broken hive!");
         Instantiate(destroyedHive, transform.position, destroyedHive.transform.rotation);
     }
     killer.numBees += numBees;
     Destroy(gameObject);
 }
Exemple #9
0
    public override void UseInteractable(BeeSwarm bees)
    {
        base.UseInteractable(bees);
        if (bees.numBees < beesRequired)
        {
            return;
        }
        BeeSwarm swarm = sCont.controlling;

        print(exitPoint.transform.position);
        CharacterController x = swarm.gameObject.GetComponent <CharacterController>();

        x.enabled = false;
        swarm.gameObject.transform.position = exitPoint.position;
        x.enabled = true;
    }
Exemple #10
0
    protected virtual void Update()
    {
        // Check to see if we're in posistion to interact
        if (canInteract)
        {
            // Check to see if the mouse is over the interactable
            RaycastHit hit;
            Ray        ray       = Camera.main.ScreenPointToRay(Input.mousePosition);
            int        layerMask = SwarmController.LAYER_MASK_IGNORE_PLAYER;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
            {
                if (hit.rigidbody != null)
                {
                    canSelect = ReferenceEquals(hit.rigidbody.gameObject, gameObject);
                    //Debug.Log("hit ourselves!");
                }
                else
                {
                    canSelect = false;
                }
            }
            else
            {
                canSelect = false;
            }

            BeeSwarm interactor = SwarmController.i.GetControlledBeeSwarm();
            // If we can select and are wanting to interact with the interactable...
            if (canSelect && Input.GetButtonDown("Fire1"))
            {
                if (interactor.numBees >= beesRequired)
                {
                    UseInteractable(interactor);
                    hasInteracted = true;
                }
                else if (alert != null)
                {
                    alert.Alert(beesRequired + " bees required", 2);
                }
            }
        }
    }
Exemple #11
0
 public override void UseInteractable(BeeSwarm bees)
 {
     if (!equipped)
     {
         bees.clothes            = this;
         transform.rotation      = bees.transform.rotation;
         faceMovement.controller = bees.GetComponent <CharacterController>();
         faceMovement.enabled    = true;
         transform.SetParent(bees.transform);
         transform.localPosition = Vector3.zero;
         rb.isKinematic          = true;
         equipped = true;
         wornBy   = bees;
         foreach (Collider collider in toDisable)
         {
             collider.enabled = false;
         }
         gameObject.layer = 2;
     }
 }
Exemple #12
0
    public bool Split()
    {
        if (numBees >= 400)
        {
            Vector3 newPosition;

            bool validSpawn = SwarmController.i.CheckMousePlacement(out newPosition);

            if (validSpawn)
            {
                BeeSwarm spawnedBees = Instantiate(newBees, newPosition, transform.rotation).GetComponent <BeeSwarm>();
                int      newNumBees  = 200;
                numBees            -= newNumBees;
                spawnedBees.numBees = newNumBees;
                spawnedBees.clothes = null;
                return(true);
            }
        }
        return(false);
    }
        public static void RunMain()
        {
            int maxIterations = 2000;
            int dimension     = 2;
            int displayEvery  = 10;

            double[]  lowerBounds = new double[] { -2.048, -2.048 };
            double[]  upperBounds = new double[] { 2.048, 2.048 };
            SimpleBee finalSolution;

            BeeSwarm <SimpleBee> .Solve(dimension, (solution) =>
            {
                // this is the Rosenbrock Saddle cost function

                double x0 = solution[0];
                double x1 = solution[1];

                double cost = 100 * Math.Pow(x0 *x0 - x1, 2) + Math.Pow(1 - x0, 2);
                return(cost);
            }, out finalSolution, lowerBounds, upperBounds, maxIterations, displayEvery);
        }
Exemple #14
0
    // Add/remove pushing objects when they enter/leave range
    void OnTriggerEnter(Collider other)
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, other.transform.position - transform.position, out hit))
        {
            if (hit.collider == other)
            {
                if (!other.CompareTag("Player") && other.GetComponent <Rigidbody>() != null && (!other.isTrigger || other.CompareTag("Hive")))
                {
                    inRange.Add(other.GetComponent <Rigidbody>());
                    Outline outline = other.GetComponent <Outline>();
                    if (outline == null)
                    {
                        outline = other.gameObject.AddComponent <Outline>();
                    }
                    outline.OutlineWidth = 4;
                    outline.OutlineColor = Color.white;
                    outline.enabled      = true;
                }
                else if (other.GetComponent <BeeSwarm>() != null)
                {
                    // JOIN 2 SWARMS TOGETHER
                    BeeSwarm component = other.GetComponent <BeeSwarm>();
                    if (other.gameObject != this.gameObject && this != SwarmController.i.GetControlledBeeSwarm())
                    {
                        component.numBees += numBees;
                        if (component.HasClothes())
                        {
                            component.clothes.Drop();
                        }
                        Destroy(this.gameObject);
                    }
                }
            }
        }
    }
Exemple #15
0
    void Update()
    {
        if (Input.GetButtonDown("R"))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        BeeSwarm currentSwarm = swarmCont.GetControlledBeeSwarm();

        if (GameObject.ReferenceEquals(lastSwarm, currentSwarm) == false)
        {
            lastSwarm = currentSwarm;
            foreach (GameObject obj in floatingBeeCounter)
            {
                GameObject.Destroy(obj);
            }

            List <BeeSwarm> otherSwarms = FindObjectsOfType <BeeSwarm>().ToList();
            if (otherSwarms.Count == 1)
            {
                return;
            }
            otherSwarms.Remove(currentSwarm);

            foreach (BeeSwarm swarm in otherSwarms)
            {
                print(otherSwarms.Count);
                int         beeCount = swarm.numBees;
                var         obj      = (GameObject)Instantiate(floatingBeeCounterPrefab, swarm.transform.position, Quaternion.Euler(45, 45, 0));
                GameObject  x        = obj.GetComponent <Wack>().getfloatObject();
                TextMeshPro tPro     = x.GetComponent <TextMeshPro>();
                tPro.text = "BEANS";
                floatingBeeCounter.Add(obj);
            }
        }
    }
    private void Update()
    {
        BeeSwarm curSwarm = swarmCont.GetControlledBeeSwarm();

        tMesh.text = "Bees in swarm\n" + curSwarm.numBees.ToString();
    }
Exemple #17
0
    public override void UseInteractable(BeeSwarm bees)

    {
        SceneManager.LoadScene("Main Menu");
    }
Exemple #18
0
 public virtual void UseInteractable(BeeSwarm bees)
 {
     // Overwrite this for each interactable
 }