示例#1
0
        public void FillTimeTable()
        {
            WorldCoordinate positionA = new WorldCoordinate("Eden", new IntPoint(2, 3));
            WorldCoordinate positionB = new WorldCoordinate("Eden", new IntPoint(4, 1));
            WorldCoordinate positionC = new WorldCoordinate("Eden", new IntPoint(1, 2));

            Timetable timetable = _world.timetableRunner.CreateTimetable("NewTimetable", "");

            timetable.CreateTimetableSpanInternal( new GameTime(03, 00), new GameTime(08, 00), new Behaviour_BeAtPosition(positionA));
            timetable.CreateTimetableSpanInternal( new GameTime(08, 00), new GameTime(21, 00), new Behaviour_BeAtPosition(positionB));
            timetable.CreateTimetableSpanInternal( new GameTime(21, 00), new GameTime(03, 00), new Behaviour_BeAtPosition(positionC));

            Console.WriteLine("TimetableSpans: \n" + timetable.TimetableSpansToString());

            _eva.timetableName = "NewTimetable";
            _eva.logger.AddListener(Console.WriteLine);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(1, 05, 00, 00));
            Assert.AreEqual(positionA, _eva.position);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(1, 12, 00, 00));
            Assert.AreEqual(positionB, _eva.position);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(2, 02, 00, 00));
            Assert.AreEqual(positionC, _eva.position);
        }
示例#2
0
        public void BasicUsage()
        {
            WorldCoordinate a = new WorldCoordinate("ladeda", new IntPoint(13, 37));
            WorldCoordinate b = new WorldCoordinate("ladeda", new IntPoint(13, 37));
            Assert.IsTrue(a == b);
            Assert.IsTrue(a.GetHashCode() == b.GetHashCode());

            WorldCoordinate c = new WorldCoordinate("ladeda", new IntPoint(13, 37));
            WorldCoordinate d = new WorldCoordinate("ladeda", new IntPoint(13, 31));
            Assert.IsTrue(c != d);
            Assert.IsTrue(c.GetHashCode() != d.GetHashCode());

            WorldCoordinate e = new WorldCoordinate("ladeda", new IntPoint(13, 37));
            WorldCoordinate f = new WorldCoordinate("ladeba", new IntPoint(13, 37));
            Assert.IsTrue(e != f);
            Assert.IsTrue(e.GetHashCode() != f.GetHashCode());
        }
示例#3
0
        public void DropHandItemFar()
        {
            if (isAvatar && busy) {
                _worldSettings.Notify(name, name + " is busy!");
                return;
            }

            if(handItem == null) {
                D.Log("Don't have a hand item");
                return;
            }

            var dropTarget = new WorldCoordinate (room.name, localPoint + IntPoint.DirectionToIntPoint (direction) * 2);
            var tileDropTarget = room.GetTile(dropTarget.localPosition);

            if(tileDropTarget == null || (isAvatar && tileDropTarget.HasOccupants())) {
                _worldSettings.Notify (name, "Can't put " + handItem.name + " there");
                return;
            }

            StartAction("DroppingFar", handItem, 1.0f, 1.5f);
        }
