示例#1
0
    public override void Initialize()
    {
        print("Initializing : PedestrianWorldBehavior");


        for (int i = 0; i < numPedestrians / 2; i++)
        {
            {
                AAgent a = CreateAgent(world, pedestrian);
                PedestrianWalkBehavior pwb = a.GetComponent <PedestrianWalkBehavior> ();

                pwb.Direction        = Vector3.right;
                a.transform.position = new Vector3(-10, 0, (Random.value - 0.5f) * 10);
                pwb.Speed            = Random.Range(minSpeed, maxSpeed);
            }
            {
                AAgent a = CreateAgent(world, pedestrian);
                PedestrianWalkBehavior pwb = a.GetComponent <PedestrianWalkBehavior> ();

                pwb.Direction        = Vector3.left;
                a.transform.position = new Vector3(10, 0, (Random.value - 0.5f) * 10);
                pwb.Speed            = Random.Range(minSpeed, maxSpeed);
            }
        }
    }
    void OnTriggerEnter(Collider c)
    {
        print(c.name);
        PedestrianWalkBehavior pwb = c.GetComponent <PedestrianWalkBehavior> ();

        if (pwb)
        {
            AAgent a = pwb.GetComponent <AAgent> ();
            a.World.ResignAgent(a);
        }
    }