IEnumerator KillPlayer() { TraceLogger.LogKVtime("monster", "killed"); alphaFadeValue = 1; GameObject.Find("Voice").audio.PlayOneShot(Resources.Load("Dying") as AudioClip); yield return(new WaitForSeconds(2)); GameObject start = GameObject.FindGameObjectWithTag("Respawn"); GameObject player = GameObject.FindGameObjectWithTag("Player"); player.transform.position = start.transform.position; //reset everything; alive = true; attacking = false; alphaFadeValue = 0; transform.position = starting_location; transform.rotation = starting_rotation; child.animation.Stop(); }
public void castSpell(GameObject target) { if (target.GetComponent("Enchantable") == null) { TraceLogger.LogKVtime("attempt", getSpellName()); TraceLogger.LogKV("target", target.GetInstanceID().ToString() + ", " + target.name + ", " + target.transform.position); TraceLogger.LogKV("player", "" + ObjectManager.FindById("Me").transform.position); (GameObject.Find("Popup").GetComponent("Popup") as Popup).popup("Target (" + target.name + ") immune to magic."); SetHidden(false); return; } TraceLogger.LogKVtime("spell", getSpellName()); ProgramLogger.LogKVtime("spell", getSpellName()); TraceLogger.LogKV("target", target.GetInstanceID().ToString() + ", " + target.name + ", " + target.transform.position); TraceLogger.LogKV("player", "" + ObjectManager.FindById("Me").transform.position); June june = new June(target, file_name); SetHidden(false); item_name = "Blank"; file_name = ""; animate = false; inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D; (target.GetComponent("Enchantable") as Enchantable).enchant(june, delegate(GameObject t){ absorbSpell(t); }); }
void OnGUI() { string redButtonText = "Help"; Badgebook badgebook = GameObject.Find("Badgebook").GetComponent <Badgebook>(); // If quest check has been requested, display an orange border if (badgebook.showOrangeBorder) { int thick = 10; GUI.DrawTexture(new Rect(0, 0, Screen.width, thick), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, 0, thick, Screen.height), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - thick, 0, thick, Screen.height), orangeBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, Screen.height - thick, Screen.width, thick), orangeBorder, ScaleMode.StretchToFill, false); if (showYellowBorder) { redButtonText = "Ok"; GUI.DrawTexture(new Rect(thick, thick, Screen.width - 2 * thick, thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(thick, thick, thick, Screen.height - 2 * thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - 2 * thick, thick, thick, Screen.height - 2 * thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(thick, Screen.height - 2 * thick, Screen.width - 2 * thick, thick), yellowBorder, ScaleMode.StretchToFill, false); } } // If help has been requested, display a yellow border else if (showYellowBorder) { redButtonText = "Ok"; int thick = 10; GUI.DrawTexture(new Rect(0, 0, Screen.width, thick), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, 0, thick, Screen.height), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(Screen.width - thick, 0, thick, Screen.height), yellowBorder, ScaleMode.StretchToFill, false); GUI.DrawTexture(new Rect(0, Screen.height - thick, Screen.width, thick), yellowBorder, ScaleMode.StretchToFill, false); } bool oldhint = hintstart; // Toggle control for marking start/end of giving a hint hintstart = GUI.Toggle(new Rect(Screen.width - 30, Screen.height - 30, 30, 30), hintstart, "H"); if (oldhint != hintstart) { showYellowBorder = false; TraceLogger.LogKVtime("hint", "" + hintstart); ProgramLogger.LogKVtime("hint", "" + hintstart); } // Display a button that requests help or cancels a call for help if (GUI.Button(new Rect(0, Screen.height - 64, 64, 64), redButtonText + "!", helpButtonStyle)) { TraceLogger.LogKVtime("hint", redButtonText); ProgramLogger.LogKVtime("hint", redButtonText); showYellowBorder = !showYellowBorder; } if (Input.GetKey(KeyCode.B)) { Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>(); spellbook.show(GameObject.Find("Inventory")); } }
public void removeItem(GameObject item) { to_remove.Add(item); TraceLogger.LogKVtime("droppedoff", item.GetInstanceID() + ", " + item.name + ", " + item.transform.position + ", " + ObjectManager.FindById("Me").transform.position); if (DroppedOff != null) { DroppedOff(item); } }
public void addItem(GameObject item) { items.Add(item); item_infos.Add(item, new ItemInfo()); TraceLogger.LogKVtime("pickedup", item.GetInstanceID() + ", " + item.name + ", " + item.transform.position + ", " + ObjectManager.FindById("Me").transform.position); if (PickedUp != null) { PickedUp(item); } }
public void LoosePlayer() { TraceLogger.LogKVtime("monster", "lost"); audio.Stop(); AttackEnded(gameObject); GameObject.Find("Main Camera").GetComponent <ShakeCamera>().endShakeMode(); //reset everything; alive = true; attacking = false; alphaFadeValue = 0; transform.position = starting_location; transform.rotation = starting_rotation; child.animation.Stop(); }
void OnGUI() { if (enabled) { displayPages(); if (GUI.Button(new Rect(Screen.width - 200, 30, 130, 65), "Back", button_style)) { enabled = false; previous_state.active = true; } if (GUI.Button(new Rect(Screen.width - 135, 110, 65, 65), "", unlock_button_style)) { showOrangeBorder = !showOrangeBorder; TraceLogger.LogKVtime("unlockbutton", "" + showOrangeBorder); } GUIStyle prev_button_style = new GUIStyle(); prev_button_style.normal.background = prev_button_texture; if (current_page != 0 && GUI.Button(new Rect(Screen.width * 0.025f, Screen.height * 0.5f, 35, 35), "", prev_button_style)) { current_page--; //PageTurnedBackward(currentPage()); //logCurrentPage(); } GUIStyle next_button_style = new GUIStyle(); next_button_style.normal.background = next_button_texture; if (current_page != getNumberOfPages() - 1 && GUI.Button(new Rect(Screen.width * 0.95f, Screen.height * 0.5f, 35, 35), "", next_button_style)) { current_page++; //PageTurnedForward(currentPage()); //logCurrentPage(); } // make it so that we can't click through to the game // NOTE: This must appear LAST in the OnGUI. Otherwise, other buttons won't work! GUI.Button(new Rect(0, 0, Screen.width, Screen.height), "", empty_style); } }
public void Attack() { Debug.Log("ATTACK!"); if (!attacking) { TraceLogger.LogKVtime("monster", "attack"); audio.clip = Resources.Load("MonsterRunning") as AudioClip; Debug.Log("About to start the audio clip"); audio.Play(); audio.loop = true; Debug.Log("About to start attacking!"); AttackStarted(gameObject); Debug.Log("About to start shaking the camera"); GameObject.Find("Main Camera").GetComponent <ShakeCamera>().startShakeMode(); } Debug.Log("About to start running"); StartRunning(); attacking = true; }
public bool Complete(string name) { if (!Contains("complete_" + name)) { if (badgeStore.label(name).Trim() == "") { Replace(name, "complete_" + name, badgeStore.label(name), badgeStore.path(name).Replace("incomplete", "complete"), true); } else { Replace(name, "complete_" + name, badgeStore.label(name) + " (COMPLETED)", badgeStore.path(name).Replace("incomplete", "complete"), true); } TraceLogger.LogKVtime("completed", name); BadgeLogger.Log(name); return(true); } else { return(false); } }
IEnumerator turnToFaceAndTalk() { //Does an sudden, jumpy turn which actually looks okayish. But this method is called as a // coroutine in order to facilitate a smoother turn if we want to implement that. transform.LookAt(GameObject.FindGameObjectWithTag("Player").transform); yield return(new WaitForSeconds(0.2f)); ConversationDisplayer c = GameObject.Find("ConversationDisplayer").GetComponent(typeof(ConversationDisplayer)) as ConversationDisplayer; Time.timeScale = 0; if (currentQuest < questList.Length && questList[currentQuest].checkIfCompleted()) { currentQuest++; } TraceLogger.LogKVtime("conversation", name + ", " + transform.position); c.Converse(((Conversation)conversationList[currentQuest])); c.show(GameObject.Find("Inventory")); }
private void tryUnlock() { int boxWidth = 300; int boxHeight = 115; GUIStyle style = GUI.skin.box; style.alignment = TextAnchor.UpperCenter; GUI.Box(new Rect(Screen.width / 2 - boxWidth / 2, Screen.height / 2 - boxHeight / 2, boxWidth, boxHeight), "Do you want to unlock\n" + unlockName + "?", style); pword = GUI.PasswordField(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 15, 200, 20), pword, "*"[0]); if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 15, 50, 30), "Yes")) { if (pword == "LaJo11a") { Complete(unlockName); } else { TraceLogger.LogKVtime("unlockbutton", "Yes"); } unlockPopup = false; unlockName = ""; showOrangeBorder = false; pword = ""; } if (GUI.Button(new Rect(Screen.width / 2 + 30, Screen.height / 2 + 15, 50, 30), "No")) { unlockPopup = false; unlockName = ""; showOrangeBorder = false; pword = ""; TraceLogger.LogKVtime("unlockbutton", "No"); } }