void disableAllScript()
    {
        foreach (GameObject drone in drones)
        {
            Wandering       wandering       = drone.GetComponent <Wandering>();
            CircleFormation circleFormation = drone.GetComponent <CircleFormation>();
            SphereFormation sphereFormation = drone.GetComponent <SphereFormation>();
            Boid            boid            = drone.GetComponent <Boid>();
            CircleMovement  circle          = drone.GetComponent <CircleMovement>();

            if (wandering.enabled)
            {
                wandering.enabled = false;
            }
            if (circleFormation.enabled)
            {
                circleFormation.enabled = false;
            }
            if (sphereFormation.enabled)
            {
                sphereFormation.enabled = false;
            }
            if (boid.enabled)
            {
                boid.enabled = false;
            }
            if (circle.enabled)
            {
                circle.enabled = false;
            }
        }
    }
예제 #2
0
    private void AssignJobsToIdlers()
    {
        // assign jobs to idle workers

        foreach (var worker in workers)
        {
            //assign a worker a job if they don't have one
            if (worker.GetJob() == null)
            {
                // first see if there are jobs availiable, otherwise
                //  assign a random idle job

                if (job_queue.Count == 0)
                {
                    // assign an idle task

                    var idle_job_types = new List <string>()
                    {
                        //"WaitingAround",
                        "Wandering"
                    };

                    int selection = (int)UnityEngine.Random.Range(0f, idle_job_types.Count);

                    var t = idle_job_types[selection];

                    Job new_job = null;

                    if (t == "WaitingAround")
                    {
                        new_job = new WaitingAround(worker);
                    }
                    else if (t == "Wandering")
                    {
                        new_job = new Wandering(worker);
                    }
                    else
                    {
                        // if for some odd reason we get here
                        // give up on this unit for this tick
                        continue;
                    }

                    worker.AssignJob(new_job);

                    in_progress_jobs.Add(new_job);
                }
                else
                {
                    var new_job = job_queue.Dequeue();

                    worker.AssignJob(new_job);

                    in_progress_jobs.Add(new_job);
                }
            }
        }
    }
예제 #3
0
    public void React()
    {
        Wandering behavior = GetComponent <Wandering>();

        if (behavior != null)
        {
            behavior.setAlive(false);
        }
        StartCoroutine(Die());
    }
예제 #4
0
 public DefaultMovementController(string characterName, GameObject character)
 {
     this.characterName     = characterName;
     this.character         = character;
     wanderingFunctions     = new Wandering(this.character);
     pursuingFunctions      = new Pursuing(this.character);
     pathfollowingFunctions = new PathFollowing(this.character, new ArrayList()
     {
         new Vector2(115f, 5f), new Vector2(115f, 10f), new Vector2(120f, 10f), new Vector2(120f, 5f)
     }, true);
     bouncingFunctions     = new Bounce(this.character);
     nearbyPlayerFunctions = new NearbyTarget(this.character, targetPoint, .5f);
     previousLocation      = character.transform.position;
 }
예제 #5
0
    public void Spawn()
    {
        Wandering behavior = GetComponent <Wandering>();


        for (int i = 0; i < enemies.Count; i++)
        {
            if (!enemies[i].activeInHierarchy) //disabled/in the pool
            {
                enemies[i].transform.position = new Vector3(Random.Range(-5, 5), (float)0.5, Random.Range(-5, 5));
                float angle = Random.Range(0, 360);
                enemies[i].transform.Rotate(0, angle, 0);
                enemies[i].SetActive(true);
            }
        }
    }
    void switchBehaviour()
    {
        switch (this.behaviour)
        {
        case "Wandering":
            foreach (GameObject drone in drones)
            {
                Wandering wandering = drone.GetComponent <Wandering>();
                wandering.enabled = !wandering.enabled;
            }
            break;

        case "CircleFormation":
            foreach (GameObject drone in drones)
            {
                CircleFormation circleFormation = drone.GetComponent <CircleFormation>();
                circleFormation.enabled = !circleFormation.enabled;
            }
            break;

        case "SphereFormation":
            foreach (GameObject drone in drones)
            {
                SphereFormation sphereFormation = drone.GetComponent <SphereFormation>();
                sphereFormation.enabled = !sphereFormation.enabled;
            }
            break;

        case "Boid":
            foreach (GameObject drone in drones)
            {
                Boid boid = drone.GetComponent <Boid>();
                boid.enabled = !boid.enabled;
            }
            break;

        case "CircleMovement":
            foreach (GameObject drone in drones)
            {
                CircleMovement circleMvt = drone.GetComponent <CircleMovement>();
                circleMvt.enabled = !circleMvt.enabled;
            }
            break;
        }
    }
 public StateContainer()
 {
     flee = new Fleeing();
     hunt = new Hunting();
     wander = new Wandering();
 }
예제 #8
0
    private void OnEnable()
    {
        Wandering behavior = GetComponent <Wandering>();

        behavior.setAlive(true);
    }
예제 #9
0
 public StateContainer()
 {
     flee   = new Fleeing();
     hunt   = new Hunting();
     wander = new Wandering();
 }