示例#4
0
        private void PrepareForNewWalkBehaviour(WorldCoordinate pFinalTargetPosition, Ting pFinalTargetTing, WalkMode pWalkMode)
        {
            #if LOG
            logger.Log(name + " is preparing new walk behaviour with final target position " + pFinalTargetPosition);
            #endif

            if (pFinalTargetTing is Computer) {
                var tile = pFinalTargetTing.room.GetTile(pFinalTargetTing.interactionPoints[0]);
                if(tile != null) {
                    var chairInFrontOfComputer = tile.GetOccupantOfType<Seat>();
                    if(chairInFrontOfComputer != null) {
                        pFinalTargetTing = chairInFrontOfComputer;
                        pWalkMode = WalkMode.WALK_TO_TING_AND_INTERACT; // changes the intent of the player
                    }
                } else {
                    D.Log("Tile at interaction point for computer " + pFinalTargetTing + " is null, " + name + " can't walk there.");
                }
            }
            else if (pFinalTargetTing is Tram) {
                var tram = pFinalTargetTing as Tram;
                if(tram.movingDoor != null) {
                    //pFinalTargetTing = tram.movingDoor;
                    WalkToTingAndInteract (tram.movingDoor);
                    D.Log("Switched target for " + name + " from " + tram + " to " + tram.movingDoor);
                    return;
                }
            }

            if (pFinalTargetTing is Seat && pFinalTargetTing == this.seat) {
                #if LOG
                logger.Log(name + " can't sit on seat " + pFinalTargetTing + " since she/he is already doing that.");
                #endif
                return;
            }

            if (pFinalTargetTing is Bed && pFinalTargetTing == this.bed) {
                #if LOG
                logger.Log(name + " can't lay in bed " + pFinalTargetTing + " since she/he is already doing that.");
                #endif
                return;
            }

            finalTargetPosition = pFinalTargetPosition;
            finalTargetTing = pFinalTargetTing;
            walkMode = pWalkMode;
            walkIterator = 0;

            //			if (actionName == "GettingUpFromSeat" || actionName == "GettingUpFromBed") {
            //				return;
            //			} else if (actionName == "PickingUp" || actionName == "Dropping" || actionName == "DroppingFar") {
            //				return;
            //			}
            if (busy) {
                return;
            }
            else if (sitting) {
                if (seat != null) {
                    GetUpFromSeat ();
                    return;
                } else {
                    //D.Log("Just start walking (from sitting)");
                    sitting = false;
                }
            } else if (laying) {
                if (bed != null) {
                    GetUpFromBed ();
                    return;
                } else {
                    //D.Log ("Just start walking (from laying down)");
                    laying = false;
                }
            }

            _walkBehaviour = null;

            ClearConversationTarget();
            seat = null;
            bed = null;
        }
示例#5
0
        public string API_SetWorldPosition(string room, float x, float y)
        {
            if(room.Contains("inventory") || room.Contains("locker")) {
                return "Can't teleport there";
            }

            if(IsAllowedToTeleport(_user as Character)) {
                if(_roomRunner.HasRoom(room)) {
                    WorldCoordinate coord = new WorldCoordinate(room, (int)x, (int)y);
                    _user.position = coord;
                    return "Success";
                }
                else {
                    return "Can't find room '" + room + "'";
                }
            }
            else {
                D.Log("Not allowed to set world position");
                return "Not allowed";
            }
        }
示例#6
0
 public bool API_CanMove()
 {
     var newPos = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));
     var newTile = _roomRunner.GetRoom(room.name).GetTile(newPos.localPosition);
     if(newTile == null) {
         return false;
     }
     else if(newTile.GetOccupants().Length > 0) {
         foreach(var occupant in newTile.GetOccupants()) {
             if(occupant is Pawn) {
                 var p = (occupant as Pawn);
                 if(p.team == this.team) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
示例#7
0
		public bool HasInteractionPointHere(WorldCoordinate finalTargetPosition)
		{
			if (room.name == finalTargetPosition.roomName) {
				foreach (IntPoint pos in interactionPoints) {
					if (finalTargetPosition.localPosition == pos) {
						return true;
					}
				}
			}
			return false;
		}
示例#8
0
        public void SleepDrinkAndSitBehaviours()
        {
            _eva.logger.AddListener(Console.WriteLine);
            _eva.timetableName = "Timetable2";
            _eva.sleepiness = 100.0f;

            WorldCoordinate positionA = new WorldCoordinate("Eden", new IntPoint(1, 1));
            WorldCoordinate positionB = new WorldCoordinate("Eden", new IntPoint(4, 2));
            WorldCoordinate positionC = new WorldCoordinate("Eden", new IntPoint(3, 3));

            _world.tingRunner.CreateTing<Bed>("Bed1", positionA);
            Drink drink = _world.tingRunner.CreateTing<Drink>("Drink1", positionB);
            drink.amount = 100f;

            _world.tingRunner.CreateTing<Seat>("Chair1", positionC);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(0, 21, 00, 00));
            Assert.AreEqual("Sleeping", _eva.actionName);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(1, 10, 00, 00));
            Assert.AreEqual(_eva.position, drink.position);

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(1, 19, 00, 00));
            Console.WriteLine("Time: " + _world.settings.gameTimeClock);
            Assert.IsNull(_eva.bed);

            _eva.sleepiness = 200f;

            WorldTestHelper.UpdateWorldUntilGameTime(_world, new GameTime(2, 21, 00, 00));
            Assert.AreEqual("Sleeping", _eva.actionName);
            Assert.IsNull(_eva.seat);
        }
