コード例 #1
0
        public void TestOpeningClosingAndMovementForExits()
        {
            // Create two one-way exits and two rooms to attach them to.
            var openableExitA = new Thing()
            {
                Name = "OpenableExitA", Id = TestThingID.Generate("testthing")
            };
            var openableExitB = new Thing()
            {
                Name = "OpenableExitB", Id = TestThingID.Generate("testthing")
            };
            var roomA = new Thing(new RoomBehavior())
            {
                Name = "Room A", Id = TestThingID.Generate("testroom")
            };
            var roomB = new Thing(new RoomBehavior())
            {
                Name = "Room B", Id = TestThingID.Generate("testroom")
            };

            roomA.Add(openableExitA);
            roomB.Add(openableExitB);

            // Attach ExitBehavior and OpensClosesBehaviors in different orders though, to verify in test that
            // eventing and such work correctly regardless of attachment order.
            var exitBehaviorA        = new ExitBehavior();
            var exitBehaviorB        = new ExitBehavior();
            var opensClosesBehaviorB = new OpensClosesBehavior();

            openableExitA.Behaviors.Add(exitBehaviorA);
            openableExitA.Behaviors.Add(opensClosesBehavior);
            openableExitB.Behaviors.Add(opensClosesBehaviorB);
            openableExitB.Behaviors.Add(exitBehaviorB);

            // Rig up behaviors so the actor can move, and move from one A to B, and from B to A.
            actingThing.Behaviors.Add(new MovableBehavior());
            exitBehaviorA.AddDestination("toB", roomB.Id);
            exitBehaviorB.AddDestination("toA", roomA.Id);

            // Ensure that the actingThing cannot move through either exit while it is in default (closed) state.
            roomA.Add(actingThing);
            exitBehaviorA.MoveThrough(actingThing);
            Assert.AreSame(roomA, actingThing.Parent);

            roomB.Add(actingThing);
            exitBehaviorB.MoveThrough(actingThing);
            Assert.AreSame(roomB, actingThing.Parent);

            // Ensure that the actingThing can open and move through each openable exit to get between rooms.
            opensClosesBehaviorB.Open(actingThing);
            exitBehaviorB.MoveThrough(actingThing);
            Assert.AreSame(roomA, actingThing.Parent);

            opensClosesBehavior.Open(actingThing);
            exitBehaviorA.MoveThrough(actingThing);
            Assert.AreSame(roomB, actingThing.Parent);
        }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("Activator Collision detected");

        if (other.CompareTag("Player"))
        {
            Debug.Log("Activator Player Collision Detected");

            GameObject Exit = GameObject.FindGameObjectWithTag("Exit");

            ExitBehavior exitScript = Exit.GetComponent <ExitBehavior>();

            exitScript.ActivateExit();
        }
    }
コード例 #3
0
 public void Init()
 {
     // Create 2 rooms and a basic ExitBehavior in prep for testing.
     this.roomA = new Thing(new RoomBehavior())
     {
         Name = "Room A", ID = TestThingID.Generate("testroom")
     };
     this.roomB = new Thing(new RoomBehavior())
     {
         Name = "Room B", ID = TestThingID.Generate("testroom")
     };
     this.exitBehavior = new ExitBehavior();
     this.exit         = new Thing(this.exitBehavior)
     {
         Name = "Exit", ID = TestThingID.Generate("testexit")
     };
 }
コード例 #4
0
        public void Init()
        {
            // Create the basic actor instances and behavior for test.
            this.witness = new Thing()
            {
                Name = "Witness", ID = TestThingID.Generate("testthing")
            };
            this.stalker1 = new Thing()
            {
                Name = "Stalker1", ID = TestThingID.Generate("testthing")
            };
            this.stalker2 = new Thing()
            {
                Name = "Stalker2", ID = TestThingID.Generate("testthing")
            };
            this.victim1 = new Thing()
            {
                Name = "Victim1", ID = TestThingID.Generate("testthing")
            };
            this.victim2 = new Thing()
            {
                Name = "Victim2", ID = TestThingID.Generate("testthing")
            };

            // Set up the rooms.
            this.room1 = new Thing()
            {
                Name = "Room", ID = TestThingID.Generate("room")
            };
            this.room2 = new Thing()
            {
                Name = "Room 2", ID = TestThingID.Generate("room")
            };

            // Set up an exit connecting the two rooms.
            this.exit = new Thing()
            {
                Name = "East Exit", ID = TestThingID.Generate("exit")
            };
            var exitBehavior = new ExitBehavior();

            ////exitBehavior.AddDestination("west", room1.ID);
            ////exitBehavior.AddDestination("east", room1.ID);
            ////this.exit.BehaviorManager.Add(exitBehavior);

            this.room1.Add(this.exit);
            this.room2.Add(this.exit);

            // Populate the first room.
            this.room1.Add(this.witness);
            this.room1.Add(this.stalker1);
            this.room1.Add(this.stalker2);
            this.room1.Add(this.victim1);
            this.room1.Add(this.victim2);

            // Prepare to verify correct eventing occurs.
            this.witness.Eventing.MovementRequest  += (root, e) => { this.lastWitnessRequest = e; };
            this.witness.Eventing.MovementEvent    += (root, e) => { this.lastWitnessEvent = e; };
            this.stalker1.Eventing.MovementRequest += (root, e) => { this.lastStalkerRequest = e; };
            this.stalker1.Eventing.MovementEvent   += (root, e) => { this.lastStalkerEvent = e; };
            this.stalker2.Eventing.MovementRequest += (root, e) => { this.lastStalkerRequest = e; };
            this.stalker2.Eventing.MovementEvent   += (root, e) => { this.lastStalkerEvent = e; };
            this.victim1.Eventing.MovementRequest  += (root, e) => { this.lastVictimRequest = e; };
            this.victim1.Eventing.MovementEvent    += (root, e) => { this.lastVictimEvent = e; };
            this.victim2.Eventing.MovementRequest  += (root, e) => { this.lastVictimRequest = e; };
            this.victim2.Eventing.MovementEvent    += (root, e) => { this.lastVictimEvent = e; };
        }
コード例 #5
0
ファイル: SpawnTDS.cs プロジェクト: remulasce/X-Runner
 public Wave(FormationType ft, EntryBehavior nb, LoiterBehavior lb, AttackType at, ExitTrigger xt, ExitBehavior xb, float timeTillNextWave, bool boundsCheck)
 {
     this.ft = ft; this.nb = nb; this.lb = lb; this.at = at; this.xt = xt; this.xb = xb; this.waveDuration = timeTillNextWave; this.boundsCheck = boundsCheck;
 }