| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Raven : MonoBehaviour, Hoverable, Interactable, IDestructible |
| public class Raven : MonoBehaviour, Hoverable, Interactable, IDestructible |
| { |
| { |
| public static bool IsInstantiated() |
| public static bool IsInstantiated() |
| { |
| { |
| return Raven.m_instance != null; |
| return Raven.m_instance != null; |
| } |
| } |
| |
| |
| private void Awake() |
| private void Awake() |
| { |
| { |
| base.transform.position = new Vector3(0f, 100000f, 0f); |
| base.transform.position = new Vector3(0f, 100000f, 0f); |
| Raven.m_instance = this; |
| Raven.m_instance = this; |
| this.m_animator = this.m_visual.GetComponentInChildren<Animator>(); |
| this.m_animator = this.m_visual.GetComponentInChildren<Animator>(); |
| this.m_collider = base.GetComponent<Collider>(); |
| this.m_collider = base.GetComponent<Collider>(); |
| base.InvokeRepeating("IdleEffect", UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax), UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax)); |
| base.InvokeRepeating("IdleEffect", UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax), UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax)); |
| base.InvokeRepeating("CheckSpawn", 1f, 1f); |
| base.InvokeRepeating("CheckSpawn", 1f, 1f); |
| } |
| } |
| |
| |
| private void OnDestroy() |
| private void OnDestroy() |
| { |
| { |
| if (Raven.m_instance == this) |
| if (Raven.m_instance == this) |
| { |
| { |
| Raven.m_instance = null; |
| Raven.m_instance = null; |
| } |
| } |
| } |
| } |
| |
| |
| public string GetHoverText() |
| public string GetHoverText() |
| { |
| { |
| if (this.IsSpawned()) |
| if (this.IsSpawned()) |
| { |
| { |
| return Localization.instance.Localize(this.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); |
| return Localization.instance.Localize(this.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $raven_interact"); |
| } |
| } |
| return ""; |
| return ""; |
| } |
| } |
| |
| |
| public string GetHoverName() |
| public string GetHoverName() |
| { |
| { |
| return Localization.instance.Localize(this.m_name); |
| return Localization.instance.Localize(this.m_name); |
| } |
| } |
| |
| |
| public bool Interact(Humanoid character, bool hold, bool alt) |
| public bool Interact(Humanoid character, bool hold, bool alt) |
| { |
| { |
| if (hold) |
| if (hold) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (this.m_hasTalked && Chat.instance.IsDialogVisible(base.gameObject)) |
| if (this.m_hasTalked && Chat.instance.IsDialogVisible(base.gameObject)) |
| { |
| { |
| Chat.instance.ClearNpcText(base.gameObject); |
| Chat.instance.ClearNpcText(base.gameObject); |
| } |
| } |
| else |
| else |
| { |
| { |
| this.Talk(); |
| this.Talk(); |
| } |
| } |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private void Talk() |
| private void Talk() |
| { |
| { |
| if (!Player.m_localPlayer) |
| if (!Player.m_localPlayer) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.m_currentText == null) |
| if (this.m_currentText == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (this.m_currentText.m_key.Length > 0) |
| if (this.m_currentText.m_key.Length > 0) |
| { |
| { |
| Player.m_localPlayer.SetSeenTutorial(this.m_currentText.m_key); |
| Player.m_localPlayer.SetSeenTutorial(this.m_currentText.m_key); |
| Gogan.LogEvent("Game", "Raven", this.m_currentText.m_key, 0L); |
| Gogan.LogEvent("Game", "Raven", this.m_currentText.m_key, 0L); |
| } |
| } |
| else |
| else |
| { |
| { |
| Gogan.LogEvent("Game", "Raven", this.m_currentText.m_topic, 0L); |
| Gogan.LogEvent("Game", "Raven", this.m_currentText.m_topic, 0L); |
| } |
| } |
| this.m_hasTalked = true; |
| this.m_hasTalked = true; |
| if (this.m_currentText.m_label.Length > 0) |
| if (this.m_currentText.m_label.Length > 0) |
| { |
| { |
| Player.m_localPlayer.AddKnownText(this.m_currentText.m_label, this.m_currentText.m_text); |
| Player.m_localPlayer.AddKnownText(this.m_currentText.m_label, this.m_currentText.m_text); |
| } |
| } |
| this.Say(this.m_currentText.m_topic, this.m_currentText.m_text, false, true, true); |
| this.Say(this.m_currentText.m_topic, this.m_currentText.m_text, false, true, true); |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenTalk, 1f); |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenTalk, 1f); |
| } |
| } |
| |
| |
| private void Say(string topic, string text, bool showName, bool longTimeout, bool large) |
| private void Say(string topic, string text, bool showName, bool longTimeout, bool large) |
| { |
| { |
| if (topic.Length > 0) |
| if (topic.Length > 0) |
| { |
| { |
| text = "<color=orange>" + topic + "</color>\n" + text; |
| text = "<color=orange>" + topic + "</color>\n" + text; |
| } |
| } |
| Chat.instance.SetNpcText(base.gameObject, Vector3.up * this.m_textOffset, this.m_textCullDistance, longTimeout ? this.m_longDialogVisibleTime : this.m_dialogVisibleTime, showName ? this.m_name : "", text, large); |
| Chat.instance.SetNpcText(base.gameObject, Vector3.up * this.m_textOffset, this.m_textCullDistance, longTimeout ? this.m_longDialogVisibleTime : this.m_dialogVisibleTime, showName ? this.m_name : "", text, large); |
| this.m_animator.SetTrigger("talk"); |
| this.m_animator.SetTrigger("talk"); |
| } |
| } |
| |
| |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| public bool UseItem(Humanoid user, ItemDrop.ItemData item) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private void IdleEffect() |
| private void IdleEffect() |
| { |
| { |
| if (!this.IsSpawned()) |
| if (!this.IsSpawned()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.m_idleEffect.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| this.m_idleEffect.Create(base.transform.position, base.transform.rotation, null, 1f, -1); |
| base.CancelInvoke("IdleEffect"); |
| base.CancelInvoke("IdleEffect"); |
| base.InvokeRepeating("IdleEffect", UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax), UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax)); |
| base.InvokeRepeating("IdleEffect", UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax), UnityEngine.Random.Range(this.m_idleEffectIntervalMin, this.m_idleEffectIntervalMax)); |
| } |
| } |
| |
| |
| private bool CanHide() |
| private bool CanHide() |
| { |
| { |
| return Player.m_localPlayer == null || !Chat.instance.IsDialogVisible(base.gameObject); |
| return Player.m_localPlayer == null || !Chat.instance.IsDialogVisible(base.gameObject); |
| } |
| } |
| |
| |
| private void Update() |
| private void Update() |
| { |
| { |
| this.m_timeSinceTeleport += Time.deltaTime; |
| this.m_timeSinceTeleport += Time.deltaTime; |
| if (!this.IsAway() && !this.IsFlying() && Player.m_localPlayer) |
| if (!this.IsAway() && !this.IsFlying() && Player.m_localPlayer) |
| { |
| { |
| Vector3 vector = Player.m_localPlayer.transform.position - base.transform.position; |
| Vector3 vector = Player.m_localPlayer.transform.position - base.transform.position; |
| vector.y = 0f; |
| vector.y = 0f; |
| vector.Normalize(); |
| vector.Normalize(); |
| float num = Vector3.SignedAngle(base.transform.forward, vector, Vector3.up); |
| float num = Vector3.SignedAngle(base.transform.forward, vector, Vector3.up); |
| if (Mathf.Abs(num) > this.m_minRotationAngle) |
| if (Mathf.Abs(num) > this.m_minRotationAngle) |
| { |
| { |
| this.m_animator.SetFloat("anglevel", this.m_rotateSpeed * Mathf.Sign(num), 0.4f, Time.deltaTime); |
| this.m_animator.SetFloat("anglevel", this.m_rotateSpeed * Mathf.Sign(num), 0.4f, Time.deltaTime); |
| base.transform.rotation = Quaternion.RotateTowards(base.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * this.m_rotateSpeed); |
| base.transform.rotation = Quaternion.RotateTowards(base.transform.rotation, Quaternion.LookRotation(vector), Time.deltaTime * this.m_rotateSpeed); |
| } |
| } |
| else |
| else |
| { |
| { |
| this.m_animator.SetFloat("anglevel", 0f, 0.4f, Time.deltaTime); |
| this.m_animator.SetFloat("anglevel", 0f, 0.4f, Time.deltaTime); |
| } |
| } |
| } |
| } |
| if (this.IsSpawned()) |
| if (this.IsSpawned()) |
| { |
| { |
| if (Player.m_localPlayer != null && !Chat.instance.IsDialogVisible(base.gameObject) && Vector3.Distance(Player.m_localPlayer.transform.position, base.transform.position) < this.m_autoTalkDistance) |
| if (Player.m_localPlayer != null && !Chat.instance.IsDialogVisible(base.gameObject) && Vector3.Distance(Player.m_localPlayer.transform.position, base.transform.position) < this.m_autoTalkDistance) |
| { |
| { |
| this.m_randomTextTimer += Time.deltaTime; |
| this.m_randomTextTimer += Time.deltaTime; |
| float num2 = (this.m_hasTalked ? this.m_randomTextInterval : this.m_randomTextIntervalImportant); |
| float num2 = (this.m_hasTalked ? this.m_randomTextInterval : this.m_randomTextIntervalImportant); |
| if (this.m_randomTextTimer >= num2) |
| if (this.m_randomTextTimer >= num2) |
| { |
| { |
| this.m_randomTextTimer = 0f; |
| this.m_randomTextTimer = 0f; |
| if (this.m_hasTalked) |
| if (this.m_hasTalked) |
| { |
| { |
| this.Say("", this.m_randomTexts[UnityEngine.Random.Range(0, this.m_randomTexts.Count)], false, false, false); |
| this.Say("", this.m_randomTexts[UnityEngine.Random.Range(0, this.m_randomTexts.Count)], false, false, false); |
| } |
| } |
| else |
| else |
| { |
| { |
| this.Say("", this.m_randomTextsImportant[UnityEngine.Random.Range(0, this.m_randomTextsImportant.Count)], false, false, false); |
| this.Say("", this.m_randomTextsImportant[UnityEngine.Random.Range(0, this.m_randomTextsImportant.Count)], false, false, false); |
| } |
| } |
| } |
| } |
| } |
| } |
| if ((Player.m_localPlayer == null || Vector3.Distance(Player.m_localPlayer.transform.position, base.transform.position) > this.m_despawnDistance || this.EnemyNearby(base.transform.position) || RandEventSystem.InEvent() || this.m_currentText == null || this.m_groundObject == null || this.m_hasTalked) && this.CanHide()) |
| if ((Player.m_localPlayer == null || Vector3.Distance(Player.m_localPlayer.transform.position, base.transform.position) > this.m_despawnDistance || this.EnemyNearby(base.transform.position) || RandEventSystem.InEvent() || this.m_currentText == null || this.m_groundObject == null || this.m_hasTalked) && this.CanHide()) |
| { |
| { |
| bool flag = this.GetBestText() != null || this.m_groundObject == null; |
| bool flag = this.GetBestText() != null || this.m_groundObject == null; |
| this.FlyAway(flag); |
| this.FlyAway(flag); |
| this.RestartSpawnCheck(3f); |
| this.RestartSpawnCheck(3f); |
| } |
| } |
| this.m_exclamation.SetActive(!this.m_hasTalked); |
| this.m_exclamation.SetActive(!this.m_hasTalked); |
| return; |
| return; |
| } |
| } |
| this.m_exclamation.SetActive(false); |
| this.m_exclamation.SetActive(false); |
| } |
| } |
| |
| |
| private bool FindSpawnPoint(out Vector3 point, out GameObject landOn) |
| private bool FindSpawnPoint(out Vector3 point, out GameObject landOn) |
| { |
| { |
| Vector3 position = Player.m_localPlayer.transform.position; |
| Vector3 position = Player.m_localPlayer.transform.position; |
| Vector3 forward = Utils.GetMainCamera().transform.forward; |
| Vector3 forward = Utils.GetMainCamera().transform.forward; |
| forward.y = 0f; |
| forward.y = 0f; |
| forward.Normalize(); |
| forward.Normalize(); |
| point = new Vector3(0f, -999f, 0f); |
| point = new Vector3(0f, -999f, 0f); |
| landOn = null; |
| landOn = null; |
| bool flag = false; |
| bool flag = false; |
| for (int i = 0; i < 20; i++) |
| for (int i = 0; i < 20; i++) |
| { |
| { |
| Vector3 vector = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(-30, 30), 0f) * forward; |
| Vector3 vector = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(-30, 30), 0f) * forward; |
| Vector3 vector2 = position + vector * UnityEngine.Random.Range(this.m_spawnDistance - 5f, this.m_spawnDistance); |
| Vector3 vector2 = position + vector * UnityEngine.Random.Range(this.m_spawnDistance - 5f, this.m_spawnDistance); |
| float num; |
| float num; |
| Vector3 vector3; |
| Vector3 vector3; |
| GameObject gameObject; |
| GameObject gameObject; |
| . | if (ZoneSystem.instance.GetSolidHeight(vector2, out num, out vector3, out gameObject) && num > ZoneSystem.instance.m_waterLevel && num > point.y && num < 2000f && vector3.y > 0.5f && Mathf.Abs(num - position.y) < 2f) |
| if (ZoneSystem.instance.GetSolidHeight(vector2, out num, out vector3, out gameObject) && num > 30f && num > point.y && num < 2000f && vector3.y > 0.5f && Mathf.Abs(num - position.y) < 2f) |
| { |
| { |
| vector2.y = num; |
| vector2.y = num; |
| point = vector2; |
| point = vector2; |
| landOn = gameObject; |
| landOn = gameObject; |
| flag = true; |
| flag = true; |
| } |
| } |
| } |
| } |
| return flag; |
| return flag; |
| } |
| } |
| |
| |
| private bool EnemyNearby(Vector3 point) |
| private bool EnemyNearby(Vector3 point) |
| { |
| { |
| return LootSpawner.IsMonsterInRange(point, this.m_enemyCheckDistance); |
| return LootSpawner.IsMonsterInRange(point, this.m_enemyCheckDistance); |
| } |
| } |
| |
| |
| private bool InState(string name) |
| private bool InState(string name) |
| { |
| { |
| return this.m_animator.isInitialized && (this.m_animator.GetCurrentAnimatorStateInfo(0).IsTag(name) || this.m_animator.GetNextAnimatorStateInfo(0).IsTag(name)); |
| return this.m_animator.isInitialized && (this.m_animator.GetCurrentAnimatorStateInfo(0).IsTag(name) || this.m_animator.GetNextAnimatorStateInfo(0).IsTag(name)); |
| } |
| } |
| |
| |
| private Raven.RavenText GetBestText() |
| private Raven.RavenText GetBestText() |
| { |
| { |
| Raven.RavenText ravenText = this.GetTempText(); |
| Raven.RavenText ravenText = this.GetTempText(); |
| Raven.RavenText closestStaticText = this.GetClosestStaticText(this.m_spawnDistance); |
| Raven.RavenText closestStaticText = this.GetClosestStaticText(this.m_spawnDistance); |
| if (closestStaticText != null && (ravenText == null || closestStaticText.m_priority >= ravenText.m_priority)) |
| if (closestStaticText != null && (ravenText == null || closestStaticText.m_priority >= ravenText.m_priority)) |
| { |
| { |
| ravenText = closestStaticText; |
| ravenText = closestStaticText; |
| } |
| } |
| return ravenText; |
| return ravenText; |
| } |
| } |
| |
| |
| private Raven.RavenText GetTempText() |
| private Raven.RavenText GetTempText() |
| { |
| { |
| foreach (Raven.RavenText ravenText in Raven.m_tempTexts) |
| foreach (Raven.RavenText ravenText in Raven.m_tempTexts) |
| { |
| { |
| if (ravenText.m_munin == this.m_isMunin) |
| if (ravenText.m_munin == this.m_isMunin) |
| { |
| { |
| return ravenText; |
| return ravenText; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| private Raven.RavenText GetClosestStaticText(float maxDistance) |
| private Raven.RavenText GetClosestStaticText(float maxDistance) |
| { |
| { |
| if (Player.m_localPlayer == null) |
| if (Player.m_localPlayer == null) |
| { |
| { |
| return null; |
| return null; |
| } |
| } |
| Raven.RavenText ravenText = null; |
| Raven.RavenText ravenText = null; |
| float num = 9999f; |
| float num = 9999f; |
| bool flag = false; |
| bool flag = false; |
| Vector3 position = Player.m_localPlayer.transform.position; |
| Vector3 position = Player.m_localPlayer.transform.position; |
| foreach (Raven.RavenText ravenText2 in Raven.m_staticTexts) |
| foreach (Raven.RavenText ravenText2 in Raven.m_staticTexts) |
| { |
| { |
| if (ravenText2.m_munin == this.m_isMunin && ravenText2.m_guidePoint) |
| if (ravenText2.m_munin == this.m_isMunin && ravenText2.m_guidePoint) |
| { |
| { |
| float num2 = Vector3.Distance(position, ravenText2.m_guidePoint.transform.position); |
| float num2 = Vector3.Distance(position, ravenText2.m_guidePoint.transform.position); |
| if (num2 < maxDistance) |
| if (num2 < maxDistance) |
| { |
| { |
| bool flag2 = ravenText2.m_key.Length > 0 && Player.m_localPlayer.HaveSeenTutorial(ravenText2.m_key); |
| bool flag2 = ravenText2.m_key.Length > 0 && Player.m_localPlayer.HaveSeenTutorial(ravenText2.m_key); |
| if (ravenText2.m_alwaysSpawn || !flag2) |
| if (ravenText2.m_alwaysSpawn || !flag2) |
| { |
| { |
| if (ravenText == null) |
| if (ravenText == null) |
| { |
| { |
| ravenText = ravenText2; |
| ravenText = ravenText2; |
| num = num2; |
| num = num2; |
| flag = flag2; |
| flag = flag2; |
| } |
| } |
| else if (flag2 == flag) |
| else if (flag2 == flag) |
| { |
| { |
| if (ravenText2.m_priority == ravenText.m_priority || flag2) |
| if (ravenText2.m_priority == ravenText.m_priority || flag2) |
| { |
| { |
| if (num2 < num) |
| if (num2 < num) |
| { |
| { |
| ravenText = ravenText2; |
| ravenText = ravenText2; |
| num = num2; |
| num = num2; |
| flag = flag2; |
| flag = flag2; |
| } |
| } |
| } |
| } |
| else if (ravenText2.m_priority > ravenText.m_priority) |
| else if (ravenText2.m_priority > ravenText.m_priority) |
| { |
| { |
| ravenText = ravenText2; |
| ravenText = ravenText2; |
| num = num2; |
| num = num2; |
| flag = flag2; |
| flag = flag2; |
| } |
| } |
| } |
| } |
| else if (!flag2 && flag) |
| else if (!flag2 && flag) |
| { |
| { |
| ravenText = ravenText2; |
| ravenText = ravenText2; |
| num = num2; |
| num = num2; |
| flag = flag2; |
| flag = flag2; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return ravenText; |
| return ravenText; |
| } |
| } |
| |
| |
| private void RemoveSeendTempTexts() |
| private void RemoveSeendTempTexts() |
| { |
| { |
| for (int i = 0; i < Raven.m_tempTexts.Count; i++) |
| for (int i = 0; i < Raven.m_tempTexts.Count; i++) |
| { |
| { |
| if (Player.m_localPlayer.HaveSeenTutorial(Raven.m_tempTexts[i].m_key)) |
| if (Player.m_localPlayer.HaveSeenTutorial(Raven.m_tempTexts[i].m_key)) |
| { |
| { |
| Raven.m_tempTexts.RemoveAt(i); |
| Raven.m_tempTexts.RemoveAt(i); |
| return; |
| return; |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| private void FlyAway(bool forceTeleport = false) |
| private void FlyAway(bool forceTeleport = false) |
| { |
| { |
| Chat.instance.ClearNpcText(base.gameObject); |
| Chat.instance.ClearNpcText(base.gameObject); |
| if (forceTeleport || this.IsUnderRoof()) |
| if (forceTeleport || this.IsUnderRoof()) |
| { |
| { |
| this.m_animator.SetTrigger("poff"); |
| this.m_animator.SetTrigger("poff"); |
| this.m_timeSinceTeleport = 0f; |
| this.m_timeSinceTeleport = 0f; |
| return; |
| return; |
| } |
| } |
| this.m_animator.SetTrigger("flyaway"); |
| this.m_animator.SetTrigger("flyaway"); |
| } |
| } |
| |
| |
| private void CheckSpawn() |
| private void CheckSpawn() |
| { |
| { |
| if (Player.m_localPlayer == null) |
| if (Player.m_localPlayer == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.RemoveSeendTempTexts(); |
| this.RemoveSeendTempTexts(); |
| Raven.RavenText bestText = this.GetBestText(); |
| Raven.RavenText bestText = this.GetBestText(); |
| if (this.IsSpawned() && this.CanHide() && bestText != null && bestText != this.m_currentText) |
| if (this.IsSpawned() && this.CanHide() && bestText != null && bestText != this.m_currentText) |
| { |
| { |
| this.FlyAway(true); |
| this.FlyAway(true); |
| this.m_currentText = null; |
| this.m_currentText = null; |
| } |
| } |
| if (this.IsAway() && bestText != null) |
| if (this.IsAway() && bestText != null) |
| { |
| { |
| if (this.EnemyNearby(base.transform.position)) |
| if (this.EnemyNearby(base.transform.position)) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (RandEventSystem.InEvent()) |
| if (RandEventSystem.InEvent()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| bool flag = this.m_timeSinceTeleport < 6f; |
| bool flag = this.m_timeSinceTeleport < 6f; |
| this.Spawn(bestText, flag); |
| this.Spawn(bestText, flag); |
| } |
| } |
| } |
| } |
| |
| |
| public DestructibleType GetDestructibleType() |
| public DestructibleType GetDestructibleType() |
| { |
| { |
| return DestructibleType.Character; |
| return DestructibleType.Character; |
| } |
| } |
| |
| |
| public void Damage(HitData hit) |
| public void Damage(HitData hit) |
| { |
| { |
| if (!this.IsSpawned()) |
| if (!this.IsSpawned()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| this.FlyAway(true); |
| this.FlyAway(true); |
| this.RestartSpawnCheck(4f); |
| this.RestartSpawnCheck(4f); |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenHits, 1f); |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenHits, 1f); |
| } |
| } |
| |
| |
| private void RestartSpawnCheck(float delay) |
| private void RestartSpawnCheck(float delay) |
| { |
| { |
| base.CancelInvoke("CheckSpawn"); |
| base.CancelInvoke("CheckSpawn"); |
| base.InvokeRepeating("CheckSpawn", delay, 1f); |
| base.InvokeRepeating("CheckSpawn", delay, 1f); |
| } |
| } |
| |
| |
| private bool IsSpawned() |
| private bool IsSpawned() |
| { |
| { |
| return this.InState("visible"); |
| return this.InState("visible"); |
| } |
| } |
| |
| |
| public bool IsAway() |
| public bool IsAway() |
| { |
| { |
| return this.InState("away"); |
| return this.InState("away"); |
| } |
| } |
| |
| |
| public bool IsFlying() |
| public bool IsFlying() |
| { |
| { |
| return this.InState("flying"); |
| return this.InState("flying"); |
| } |
| } |
| |
| |
| private void Spawn(Raven.RavenText text, bool forceTeleport) |
| private void Spawn(Raven.RavenText text, bool forceTeleport) |
| { |
| { |
| if (Utils.GetMainCamera() == null || !Raven.m_tutorialsEnabled) |
| if (Utils.GetMainCamera() == null || !Raven.m_tutorialsEnabled) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (text.m_static) |
| if (text.m_static) |
| { |
| { |
| this.m_groundObject = text.m_guidePoint.gameObject; |
| this.m_groundObject = text.m_guidePoint.gameObject; |
| base.transform.position = text.m_guidePoint.transform.position; |
| base.transform.position = text.m_guidePoint.transform.position; |
| } |
| } |
| else |
| else |
| { |
| { |
| Vector3 vector; |
| Vector3 vector; |
| GameObject gameObject; |
| GameObject gameObject; |
| if (!this.FindSpawnPoint(out vector, out gameObject)) |
| if (!this.FindSpawnPoint(out vector, out gameObject)) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| base.transform.position = vector; |
| base.transform.position = vector; |
| this.m_groundObject = gameObject; |
| this.m_groundObject = gameObject; |
| } |
| } |
| this.m_currentText = text; |
| this.m_currentText = text; |
| this.m_hasTalked = false; |
| this.m_hasTalked = false; |
| this.m_randomTextTimer = 99999f; |
| this.m_randomTextTimer = 99999f; |
| if (this.m_currentText.m_key.Length > 0 && Player.m_localPlayer.HaveSeenTutorial(this.m_currentText.m_key)) |
| if (this.m_currentText.m_key.Length > 0 && Player.m_localPlayer.HaveSeenTutorial(this.m_currentText.m_key)) |
| { |
| { |
| this.m_hasTalked = true; |
| this.m_hasTalked = true; |
| } |
| } |
| Vector3 vector2 = Player.m_localPlayer.transform.position - base.transform.position; |
| Vector3 vector2 = Player.m_localPlayer.transform.position - base.transform.position; |
| vector2.y = 0f; |
| vector2.y = 0f; |
| vector2.Normalize(); |
| vector2.Normalize(); |
| base.transform.rotation = Quaternion.LookRotation(vector2); |
| base.transform.rotation = Quaternion.LookRotation(vector2); |
| if (forceTeleport) |
| if (forceTeleport) |
| { |
| { |
| this.m_animator.SetTrigger("teleportin"); |
| this.m_animator.SetTrigger("teleportin"); |
| } |
| } |
| else if (text.m_static) |
| else if (text.m_static) |
| { |
| { |
| if (this.IsUnderRoof()) |
| if (this.IsUnderRoof()) |
| { |
| { |
| this.m_animator.SetTrigger("teleportin"); |
| this.m_animator.SetTrigger("teleportin"); |
| } |
| } |
| else |
| else |
| { |
| { |
| this.m_animator.SetTrigger("flyin"); |
| this.m_animator.SetTrigger("flyin"); |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| this.m_animator.SetTrigger("flyin"); |
| this.m_animator.SetTrigger("flyin"); |
| } |
| } |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenAppear, 1f); |
| Game.instance.IncrementPlayerStat(PlayerStatType.RavenAppear, 1f); |
| } |
| } |
| |
| |
| private bool IsUnderRoof() |
| private bool IsUnderRoof() |
| { |
| { |
| return Physics.Raycast(base.transform.position + Vector3.up * 0.2f, Vector3.up, 20f, LayerMask.GetMask(new string[] { "Default", "static_solid", "piece" })); |
| return Physics.Raycast(base.transform.position + Vector3.up * 0.2f, Vector3.up, 20f, LayerMask.GetMask(new string[] { "Default", "static_solid", "piece" })); |
| } |
| } |
| |
| |
| public static void RegisterStaticText(Raven.RavenText text) |
| public static void RegisterStaticText(Raven.RavenText text) |
| { |
| { |
| Raven.m_staticTexts.Add(text); |
| Raven.m_staticTexts.Add(text); |
| } |
| } |
| |
| |
| public static void UnregisterStaticText(Raven.RavenText text) |
| public static void UnregisterStaticText(Raven.RavenText text) |
| { |
| { |
| Raven.m_staticTexts.Remove(text); |
| Raven.m_staticTexts.Remove(text); |
| } |
| } |
| |
| |
| public static void AddTempText(string key, string topic, string text, string label, bool munin) |
| public static void AddTempText(string key, string topic, string text, string label, bool munin) |
| { |
| { |
| if (key.Length > 0) |
| if (key.Length > 0) |
| { |
| { |
| using (List<Raven.RavenText>.Enumerator enumerator = Raven.m_tempTexts.GetEnumerator()) |
| using (List<Raven.RavenText>.Enumerator enumerator = Raven.m_tempTexts.GetEnumerator()) |
| { |
| { |
| while (enumerator.MoveNext()) |
| while (enumerator.MoveNext()) |
| { |
| { |
| if (enumerator.Current.m_key == key) |
| if (enumerator.Current.m_key == key) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| Raven.RavenText ravenText = new Raven.RavenText(); |
| Raven.RavenText ravenText = new Raven.RavenText(); |
| ravenText.m_key = key; |
| ravenText.m_key = key; |
| ravenText.m_topic = topic; |
| ravenText.m_topic = topic; |
| ravenText.m_label = label; |
| ravenText.m_label = label; |
| ravenText.m_text = text; |
| ravenText.m_text = text; |
| ravenText.m_static = false; |
| ravenText.m_static = false; |
| ravenText.m_munin = munin; |
| ravenText.m_munin = munin; |
| Raven.m_tempTexts.Add(ravenText); |
| Raven.m_tempTexts.Add(ravenText); |
| } |
| } |
| |
| |
| public GameObject m_visual; |
| public GameObject m_visual; |
| |
| |
| public GameObject m_exclamation; |
| public GameObject m_exclamation; |
| |
| |
| public string m_name = "Name"; |
| public string m_name = "Name"; |
| |
| |
| public bool m_isMunin; |
| public bool m_isMunin; |
| |
| |
| public bool m_autoTalk = true; |
| public bool m_autoTalk = true; |
| |
| |
| public float m_idleEffectIntervalMin = 10f; |
| public float m_idleEffectIntervalMin = 10f; |
| |
| |
| public float m_idleEffectIntervalMax = 20f; |
| public float m_idleEffectIntervalMax = 20f; |
| |
| |
| public float m_spawnDistance = 15f; |
| public float m_spawnDistance = 15f; |
| |
| |
| public float m_despawnDistance = 20f; |
| public float m_despawnDistance = 20f; |
| |
| |
| public float m_autoTalkDistance = 3f; |
| public float m_autoTalkDistance = 3f; |
| |
| |
| public float m_enemyCheckDistance = 10f; |
| public float m_enemyCheckDistance = 10f; |
| |
| |
| public float m_rotateSpeed = 10f; |
| public float m_rotateSpeed = 10f; |
| |
| |
| public float m_minRotationAngle = 15f; |
| public float m_minRotationAngle = 15f; |
| |
| |
| public float m_dialogVisibleTime = 10f; |
| public float m_dialogVisibleTime = 10f; |
| |
| |
| public float m_longDialogVisibleTime = 10f; |
| public float m_longDialogVisibleTime = 10f; |
| |
| |
| public float m_dontFlyDistance = 3f; |
| public float m_dontFlyDistance = 3f; |
| |
| |
| public float m_textOffset = 1.5f; |
| public float m_textOffset = 1.5f; |
| |
| |
| public float m_textCullDistance = 20f; |
| public float m_textCullDistance = 20f; |
| |
| |
| public float m_randomTextInterval = 30f; |
| public float m_randomTextInterval = 30f; |
| |
| |
| public float m_randomTextIntervalImportant = 10f; |
| public float m_randomTextIntervalImportant = 10f; |
| |
| |
| public List<string> m_randomTextsImportant = new List<string>(); |
| public List<string> m_randomTextsImportant = new List<string>(); |
| |
| |
| public List<string> m_randomTexts = new List<string>(); |
| public List<string> m_randomTexts = new List<string>(); |
| |
| |
| public EffectList m_idleEffect = new EffectList(); |
| public EffectList m_idleEffect = new EffectList(); |
| |
| |
| public EffectList m_despawnEffect = new EffectList(); |
| public EffectList m_despawnEffect = new EffectList(); |
| |
| |
| private Raven.RavenText m_currentText; |
| private Raven.RavenText m_currentText; |
| |
| |
| private GameObject m_groundObject; |
| private GameObject m_groundObject; |
| |
| |
| private Animator m_animator; |
| private Animator m_animator; |
| |
| |
| private Collider m_collider; |
| private Collider m_collider; |
| |
| |
| private bool m_hasTalked; |
| private bool m_hasTalked; |
| |
| |
| private float m_randomTextTimer = 9999f; |
| private float m_randomTextTimer = 9999f; |
| |
| |
| private float m_timeSinceTeleport = 9999f; |
| private float m_timeSinceTeleport = 9999f; |
| |
| |
| private static List<Raven.RavenText> m_tempTexts = new List<Raven.RavenText>(); |
| private static List<Raven.RavenText> m_tempTexts = new List<Raven.RavenText>(); |
| |
| |
| private static List<Raven.RavenText> m_staticTexts = new List<Raven.RavenText>(); |
| private static List<Raven.RavenText> m_staticTexts = new List<Raven.RavenText>(); |
| |
| |
| private static Raven m_instance = null; |
| private static Raven m_instance = null; |
| |
| |
| public static bool m_tutorialsEnabled = true; |
| public static bool m_tutorialsEnabled = true; |
| |
| |
| [Serializable] |
| [Serializable] |
| public class RavenText |
| public class RavenText |
| { |
| { |
| public bool m_alwaysSpawn = true; |
| public bool m_alwaysSpawn = true; |
| |
| |
| public bool m_munin; |
| public bool m_munin; |
| |
| |
| public int m_priority; |
| public int m_priority; |
| |
| |
| public string m_key = ""; |
| public string m_key = ""; |
| |
| |
| public string m_topic = ""; |
| public string m_topic = ""; |
| |
| |
| public string m_label = ""; |
| public string m_label = ""; |
| |
| |
| [TextArea] |
| [TextArea] |
| public string m_text = ""; |
| public string m_text = ""; |
| |
| |
| [NonSerialized] |
| [NonSerialized] |
| public bool m_static; |
| public bool m_static; |
| |
| |
| [NonSerialized] |
| [NonSerialized] |
| public GuidePoint m_guidePoint; |
| public GuidePoint m_guidePoint; |
| } |
| } |
| } |
| } |
| |
| |