public void Setup() { D.onDLog += Console.WriteLine; SmartWalkBehaviour.s_logger.AddListener (s => Console.WriteLine ("Walk behaviour: " + s)); WorldTestHelper.GenerateInitData(); InitialSaveFileCreator i = new InitialSaveFileCreator(); _world = new World(i.CreateRelay("../InitData1/")); foreach (string s in _world.Preload()) ; _d1 = _world.tingRunner.CreateTing<Door>("DoorOne", new TingTing.WorldCoordinate("Eden", new IntPoint(4, 4)), Direction.LEFT); _d2 = _world.tingRunner.CreateTing<Door>("DoorTwo", new TingTing.WorldCoordinate("Hallway", new IntPoint(0, 0)), Direction.RIGHT); _d1.targetDoorName = _d2.name; _d2.targetDoorName = _d1.name; _d3 = _world.tingRunner.CreateTing<Door>("DoorThree", new TingTing.WorldCoordinate("Hallway", new IntPoint(4, 2)), Direction.LEFT); _d4 = _world.tingRunner.CreateTing<Door>("DoorFour", new TingTing.WorldCoordinate("Kitchen", new IntPoint(0, 2)), Direction.RIGHT); _d3.targetDoorName = _d4.name; _d4.targetDoorName = _d3.name; _world.roomRunner.GetRoom("Hallway").worldPosition = new IntPoint(4, 4); _adam = _world.tingRunner.GetTing<Character>("Adam"); _eve = _world.tingRunner.GetTing<Character>("Eva"); }
public void UseKeyToGetThroughDoor(Door pDoor) { Key key = null; List<Key> keys = new List<Key>(); foreach(var item in _character.inventoryItems) { if(item is Key) { keys.Add(item as Key); } } if (_character.handItem is Key) { keys.Add (_character.handItem as Key); } if (keys.Count > 0) { int r = Randomizer.GetIntValue(0, keys.Count); key = keys[r]; } if(key == null) { //#if LOG D.Log("No key found for character " + _character.name + " at door " + pDoor); //#endif _character.CancelWalking(); return; } if(_character.handItem != key) { _character.MoveHandItemToInventory(); _character.handItem = key; } _character.UseHandItemToInteractWith(pDoor); pDoor.autoLockTimer = 4f; }
/// <summary> /// If the other ting is pickupable, the character will just pick it up and not do anything with it. /// If the other ting is not pickupable, the character will interact directly with it using the InteractWith() function. /// </summary> public void WalkToTingAndInteract(Ting pOtherTing) { rememberToHackComputerAfterSittingDown = false; if(isAvatar && pOtherTing is Door) { Door door = pOtherTing as Door; if(door.isBusy) { _worldSettings.Notify(name, "Door in use, will wait in line"); rememberToUseDoorAfterWaitingPolitely = door; WalkTo (new WorldCoordinate(room.name, door.waitingPoint)); return; } } if (pOtherTing.HasInteractionPointHere (this.position)) { if (pOtherTing.canBePickedUp) { logger.Log (name + " will pick up " + pOtherTing + " directly, no need to move"); PickUp (pOtherTing); } else { logger.Log (name + " will interact directly with " + pOtherTing + ", no need to move"); InteractWith (pOtherTing); } return; } if(pOtherTing is Character && MimanGrimmApiDefinitions.AreTingsWithinDistance(this, pOtherTing, 10)) { Character otherCharacter = pOtherTing as Character; if(this.sitting || this.laying || otherCharacter.HasNoFreeInteractionPoints()) { #if LOG logger.Log(name + " is using direct interaction with " + otherCharacter); #endif InteractWith(pOtherTing); return; } } PrepareForNewWalkBehaviour(pOtherTing.position, pOtherTing, WalkMode.WALK_TO_TING_AND_INTERACT); }
public override void Update(float dt) { if(_timetable != null) { _timetable.Update(dt, gameClock, this, _tingRunner as MimanTingRunner, _roomRunner, _dialogueRunner, _worldSettings); } // CHECK FOR WALK MODE USED TO BE AT THIS LOCATION IN THE CODE, I MOVED IT INTO THE ELSE BRANCH OF THE SLEEP CHECK BELOW // this is for not holding on to things that are put into trash cans that have no code in them if (handItem != null && !handItem.isBeingHeld) { handItem = null; } if(rememberToUseDoorAfterWaitingPolitely != null) { if(rememberToUseDoorAfterWaitingPolitely.isBusy) { //D.Log(rememberToUseDoorAfterWaitingPolitely + " is busy"); } else if(actionName != "") { //D.Log("Waiting politely with action: " + actionName); } else { D.Log("Door is free now!"); float t = 0.1f; StartAction("UseDoorReallySoon", rememberToUseDoorAfterWaitingPolitely, t, t); rememberToUseDoorAfterWaitingPolitely = null; } } if(actionName == "Sleeping") { sleepiness -= _worldSettings.gameTimeSpeed * dt * 0.03f; // TODO: this was 0.02 until Sep 11 2015 if(sleepiness < 0f) { sleepiness = 0f; } corruption -= _worldSettings.gameTimeSpeed * dt * 0.01f; if (corruption < 0f) { corruption = 0f; } drunkenness -= _worldSettings.gameTimeSpeed * dt * 0.02f; if(drunkenness < 0f) { drunkenness = 0f; } if(room.exterior) { smelliness += dt * 0.5f; if(smelliness > 100f) { smelliness = 100f; } } if(gameClock > alarmTime) { //D.Log(name + ", gameClock > alarmTime, " + gameClock + " > " + alarmTime); StopAction(); dialogueLine = ""; if (bed == null) { laying = false; } #if LOG logger.Log(name + " woke up"); #endif } } else { if(walkMode != WalkMode.NO_TARGET && !IsGettingUp()) { EnsureWalkBehaviour(); _walkBehaviour.Update(dt); } if(conversationTarget == null && !neverGetsTired && !talking && !laying && !sitting) { sleepiness += _worldSettings.gameTimeSpeed * dt * 0.0015f; if (sleepiness > 99.0f && IsIdle ()) { if (sitting) { #if LOG logger.Log (name + " falling asleep in a seat from exhaustion"); #endif StartAction("FallingAsleepInChair", seat, 2.0f, 2.0f); } else { #if LOG logger.Log (name + " falling asleep on the street from exhaustion"); #endif FallAsleepFromStanding (8); } } } else { // D.Log(name + " is not gettings sleepy... conversationTarget " + conversationTarget + " talking " + talking + " sitting " + sitting + " laying " + laying); } // Get clean in the rain if(room.exterior && _worldSettings.rain > 10f) { smelliness -= dt * 4.0f; if(smelliness < 0f) { smelliness = 0f; } } } if(isAvatar && (actionName == "InsideComputer" || room.name == "Internet")) { corruption += dt * 0.001f; } if(corruption > 100) { corruption = 100; } else if(corruption < 0) { corruption = 0; } }
bool IsTargetDoorInABusyElevator(Door pTargetDoor) { return pTargetDoor != null && pTargetDoor.elevatorAlternatives.Length > 0 && pTargetDoor.room.GetTingsOfType<Character>().Count > 0; }