public void OnCollisionEnter2D(Collision2D collision) { MessageBar.Show($"You collected: {name} x {count}"); model.AddInventoryItem(this); UserInterfaceAudio.OnCollect(); gameObject.SetActive(false); }
void Update() { if (isInRange) { if (manage_it.firstTime) { displaymessage = true; StartCoroutine(WaitAndMakeTextDisappear(hideTextDuration)); } if (Input.GetKeyDown(interactKey)) { MessageBar.Show($"You collected: {name} x {count}"); if (this.CompareTag("pedra")) { pedra = true; Debug.Log("Dins de update" + pedra); //OnGUI(); StartCoroutine(WaitAndMakeTextDisappear(hideTextDuration)); } model.AddInventoryItem(this); UserInterfaceAudio.OnCollect(); gameObject.SetActive(false); Debug.Log("Key pressed"); } } }
public void OnTriggerEnter2D(Collider2D collider) { if (!Application.isPlaying) { return; } foreach (var requiredInventoryItem in requiredInventoryItems) { if (requiredInventoryItem != null) { if (!model.HasInventoryItem(requiredInventoryItem.name)) { if (nullinventorymessage) { MessageBar.Show(noinventory); nullinventorymessage = false; } return; } } } foreach (var requiredStoryItem in requiredStoryItems) { if (requiredStoryItem != null) { if (!model.HasSeenStoryItem(requiredStoryItem.ID)) { return; } } } if (text != string.Empty) { MessageBar.Show(text); } if (ID != string.Empty) { model.RegisterStoryItem(ID); } if (audioClip == null) { UserInterfaceAudio.OnStoryItem(); } else { UserInterfaceAudio.PlayClip(audioClip); } if (disableWhenDiscovered) { gameObject.SetActive(false); } if (cutscenePrefab != null) { var cs = Instantiate(cutscenePrefab); if (cs.audioClip != null) { cs.OnFinish += (i) => model.musicController.CrossFade(model.musicController.audioClip); } } }
public void OnTriggerEnter2D(Collider2D collider) { MessageBar.Show($"Вы получили: {name} x {count}"); model.AddInventoryItem(this); UserInterfaceAudio.OnCollect(); gameObject.SetActive(false); }
public void OnTriggerEnter2D(Collider2D collider) { //MessageBar.Show($"You collected: {name} x {count}"); model.AddInventoryItem(this); UserInterfaceAudio.OnCollect(); gameObject.SetActive(false); //Destroy(gameObject); }
public void OnTriggerEnter2D(Collider2D collider) { MessageBar.Show($"You collected: {name} x {count}"); model.AddInventoryItem(this); UserInterfaceAudio.OnCollect(); gameObject.SetActive(false); tmp.glory += 1; tmp.blood += 100; tmp.strength += 1; }
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { var t = stateInfo.normalizedTime % 1; if (lastNormalizedTime < leftFoot && t >= leftFoot) { UserInterfaceAudio.PlayClip(clips[clipIndex]); clipIndex = (clipIndex + 1) % clips.Length; } if (lastNormalizedTime < rightFoot && t >= rightFoot) { UserInterfaceAudio.PlayClip(clips[clipIndex]); clipIndex = (clipIndex + 1) % clips.Length; } lastNormalizedTime = t; }
public void RewardItemsToPlayer() { foreach (var i in rewardItems) { MessageBar.Show($"You collected: {i.name} x {i.count}"); model.AddInventoryItem(i); UserInterfaceAudio.OnCollect(); i.gameObject.SetActive(false); } if (outroCutscenePrefab != null) { var cs = Instantiate(outroCutscenePrefab); if (cs.audioClip != null) { cs.OnFinish += (i) => model.musicController.CrossFade(model.musicController.audioClip); } } }
public override void Execute() { ConversationPiece ci; //default to first conversation item if no key is specified, else find the right conversation item. if (string.IsNullOrEmpty(conversationItemKey)) { ci = conversation.items[0]; // GameObject.Find("Player").GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.None | RigidbodyConstraints2D.FreezeRotation; } else { ci = conversation.Get(conversationItemKey); } //if this item contains an unstarted quest, schedule a start quest event for the quest. if (ci.quest != null) { if (!ci.quest.isStarted) { var ev = Schedule.Add <StartQuest>(1); ev.quest = ci.quest; ev.npc = npc; } if (ci.quest.isFinished && ci.quest.questCompletedConversation != null) { ci = ci.quest.questCompletedConversation.items[0]; } } //calculate a position above the player's sprite. var position = gameObject.transform.position; var sr = gameObject.GetComponent <SpriteRenderer>(); if (sr != null) { position += new Vector3(0, (1 * sr.size.y + (ci.options.Count == 0 ? 0.1f : 0.2f)) / 2, 0); } //show the dialog model.dialog.Show(position, ci.text); GameObject.Find("Player").GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll; var animator = gameObject.GetComponent <Animator>(); if (animator != null) { //animator.SetBool("Talk", true); //rigidbody.constraints = (RigidbodyConstraints2D)RigidbodyConstraints.FreezePosition; var ev = Schedule.Add <StopTalking>(2); ev.animator = animator; } if (ci.audio != null) { UserInterfaceAudio.PlayClip(ci.audio); } //speak some gibberish at two speech syllables per word. UserInterfaceAudio.Speak(gameObject.GetInstanceID(), ci.text.Split(' ').Length * 2, 1); //if this conversation item has an id, register it in the model. if (!string.IsNullOrEmpty(ci.id)) { model.RegisterConversation(gameObject, ci.id); } //setup conversation choices, if any. if (ci.options.Count == 0) { //do nothing } else { //Create option buttons below the dialog. for (var i = 0; i < ci.options.Count; i++) { model.dialog.SetButton(i, ci.options[i].text); } //if user pickes this option, schedule an event to show the new option. model.dialog.onButton += (index) => { //hide the old text, so we can display the new. model.dialog.Hide(); //This is the id of the next conversation piece. var next = ci.options[index].targetId; //Make sure it actually exists! if (conversation.ContainsKey(next)) { //find the conversation piece object and setup a new event with correct parameters. var c = conversation.Get(next); var ev = Schedule.Add <ShowConversation>(0.25f); ev.conversation = conversation; ev.gameObject = gameObject; ev.conversationItemKey = next; } else { Debug.LogError($"No conversation with ID:{next}"); } }; } //if conversation has an icon associated, this will display it. model.dialog.SetIcon(ci.image); }
IEnumerator _Play() { if (audioClip != null) { model.musicController.CrossFade(audioClip); } material.SetTexture("_ScreenTex", game); material.SetTexture("_FrontTex", cutsceneEvents[0].newImage); material.SetTexture("_BackTex", game); material.SetFloat("_Zoom", zoom); material.SetFloat("_PanX", pan.x); material.SetFloat("_PanY", pan.y); material.SetFloat("_Fade", 0); textAlpha = 0; var t = 0f; while (t <= 1) { t += Time.deltaTime / fadeInTime; material.SetFloat("_Alpha", Mathf.Clamp01(Mathf.SmoothStep(0, 1, t))); yield return(null); } for (var i = 0; i < cutsceneEvents.Length; i++) { var e = cutsceneEvents[i]; t = 0f; var fade = 0f; material.SetTexture("_FrontTex", e.newImage); material.SetTexture("_NoiseTex", e.transitionGradient); material.SetFloat("_Fade", fade); textMeshPro.text = e.newText; textAlpha = 1; var startZoom = zoom; var endZoom = e.zoom; var startPan = pan; var endPan = e.pan; if (e.audioClip != null) { UserInterfaceAudio.PlayClip(e.audioClip); } while (t <= 1f) { t = Mathf.Clamp01(t); var d = Mathf.SmoothStep(0, 1, t); zoom = Mathf.Lerp(startZoom, endZoom, d); pan = Vector2.Lerp(startPan, endPan, d); material.SetFloat("_Zoom", zoom); material.SetFloat("_PanX", pan.x); material.SetFloat("_PanY", pan.y); t += Time.deltaTime / e.duration; yield return(null); } textAlpha = 0; if (i < cutsceneEvents.Length - 1) { var next = cutsceneEvents[i + 1]; material.SetTexture("_BackTex", next.newImage); } else { material.SetTexture("_BackTex", null); } fade = 0f; while (fade <= 1) { fade += Time.deltaTime / crossFadeTime; material.SetFloat("_Fade", fade); yield return(null); } } t = 1f; while (t > 0) { t -= Time.deltaTime / fadeOutTime; material.SetFloat("_Alpha", Mathf.Clamp01(Mathf.SmoothStep(0, 1, t))); yield return(null); } yield return(null); isPlaying = false; gameObject.SetActive(false); if (OnFinish != null) { OnFinish(this); } if (Application.isPlaying && destroyWhenFinished) { Destroy(gameObject); } }