示例#9
0
文件: Ting.cs 项目: substans/TingTing
 internal void SetInitCreateValues(string pName, WorldCoordinate pPosition, Direction pDirection)
 {
     _startingName      = pName;
     _startingPosition  = pPosition;
     _startingDirection = pDirection;
 }
示例#10
0
 public void API_Move()
 {
     var newPos = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));
     position = newPos;
 }
示例#11
0
 void OnPositionChanged(WorldCoordinate pPrevPos, WorldCoordinate pNewPos)
 {
     UpdateMovingDoorPosition();
 }
示例#12
0
        public override void Update(float dt)
        {
            //D.Log("updating vehicle");

            UpdateMovingDoorPosition();

            if(currentNavNode == null || nextNavNode == null) {
                return;
            }

            if (safetySwitchOn) {
                if (movingDoor.actionName == "") {
                    // only allow it to go when the moving door is not operating
                    safetySwitchOn = false;
                }
                return;
            }

            distance += speed * dt;

            if(distanceFraction >= 0.99f) {
                var oldCurrent = currentNavNode;
                distance = 0f;
                currentNavNode = nextNavNode;
                nextNavNode = _tingRunner.GetTingUnsafe(currentNavNode.mainTrackName) as NavNode;
                if(nextNavNode == null) {
                    throw new Exception("nextNavNode is null for vehicle " + name + " at position " + position + " and current nav node " + currentNavNode.name);
                }
                position = currentNavNode.position;
                if(onNewNavNode != null) {
                    onNewNavNode(oldCurrent, currentNavNode);
                }
            }

            if(currentNavNode.room != nextNavNode.room) {
                position = new WorldCoordinate(room.name, 10000, 10000);
                //D.Log(name + " is going between scenes");
            }
            else {
                var delta = nextNavNode.localPoint - currentNavNode.localPoint;
                var middlePosition = currentNavNode.localPoint + delta.scale(distanceFraction);
                position = new WorldCoordinate(room.name, middlePosition);
                direction = delta.Clamped().ToDirection();
            }
        }
示例#13
0
        public void CheckBalance()
        {
            WorldCoordinate testDefaultCoordinate = new WorldCoordinate("Eden", IntPoint.Zero);

            WorldTestHelper.GenerateInitData ();
            InitialSaveFileCreator i = new InitialSaveFileCreator ();
            World world = new World (i.CreateRelay (WorldTestHelper.INIT_DATA_PATH));

            D.onDLog += o => Console.WriteLine("D.Log: " + o);
            world.dialogueRunner.AddOnSomeoneSaidSomethingListener(o => Console.WriteLine("Dialogue: " + o));

            CreditCard card = world.tingRunner.CreateTing<CreditCard> ("Visa", testDefaultCoordinate);
            card.logger.AddListener (o => Console.WriteLine ("Card log: " + o));
            card.AddDataListener ("dialogueLine", (string oldValue, string newValue) => {
                Console.WriteLine ("Card said: " + newValue);
            });
            card.nameOfOwner = "Eva";
            card.masterProgramName = "EvasCard";

            Computer financeComputer = world.tingRunner.CreateTing<Computer>("FinanceComputer", testDefaultCoordinate);
            financeComputer.masterProgramName = "FinanceComputer";
            financeComputer.hasMemoryAPI = true;
            financeComputer.masterProgram.Start();

            WorldTestHelper.UpdateWorld (world, 3f);
            card.RunMakeTransactionFunction (100.0f);
            WorldTestHelper.UpdateWorld (world, 3f);

            Console.WriteLine ("Evas card errors: ");
            foreach (var error in card.masterProgram.GetErrors()) {
                Console.WriteLine (error.ToString ());
            }

            Console.WriteLine ("Finance computer errors: ");
            foreach (var error in financeComputer.masterProgram.GetErrors()) {
                Console.WriteLine (error.ToString ());
            }

            Console.WriteLine ("Finance computer output: ");
            PrintOutput(financeComputer);

            Assert.IsNotNull(financeComputer.memory);
            Assert.IsNotNull(financeComputer.memory.data);

            object cashAmount = null;
            bool gotIt = financeComputer.memory.data.TryGetValue("Eva", out cashAmount);

            Assert.IsTrue(gotIt);
            Assert.AreEqual(typeof(float), cashAmount.GetType());
            Assert.AreEqual(100.0f, (float)cashAmount);

            card.RunMakeTransactionFunction(-20.0f);
            WorldTestHelper.UpdateWorld (world, 1.0f);

            Assert.IsNotNull(financeComputer.memory);
            Assert.IsNotNull(financeComputer.memory.data);

            object cashAmount2 = null;
            bool gotIt2 = financeComputer.memory.data.TryGetValue("Eva", out cashAmount2);

            Assert.IsTrue(gotIt2);
            Assert.AreEqual(80.0f, (float)cashAmount2);
        }
