void MovePetroglyph() { if (holdingPetroglyph == null) { return; } var activeCamera = Camera.main; DebugUtilities.Assert(activeCamera.enabled, "Camera is not enabled!"); var targetPosition = new Vector3(); var targetRotation = new Quaternion(); bool movedWithMouse = GetMouseTargetTransform(out targetPosition, out targetRotation); if (movedWithMouse) { var warpPosition = holdingPetroglyph.transform.position; warpPosition.z = targetPosition.z; warpPosition.x = targetPosition.x; holdingPetroglyph.transform.position = warpPosition + pickingOffset; } { var horizontal = Input.GetAxis("Horizontal"); var vertical = Input.GetAxis("Vertical"); targetPosition.x = horizontal * Time.deltaTime; targetPosition.y = vertical * Time.deltaTime; targetPosition.z = 0; pickingOffset += activeCamera.transform.TransformDirection(targetPosition); pickingOffset.y = 0; } }
public void SkipToComponent(string skipToComponentName) { if (skipToComponentName == string.Empty) { Debug.Log("We skip to the first component"); lineIndex = 0; return; } DebugUtilities.Assert(!isActingScene, "We can not skip while acting a scene!"); DebugUtilities.Assert(activeLine == null, "We can not skip while we are acting a line in a scene!"); var currentLine = lines[lineIndex]; Debug.Log("Line: " + currentLine.name + " _________________________________________"); while (skipToComponentName != currentLine.name) { Debug.Log("*** We skip line:" + currentLine.name + ". Looking for: " + skipToComponentName); lineIndex++; DebugUtilities.Assert(lineIndex < lines.Length, "Illegal index! Couldn't find component:" + skipToComponentName); currentLine = lines[lineIndex]; } // PlayNextLine(); }
void SetupIngameCamera() { var defaultCameraToSpawnObject = Instantiate(ingameCameraToSpawn) as GameObject; cameraApplicator = defaultCameraToSpawnObject.GetComponent <LogicCameraInfoApplicator>(); DebugUtilities.Assert(cameraApplicator != null, "Must have PlayerCamera component on this camera"); }
void TriggerOnBlacksmithSwordCold() { BroadcastMessage("OnBlacksmithSwordCold"); DebugUtilities.Assert(avatar != null, "Please set collision masks. Nothing other than CharacterAvatars should trigger this"); DebugUtilities.Assert(annealInteractable != null, "You must set up interactable for InteractOnTrigger:" + name); avatar.PerformPrimaryAction(annealInteractable.gameObject); }
void SetQuestItemEnabled(string itemName, bool enabled) { Debug.Log("Setting quest item: " + itemName + " to:" + enabled); if (enabled) { for (var i = 0; i < inventoryItemsRoot.transform.childCount; ++i) { if (SetQuestItemEnabled(i, itemName, true)) { return; } } } else { for (var i = inventoryItemsRoot.transform.childCount - 1; i >= 0; --i) { if (SetQuestItemEnabled(i, itemName, false)) { return; } } } DebugUtilities.Assert(false, "Couldn't find inventory item to toggle:" + itemName); }
protected void PerformAction(IAvatar avatar) { DebugUtilities.Assert(actorScenePrefab != null, "You must have a valid actorScene for the action"); var instantiatedScene = ActorSceneUtility.CreateSceneWithAvatarAndInteractable(actorScenePrefab.gameObject, avatar, gameObject); instantiatedScene.PlayScene(avatar.playerNotifications); }
void SpawnSword() { Debug.Log("Spawning sword!"); DebugUtilities.Assert(sword == null, "You already have a sword, can not spawn a new one"); sword = SpawnTool(swordPrefab.gameObject, swordTransformInHand).GetComponentInChildren <BlacksmithSword>(); SetSwordHandPosition(swordHandPosition); }
void SpawnSledge() { Debug.Log("Spawning sledgehammer!"); DebugUtilities.Assert(sledge == null, "You already have a sword, can not spawn a new one"); sledge = SpawnTool(sledgePrefab.gameObject, sledgeTransformInHand).GetComponentInChildren <BlacksmithSledgehammer>(); sledge.smither = this; }
public void DetachListener(ListenerStackItem item) { DebugUtilities.Assert(item != null, "Illegal handle: null"); Debug.Log("** Removing listener from" + item.name); listenerStack.Remove(item); AttachListenerToHighestPriority(); }
void Start() { foreach (var item in itemsToPickup) { DebugUtilities.Assert(item != null, "We have null items in quest part:" + name); } }
public void Remove(int x, int y, Block block) { DebugUtilities.Assert(grid[x, y].Element == block); grid[x, y].Element = null; grid[x, y].Type = GridElement.ElementType.Empty; grid[x, y].State = GridElement.ElementState.Empty; }
void KickoutListenerFromCameraAnimation() { Debug.Log("Removing listener from scene component: " + name); DebugUtilities.Assert(actingInScene != null, "Must have a acting scene"); DebugUtilities.Assert(actingInScene.GetPlayerNotifications() != null, "Must have a player notifications"); actingInScene.GetPlayerNotifications().DetachListener(listenerHandle); listenerHandle = null; }
float DistanceToObject(Interactable interactable) { DebugUtilities.Assert(interactable != null, "Must have a valid interactable"); DebugUtilities.Assert(objectToFollow != null, "Must have a valid object to follow"); var distance = (interactable.transform.position - objectToFollow.transform.position).magnitude; return(distance); }
void FreeId(int id) { DebugUtilities.Assert(StoreMap[id]); StoreMap[id] = false; Destroy(BlockStore[id].gameObject); BlockCount--; }
public void SetStartedQuestPart(string questName, string questPartName) { DebugUtilities.Assert(questName != "", "QUEST NAME CAN NOT BE EMPTY"); var questInfo = FindStartedQuest(questName); DebugUtilities.Assert(questInfo != null, "Couldn't find quest:" + questName); questInfo.questPart = questPartName; Save(); }
public override void Skip() { DebugUtilities.Assert(instantiatedCutscene != null, "Instantiated Cutscene is null. Can not skip!"); Debug.Log("STOP ACTING************************************** ######################" + scene.name); // var avatar = actingInScene.GetMainAvatar(); instantiatedCutscene.QuitScene(); Debug.Log("Destroying object:" + instantiatedCutscene.gameObject.name); instantiatedCutscene = null; }
void Close() { DebugUtilities.Assert(avatarQuest != null, "Avatar quest is null, did you close it before Act?"); DebugUtilities.Assert(goalObject != null, "Goal object is null, did it unspawn during interact?"); Debug.Log("Closing Interact with:" + interactableName); avatarQuest.RemoveGoalObject(goalObject.gameObject); goalObject = null; ComponentDone(); }
void PauseGame() { ShowMenu(true); Time.timeScale = 0.0f; DebugUtilities.Assert(allowedToInteract == null, "Was already restricting interaction"); allowedToInteract = new AllowedToInteractModifier(); player.AssignedAvatar().AddAllowedToInteractModifier(allowedToInteract); player.playerInteraction.OnAllowedToUseUI(true); }
bool ParseCommandIfFound(string title, out string nextText) { var escapeIndex = title.IndexOf('%'); nextText = title; if (escapeIndex != -1) { var endEscapeIndex = title.IndexOf(' ', escapeIndex + 1); DebugUtilities.Assert(endEscapeIndex != -1, "Illegal formatting:" + title); var escapeCode = title.Substring(escapeIndex + 1, endEscapeIndex - escapeIndex); var textBefore = title.Substring(0, escapeIndex).TrimEnd(); var textAfter = title.Substring(endEscapeIndex + 1); var parameters = escapeCode.Substring(1); nextText = textBefore; switch (escapeCode[0]) { case 'w': { var waitTime = float.Parse(parameters); nextTitle = textAfter; nextTitleTime = Time.time + waitTime; nextCommand = Command.WaitTime; Debug.Log("Waiting time:" + waitTime + " remaining:" + nextTitle + " showing:" + textBefore); nextText = textAfter; break; } case 't': { // Couldn't get TimeSpan.ParseExact to work, so added custom parsing. var separator = parameters.IndexOf(':'); if (separator == -1) { Debug.LogError($"wrong time format '{parameters}'"); } var minutesString = parameters.Substring(0, separator); var secondsString = parameters.Substring(separator + 1); var minutes = int.Parse(minutesString); var seconds = int.Parse(secondsString); nextTitleTime = minutes * 60 + seconds; nextTitle = textAfter; nextCommand = Command.VideoTime; break; } } } return(escapeIndex != -1); }
public void Ignited() { BroadcastMessage("OnFirePitIgnited"); DebugUtilities.Assert(health == 0, "You can only ignite when the fire is dead"); int oldHealth = health; health = 20; CheckHealth(oldHealth); isIgniting = false; }
public void AddBlock(int x, int y, Block block, GridElement.ElementState state) { DebugUtilities.Assert(x < PlayWidth); DebugUtilities.Assert(y < PlayHeight); DebugUtilities.Assert(grid[x, y].State == GridElement.ElementState.Empty); grid[x, y].Element = block; grid[x, y].Type = GridElement.ElementType.Block; grid[x, y].State = state; }
protected override void Act() { Debug.Log("Starting Arrive At Destination: " + areaName); goalObject = GameObject.Find(areaName); DebugUtilities.Assert(goalObject != null, "Couldn't find object:" + areaName); var avatar = actingInScene.GetActor("Tyra"); avatarQuest = avatar.GetComponentInChildren <AvatarQuest>(); avatarQuest.AddGoalObject(goalObject); }
public void SetLogicCamera(LogicCamera logicCameraToFollow) { DebugUtilities.Assert(logicCameraToFollow != null, "Camera can not be null!"); if (logicCamera) { // cameraInfo.pivotRotation = logicCamera.transform.rotation; } logicCamera = logicCameraToFollow; // logicCamera.OnCameraSwitch(cameraInfo); cameraInfo.cameraSwitched = true; }
private void beginMouseOperation() { DebugUtilities.Assert(_gotMouseDown == false, "beginMouseOperation called when already in mouse operation"); _gotMouseDown = true; // Use the handler specified on Model, if not null. Otherwise, use ourself. _currentMouseHandler = _CanvasViewModel.CanvasViewMouseHandler != null ? _CanvasViewModel.CanvasViewMouseHandler : this; // Don't create undo states at every drag update. _CanvasViewModel._DocumentViewModel.dm_DocumentDataModel.BeginOperation("CanvasView mouse operation"); }
void SetupMoveAndInteraction() { if (activeLine != null) { DebugUtilities.Assert(activeLine != null, "Active Line is null after act"); bool canMove = activeLine.AvatarAllowedToMove(); bool canInteract = activeLine.AvatarAllowedToInteract(); SetInteractionForMainCharacter(canInteract); SetMovementForMainCharacter(canMove); } }
void OnTriggerEnter(Collider collider) { if (canInteract) { Debug.Log("Collision:" + name); var avatar = collider.GetComponentInChildren <CharacterAvatar>(); DebugUtilities.Assert(avatar != null, "Please set collision masks. Nothing other than CharacterAvatars should trigger this"); DebugUtilities.Assert(interactable != null, "You must set up interactable for InteractOnTrigger:" + name); avatar.PerformPrimaryAction(interactable.gameObject); } }
void AllocateId(int id) { DebugUtilities.Assert(!StoreMap[id]); StoreMap[id] = true; BlockStore[id] = Instantiate(BlockPrefab, Vector3.zero, Quaternion.identity) as Block; BlockStore[id].Id = id; BlockStore[id].transform.parent = transform; BlockCount++; }
protected override void Act() { Debug.Log("Interactable: " + interactableName); goalObject = Interactable.GetInteractableFromName(interactableName); DebugUtilities.Assert(goalObject != null, "Couldn't find interactable component on:" + interactableName); var avatar = actingInScene.GetActor("Tyra"); avatarQuest = avatar.GetComponentInChildren <AvatarQuest>(); avatarQuest.AddGoalObject(goalObject.gameObject); }
void StopFanningMode() { Debug.Log("Fanning: Stop"); DebugUtilities.Assert(isInFanMode, "You can not reset if you aren't fanning"); if (barAnim != null) { Destroy(barAnim.gameObject); barAnim = null; } isInFanMode = false; }
void Initiate() { var mainActorObject = GameObject.FindGameObjectWithTag("Player"); DebugUtilities.Assert(mainActorObject != null, "Couldn't fint IAvatar from tag Player"); var avatar = mainActorObject.GetComponentInChildren <IAvatar>(); DebugUtilities.Assert(avatar != null, "Found an object with tag Player but didn't have an actor."); var actorScene = ActorSceneUtility.CreateSceneWithAvatar(actorScenePrefab, avatar); actorScene.PlayScene(avatar.playerNotifications); }