コード例 #1
0
    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
    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;
        }
    }