示例#14
0
 //        [SprakAPI("Teleport user to another position. Returns an error message as a string.", "x", "y")]
 //        public string API_TeleportUser(string targetRoom, int x, int y)
 //        {
 //            if(_user == null) {
 //                D.Log ("User for door " + name + " is null");
 //                return "Fail";
 //                //throw new Exception("User is null for door " + name);
 //            }
 //            
 //            if(targetDoor != null) {
 //                var targetRoomRef = _roomRunner.GetRoom(targetRoom);
 //                PushAwayBlockers(targetRoomRef, x, y, IntPoint.DirectionToIntPoint(targetDoor.direction));
 //                WorldCoordinate newPosition = new WorldCoordinate(targetRoom, x, y); // OLD VERSION: door.targetPosition;
 //                logger.Log(name + " opened the door " + name + " and will now teleport to " + newPosition);
 //                _user.targetPositionInRoom = targetDoor.position; // makes the Shell not freak out when it is created in the new scene but target is still in the old one
 //                _user.position = newPosition;
 //                _user.direction = targetDoor.direction;
 //                _user.StopAction();
 //                _user.StartAction("WalkingThroughDoorPhase2", null, 1.35f, 1.35f);
 //                _dialogueRunner.EventHappened(_user.name + "_open_" + name);
 //                if(isElevatorEntrance) {
 //                    targetDoor.elevatorFloor = this.elevatorFloor;
 //                }
 //                return "Success";
 //            }
 //            else {
 //                return "Door '" + name + "' doesn't have a target";
 //            }
 //        }
 void PushAwayBlockers(Room targetRoom, int x, int y, IntPoint pushDir)
 {
     var tile = targetRoom.GetTile(x, y);
     if(tile == null) return;
     var blockers = tile.GetOccupants();
     foreach(var blocker in blockers) {
         if(blocker is Character) {
             var newPosition = new WorldCoordinate(blocker.position.roomName, blocker.position.localPosition + pushDir * 2);
             if(targetRoom.GetTile(newPosition.localPosition) != null) {
                 //D.Log(blocker + " was pushed by a door from " + blocker.position + " to " + newPosition);
                 blocker.position = newPosition;
             } else {
                 D.Log("Can't push " + blocker.name + " to " + newPosition + " because there is no tile there");
             }
         }
     }
 }
示例#15
0
        public void API_Goto(string doorName)
        {
            if(_user == null) {
                D.Log ("User for door " + name + " is null");
                //throw new Error ("No user for door " + name);
                return;
            }

            var otherDoor = _tingRunner.GetTingUnsafe (doorName) as Door;

            if(otherDoor != null) {
                Room otherRoom = otherDoor.room;
                var interactionPoint = otherDoor.interactionPoints [0];
                int otherX = interactionPoint.x;
                int otherY = interactionPoint.y;

                PushAwayBlockers(otherRoom, otherX, otherY, IntPoint.DirectionToIntPoint(otherDoor.direction));

                WorldCoordinate newPosition = new WorldCoordinate(otherRoom.name, otherX, otherY);

                //D.Log("ExitTroughDoor was called on " + name + " and will now teleport " + _user.name + " to " + newPosition);

                _user.targetPositionInRoom = otherDoor.position; // makes the Shell not freak out when it is created in the new scene but target is still in the old one
                _user.position = newPosition;
                _user.direction = otherDoor.direction;
                _user.StopAction();
                _user.StartAction("WalkingThroughDoorPhase2", null, 1.35f, 1.35f);
                ResetAttempts(); // success!

                _dialogueRunner.EventHappened(_user.name + "_open_" + name);
                if(isElevatorEntrance) {
                    otherDoor.elevatorFloor = this.elevatorFloor;
                }
            }
            else {
                throw new Error ("Can't find door with name " + doorName);
            }
        }
