GameObject tetherRope; //Rope that you can attach to the drifter with #endregion Fields #region Methods public void attach(bool isTug = false) { if (this.attached || this.attachedToStation) return; this.attached = true; if (!isTug) { this.transform.position += player.transform.position - ropeEnd.transform.position; GameObject.Find("IndicatorArrow").GetComponent<IndicatorArrowScript>().setIndicatorTarget(IndicatorTarget.IndicatorSphere); GameObject.Find("StoryConditionManager").GetComponent<StoryConditionManager>().updateCondition(StoryConditionValues.isAttached, true); if (!GameObject.Find("StoryConditionManager").GetComponent<StoryConditionManager>().getConditionStatus(StoryConditionValues.DrifterDead)) { root = new StorySequence(); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_ThankGod", this.gameObject, 0, false, "Thank god, I wasn't sure you would make it.")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_WhatDoYouMean", this.gameObject, 0, false, "What do you mean? I mean.. I don't hate you that much..")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_HoldOffOnTheJokes", this.gameObject, 0, false, "this isn't over yet¦ maybe hold off on the jokes until we've landed.")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_FairEnough", this.gameObject, 0, false, "Fair enough.")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_NowLetsGet", this.gameObject, 0, false, "Now, let's get out of here.")); attachDialogueTreeStatus = StoryStatus.STATUS_Running; GameObject.Find("OxygenBars").GetComponent<OxygenBarScript>().stopDialogueTree(); } } CharacterJoint playerJoint = player.AddComponent<CharacterJoint>(); playerJoint.autoConfigureConnectedAnchor = false; playerJoint.connectedBody = ropeEnd.GetComponent<Rigidbody>(); playerJoint.anchor = Vector3.zero; playerJoint.connectedAnchor = Vector3.zero; Rigidbody playerBody = player.GetComponent<Rigidbody>(); playerBody.drag = 1.0f; playerBody.angularDrag = 1.0f; playerBody.mass = playerAttachMass; playerBody.maxDepenetrationVelocity = 1.0f; playerBody.useGravity = false; }
private StoryBehavior treeDFS(JSONObject json) { StoryBehavior root = null; string curType = ""; json.GetField(ref curType, "type"); //Debug.Log(curType); switch (curType) { case "SEQUENCE": bool isResponseConditionSeq = false; bool isSelectorElse = false; json.GetField(ref isResponseConditionSeq, "isResponseOptionSequence"); json.GetField(ref isSelectorElse, "isSelectorElse"); root = new StorySequence(isResponseConditionSeq, isSelectorElse); break; case "SELECTOR": root = new StorySelector(); break; case "SCENE": string sceneValue = ""; json.GetField(ref sceneValue, "sceneName"); Scenes curSceneName = (Scenes)Enum.Parse(typeof(Scenes), sceneValue); root = new StoryScene(curSceneName, this.gameObject); break; case "DIALOGUE": string audioFile = ""; string startDelayStr = ""; bool looping = false; string subtitles = ""; string character = ""; json.GetField(ref audioFile, "audioFile"); json.GetField(ref startDelayStr, "startDelay"); json.GetField(ref looping, "looping"); json.GetField(ref subtitles, "subtitles"); json.GetField(ref character, "character"); root = new StoryDialogue(audioFile, this.gameObject, float.Parse(startDelayStr), looping, subtitles, character); break; case "CONDITION": string conditionName = ""; json.GetField(ref conditionName, "condition"); bool isDialogueCondition = false; bool isAgitated = false; json.GetField(ref isDialogueCondition, "isDialogueCondition"); json.GetField(ref isAgitated, "isAgitated"); string defaultCondition = ""; if (isDialogueCondition) json.GetField(ref defaultCondition, "defaultCondition"); root = new StoryCondition(conditionName, isDialogueCondition, isAgitated, defaultCondition); break; case "OPTIONS": JSONObject options = json.GetField("options"); string[] resp = new string[options.list.Count]; int i = 0; foreach(JSONObject opt in options.list) { resp[i++] = opt.str; } JSONObject successConds = json.GetField("successConditions"); string[] successConditions = new string[options.list.Count]; i = 0; foreach (JSONObject condValue in successConds.list) { successConditions[i++] = condValue.str; } root = new StoryDialogueOptions(resp, successConditions, this.gameObject); break; } //Debug.Log(root); JSONObject children = json.GetField("children"); if(children != null) { foreach (JSONObject child in children.list) { root.addChild(treeDFS(child)); } } return root; }
void setLowOxygenAlarm() { GameObject.Find("SoundManager").GetComponent<SoundManager>().playOxygenWarningSound(Camera.main.transform.position); playerOxygenBar.GetComponentInChildren<Text>().color = Color.red; foreach (CanvasRenderer canvasRender in oxygenDepletionDisplay.GetComponentsInChildren<CanvasRenderer>()) { canvasRender.SetAlpha(1.0f); //The instruction for attaching will be visible } GameObject.Find("StoryConditionManager").GetComponent<StoryConditionManager>().updateCondition(StoryConditionValues.lowRescueTime, true); if (!GameObject.Find("StoryConditionManager").GetComponent<StoryConditionManager>().getConditionStatus(StoryConditionValues.DrifterDead)) { root = new StorySequence(); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_WereRunningOut", this.gameObject, 0, false, "Now, let's get out of here.")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_NotHelping", this.gameObject, 0, false, "You're not helping.")); root.addChild(new StoryDialogue("Audio/Dialogue/Scene02_FastAsICan", this.gameObject, 0, false, "I'm going as fast as I can.")); lowOxygenStatus = StoryStatus.STATUS_Running; GameObject.Find("Drifter").GetComponent<DrifterScript>().stopAttachedDialogueTree(); } }