示例#16
0
 public string API_Teleport(float x, float y)
 {
     if(_user != null) {
         WorldCoordinate coord = new WorldCoordinate(_user.room.name, (int)x, (int)y);
         PointTileNode tile = _user.room.GetTile(coord.localPosition);
         if(tile != null) {
             _user.position = coord;
             return "Success";
         }
         else {
             return "Can't move there";
         }
     }
     else {
         throw new Exception("User is null");
     }
 }
示例#17
0
        public string API_SetWorldPosition(string room, float x, float y)
        {
            if(room.Contains("inventory") || room.Contains("locker")) {
                return "Can't teleport there";
            }

            if(_user != null) {
                if(_roomRunner.HasRoom(room)) {
                    WorldCoordinate coord = new WorldCoordinate(room, (int)x, (int)y);
                    _user.position = coord;
                    return "Success";
                }
                else {
                    return "Can't find room '" + room + "'";
                }
            }
            else {
                throw new Error("User is null");
            }
        }
示例#18
0
 public void GetUpBedSnap()
 {
     D.isNull(bed, "bed is null");
     int exitPoint = bed.exitPoint;
     position = new WorldCoordinate(room.name, bed.GetCurrentExitPoint ());
     bed = null;
     //D.Log(name + " got up and snapped to bed interaction point " + exitPoint + " at position " + position + "");
 }
示例#19
0
        public void WalkThrough(Character pCharacter)
        {
            if (targetPortal == null) {
                _worldSettings.Notify(pCharacter.name, "This arrow is leading nowhere!");
                return;
            }

            WorldCoordinate newPosition = new WorldCoordinate(targetPortal.room.name, targetPortal.interactionPoints[0]);
            logger.Log(name + " used the portal " + name + " and will now teleport to " + newPosition);
            pCharacter.position = newPosition;
            pCharacter.direction = targetPortal.direction;
            pCharacter.StopAction();
            pCharacter.StartAction("WalkingThroughPortalPhase2", null, 2.2f, 2.2f);
            //pCharacter.StartAction("WalkingThroughDoorPhase2", null, 2.0f, 2.0f);
            //_dialogueRunner.EventHappened(_user.name + "_open_" + name);
        }
示例#20
0
 public void GetUpSeatSnap()
 {
     D.isNull(seat, "seat is null");
     position = new WorldCoordinate(room.name, seat.GetCurrentExitPoint());
     seat = null;
     //D.Log(name + " got up and snapped to interaction point of seat!");
 }
示例#21
0
 public void WalkTo(WorldCoordinate pPosition)
 {
     PrepareForNewWalkBehaviour(pPosition, null, WalkMode.WALK_TO_POINT);
 }
示例#22
0
        protected override void ActionTriggered(Ting pOtherTing)
        {
            if (actionName == "Drinking") {
                Drink drink = (Drink)pOtherTing;
                D.isNull(drink, "drink is null");
                drink.DrinkFrom (this);
            } else if (actionName == "TakingDrug" || actionName == "Eat") {
                Drug drug = (Drug)pOtherTing;
                D.isNull(drug, "drug is null");
                drug.Take (this);
                actionOtherObject = null;
                SetNoHandItem ();
                _dialogueRunner.EventHappened (name + "_took_" + drug.name);
                _tingRunner.RemoveTingAfterUpdate (drug.name);
            } else if (actionName == "TakingSnus") {
                var snus = pOtherTing as Snus;
                D.isNull(snus, "snus is null");
                snus.Take (this);
                _dialogueRunner.EventHappened (name + "_snusade");
            } else if (actionName == "SmokingCigarette") {
                var cigarette = pOtherTing as Cigarette;
                D.isNull(cigarette, "cigarette is null");
                cigarette.Take (this);
            } else if (actionName == "LockedDoor") {
                _worldSettings.Notify (name, "The door is locked");
                D.isNull(pOtherTing, "pOtherTing is null");
                _dialogueRunner.EventHappened (name + "_yank_" + pOtherTing.name);
            } else if (actionName == "UseDoorReallySoon") {
                D.Log(name + " is triggering UseDoorReallySoon: " + pOtherTing.name);
                var theDoor = (pOtherTing as Door);
                if(theDoor.autoLockTimer <= 0f && ArePointsWithinDistance(localPoint, theDoor.waitingPoint, 1)) {
                    StopAction();
                    InteractWith(pOtherTing);
                }
                else {
                    _worldSettings.Notify(name, "Door was just locked");
                }
            } else if (actionName == "WalkingThroughDoor") {
                Door door = pOtherTing as Door;
                D.isNull(door, "door is null");
                door.WalkThrough (this);
                door.targetDoor.Open (); // mid point
            } else if (actionName == "WalkingThroughDoorPhase2") {
                //D.Log (name + " is done with walk through door phase 2!");
                StopAction ();
                if (_walkBehaviour != null) {
                    _walkBehaviour.StartWalkingAgain ();
                }
            } else if (actionName == "WalkingThroughPortal") {
                Portal portal = pOtherTing as Portal;
                D.isNull(portal, "portal is null");
                portal.WalkThrough (this);
            } else if (actionName == "WalkingThroughPortalPhase2") {
                //D.Log(name + " is done with walk through portal phase 2!");
                StopAction ();
                if (_walkBehaviour != null) {
                    _walkBehaviour.StartWalkingAgain ();
                }
            } else if (actionName == "WalkingThroughFence") {
                //StopAction ();
                StartAction ("DoneWalkingThroughFence", null, 0.01f, 0.02f);
                var fence = (pOtherTing as Fence);
                D.isNull(fence, "fence is null");
                position = fence.goalPosition;
                fence.user = null;
                timetableTimer = 0f; // re-trigger timetable
            } else if (actionName == "UsingDoorWithKey") {
                var door = pOtherTing as Door;
                D.isNull(door, "door is null");

                var key = (handItem as Key);
                if(key == null) {
                    D.Log(name + " is UsingDoorWithKey but has no key in hand, will interact normally with it instead.");
                    InteractWith(door);
                    return;
                }

                key.InteractWith (door);
                #if LOG
                //logger.Log (name + " unlocked the door " + pOtherTing.name + " using the key '" + handItem.name + "'");
                #endif
            } else if (actionName == "PickingUp") {
                if (pOtherTing.isBeingHeld) {
                    #if LOG
                    logger.Log (pOtherTing + " is being held and can't be picked up");
                    #endif
                    return;
                }
                D.isNull(pOtherTing, "pOtherTing is null");
                SetHandItem ((MimanTing)pOtherTing);
                _dialogueRunner.EventHappened (name + "_pickup_" + pOtherTing.name);
                handItem.isBeingHeld = true;
            } else if (actionName == "Dropping" || actionName == "DroppingFar") {
                if(handItem == null) {
                    D.Log (name + " is trying to drop hand item but it is null");
                    return;
                }
                int dropLength = (actionName == "Dropping") ? 1 : 2;
                var dropTarget = new WorldCoordinate (room.name, localPoint + IntPoint.DirectionToIntPoint (direction) * dropLength);
                handItem.position = dropTarget;
                handItem.isBeingHeld = false;
                handItem.direction = direction;
                handItem.OnPutDown ();
                SetNoHandItem ();
            } else if (actionName == "PutHandItemIntoInventory") {
                MoveHandItemToInventory ();
            } else if (actionName == "TakeOutInventoryItem") {
                SetHandItem ((MimanTing)pOtherTing);
                handItem.position = position;
                handItem.isBeingHeld = true;
            } else if (actionName == "LayingDown") {
                D.isNull(bed, "bed is null");
                LayInBed (bed);
            } else if (actionName == "FallingAsleep") {
                int hours = 8;
                if(!isAvatar) {
                    hours = 3; // TODO: do this to make people not sleep as long and miss stuff
                }
                Sleep (gameClock + new GameTime (hours, 0));
            } else if (actionName == "FallingAsleepInChair") {
                Sleep (gameClock + new GameTime (3, 0));
            } else if (actionName == "FallAsleepFromStanding") {
                // Alarm time is set when FallAsleepFromStanding() is called
                Sleep (alarmTime);
                laying = true;
            } else if (actionName == "GettingSeated") {
                var seat = pOtherTing as Seat;
                D.isNull(seat, "seat is null");
                Sit (seat);
            } else if (actionName == "GettingUpFromSeat") {
                //D.Log("GettingUpFromSeat action triggered the normal way");
                AfterGettingUpFromSeat ();
                if (seat != null) {
                    GetUpSeatSnap ();
                }
            } else if (actionName == "GettingUpFromBed") {
                //D.Log("GettingUpFromBed action triggered the normal way");
                AfterGettingUpFromBed ();
                if (bed != null) {
                    GetUpBedSnap ();
                }
            } else if (actionName == "PushingButtonOnHandItem" || actionName == "StartingJukebox") {
                D.Log ("Triggering action " + actionName);
                TingWithButton tingWithButton = pOtherTing as TingWithButton;
                D.isNull(tingWithButton, "tingWithButton is null");
                if (tingWithButton == null) {
                    D.LogError (pOtherTing.name + " is not a TingWithButton");
                }
                tingWithButton.PushButton (this);
            } else if (actionName == "PushingButton") {
                var button = (pOtherTing as Button);
                D.isNull(button, "button is null");
                button.Push (this);
                _dialogueRunner.EventHappened (this.name + "_pressed_" + pOtherTing.name);
            } else if (actionName == "UsingTv") {
                var tv = (pOtherTing as Tv);
                D.isNull(tv, "tv is null");
                tv.Flip ();
            } else if (actionName == "TurnLeft") {
                TurnDegrees (90);
            } else if (actionName == "TurnRight") {
                TurnDegrees (-90);
            } else if (actionName == "KickingLamp") {
                Lamp lamp = pOtherTing as Lamp;
                D.isNull(lamp, "lamp is null");
                lamp.Kick ();
            } else if (actionName == "Extracting") {
                Extractor extractor = handItem as Extractor;
                if (extractor == null) {
                    D.LogError (name + " is trying to use a hand item that is not an Extractor to extract things");
                } else {
                    extractor.Attach (pOtherTing);
                }
            } else if (actionName == "UsingComputer") {
                Computer computer = pOtherTing as Computer;
                D.isNull(computer, "computer is null");
                Floppy maybeFloppy = handItem as Floppy;
                computer.GetUsedBy (this, maybeFloppy);
                _dialogueRunner.EventHappened (name + "_start_Computer");
            } else if (actionName == "SlurpingIntoComputer") {
                StartAction ("InsideComputer", pOtherTing, LONG_TIME, LONG_TIME);
                _dialogueRunner.EventHappened (name + "_slurped_" + pOtherTing.name);
            } else if (actionName == "Inspect") {
                if (actionOtherObject is FuseBox) {
                    (actionOtherObject as FuseBox).BeInspected (this);
                    _dialogueRunner.EventHappened (name + "_inspect_Fusebox");
                } else if (actionOtherObject is Fountain) {
                    _dialogueRunner.EventHappened (name + "_inspect_Fountain");
                } else if (actionOtherObject is TrashCan) {
                    _dialogueRunner.EventHappened (name + "_inspect_TrashCan");
                }
            } else if (actionName == "ThrowingTingIntoTrashCan") {
                var trash = handItem;
                TrashCan trashCan = pOtherTing as TrashCan;
                D.isNull(trashCan, "trashCan is null");
                trashCan.Throw (trash);
            } else if (actionName == "PuttingTingIntoSendPipe") {
                var pipe = pOtherTing as SendPipe;
                D.isNull(pipe, "pipe is null");
                var stuff = handItem;
                handItem.isBeingHeld = false;
                SetNoHandItem ();
                pipe.PutStuffIntoIt (stuff);
            } else if (actionName == "PuttingTingIntoLocker") {
                Locker locker = pOtherTing as Locker;
                D.isNull(locker, "locker is null");
                handItem.isBeingHeld = false;
                bool success = locker.PutTingIntoRandomFreeSpot (handItem);
                if (success) {
                    SetNoHandItem ();
                }
            } else if (actionName == "GivingHandItem") {
                Character receiver = pOtherTing as Character;
                D.isNull (receiver, "The receiver is null");
                _dialogueRunner.EventHappened (name + "_give_"/* + handItem.prefab + "_to_" */ + receiver.name);
                if (onNewHandItem != null) {
                    onNewHandItem ("", true);
                }
                if (receiver.handItem != null) {
                    receiver.MoveHandItemToInventoryForcefully ();
                }
                receiver.SetHandItem (handItem);
                handItem = null;
            } else if (actionName == "BeingBothered") {
                timetableTimer = 0.5f;
            } else if (actionName == "Tasing") {
                var otherCharacter = (pOtherTing as Character);
                D.isNull(otherCharacter, "other character is null");
                otherCharacter.GetTased ();
                _dialogueRunner.EventHappened(name + "_tase_" + otherCharacter);
            } else if (actionName == "GettingTased") {
                ClearWalkingData(); // FIX?!
                FallAsleepFromStanding (2);
            } else if (actionName == "Angry") {
                timetableTimer = 0.5f;
            } else if (actionName == "UseSink") {
                var sink = (actionOtherObject as Sink);
                D.isNull(sink, "sink is null");
                sink.Toggle ();
                if (!sink.on) {
                    _dialogueRunner.EventHappened (name + "_turnOff_" + sink.name);
                }
            } else if (actionName == "RefillingDrink") {
                var drink = (handItem as Drink);
                D.isNull(drink, "drink is null");
                var sink = actionOtherObject as Sink;
                if (sink == null) {
                    D.Log ("Sink was null, can't refill");
                } else {
                    sink.UseDrinkOnSink (drink);
                }
            } else if (actionName == "Screwing") {
                var screwdriver = (handItem as Screwdriver);
                D.isNull(screwdriver, "screwdriver is null");
                var computer = actionOtherObject as Computer;
                if (computer == null) {
                    D.Log ("Computer was null, can't screw it");
                } else {
                    screwdriver.UseOnComputer (computer);
                }
            } else if (actionName == "Mixing") {
                var mixer = pOtherTing as MusicBox;
                D.isNull(mixer, "mixer is null");
                mixer.isPlaying = true;
            } else if (actionName == "UseStove") {
                var stove = pOtherTing as Stove;
                D.isNull(stove, "stove is null");
                stove.on = !stove.on;
            } else if (actionName == "TalkingInTelephone") {
                var phone = (pOtherTing as Telephone);
                D.isNull(phone, "phone is null");
                phone.Use ();
                _dialogueRunner.EventHappened (name + "_phone_" + pOtherTing.name);
            } else if (actionName == "ActivatingVendingMachine") {
                var vendingMachine = pOtherTing as VendingMachine;
                D.isNull(vendingMachine, "vendingMachine is null");
                vendingMachine.PushCokeDispenserButton (this);
            } else if (actionName == "Stealing") {
                var otherCharacter = actionOtherObject as Character;
                D.isNull(otherCharacter, "other character is null");
                var items = otherCharacter.inventoryItems;
                if (items.Length == 0) {
                    _worldSettings.Notify (name, "Nothing to steal");
                } else {
                    Ting stolenItem = Randomizer.RandNth (items);
                    MoveHandItemToInventory ();
                    SetHandItem (stolenItem as MimanTing);
                    _worldSettings.Notify (name, "You stole: " + stolenItem.tooltipName);
                }
            }
            else {
                //throw new Exception("Can't find trigger response to action '" + actionName + "'");
            }
        }
示例#23
0
文件: Ting.cs 项目: substans/TingTing
 internal void SetInitCreateValues(string pName, WorldCoordinate pPosition, Direction pDirection)
 {
     _startingName = pName;
     _startingPosition = pPosition;
     _startingDirection = pDirection;
 }
示例#24
0
 void OnPositionChanged(WorldCoordinate pPreviousPosition, WorldCoordinate pNewPosition)
 {
     UpdateHandItemPosition();
 }
示例#25
0
        public void API_Move()
        {
            if(dead) {
                return;
            }

            var newPos = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));
            var newTile = _roomRunner.GetRoom(room.name).GetTile(newPos.localPosition);
            if(newTile == null) {
                //D.Log(name + " can't move forward since there is no tile to move to");
            }
            else if(newTile.GetOccupants().Length > 0) {
                //D.Log(name + " can't move forward since there are occupants there: ");
                foreach(var occupant in newTile.GetOccupants()) {
                    //D.Log(occupant.name);
                    if(occupant is Pawn) {
                        var otherPawn = (occupant as Pawn);
                        if(otherPawn.team != this.team && !otherPawn.dead) {
                            otherPawn.GetHit();
                            PlaySound ("FishAttack");
                        }
                    }
                }
            }
            else {
                position = newPos;
            }

            moveNr++;
        }
示例#26
0
 public string API_Teleport(float x, float y)
 {
     if(IsAllowedToTeleport(_user as Character)) {
         WorldCoordinate coord = new WorldCoordinate(_user.room.name, (int)x, (int)y);
         PointTileNode tile = _user.room.GetTile(coord.localPosition);
         if(tile != null) {
             _user.position = coord;
             return "Success";
         }
         else {
             return "Can't move there";
         }
     }
     else {
         D.Log("Not allowed to teleport");
         return "Not allowed";
     }
 }