private void LoadGoalScript(string script_name, int index) { List <TextAssetParser> list = new List <TextAssetParser>(); TextAsset textAsset = Resources.Load("Scripts/AI/" + script_name + "Goals") as TextAsset; if (textAsset) { TextAssetParser textAssetParser = new TextAssetParser(textAsset); list.Add(textAssetParser); this.m_GoalParsersByName.Add(script_name, textAssetParser); Resources.UnloadAsset(textAsset); } else { for (int i = 0; i < 9999; i++) { AI.AIID aiid = (AI.AIID)index; string text = aiid.ToString() + "Goals_" + i.ToString(); textAsset = (Resources.Load("Scripts/AI/" + text) as TextAsset); if (!textAsset) { break; } TextAssetParser textAssetParser2 = new TextAssetParser(textAsset); list.Add(textAssetParser2); this.m_GoalParsersByName.Add(text, textAssetParser2); Resources.UnloadAsset(textAsset); } } this.m_GoalParsers.Add(index, list); }
public void Load(int index) { for (int i = 0; i < this.m_Members.Count; i++) { if (this.m_Members[i] != null) { this.m_AllObjects.Remove(this.m_Members[i].gameObject); UnityEngine.Object.Destroy(this.m_Members[i].gameObject); } } this.m_Members.Clear(); int num = SaveGame.LoadIVal("HAGroupCount" + index); for (int j = 0; j < num; j++) { AI.AIID aiid = (AI.AIID)Enum.Parse(typeof(AI.AIID), SaveGame.LoadSVal("HAGroupID" + j.ToString() + "_" + index.ToString())); Vector3 position = SaveGame.LoadV3Val("HAGroupPos" + j.ToString() + "_" + index.ToString()); Quaternion rotation = SaveGame.LoadQVal("HAGroupRot" + j.ToString() + "_" + index.ToString()); GameObject prefab = GreenHellGame.Instance.GetPrefab(aiid.ToString()); GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab, position, rotation, base.transform); HumanAI component = gameObject.GetComponent <HumanAI>(); this.AddAI(component); } this.Deactivate(); }
private void Setup() { if (!this.m_List) { return; } this.m_List.Clear(); for (int i = 0; i < 44; i++) { AI.AIID aiid = (AI.AIID)i; if (aiid.ToString().ToLower().Contains(this.m_LastField)) { this.m_List.AddElement(aiid.ToString(), -1); } } this.m_List.SortAlphabetically(); this.m_List.SetSelectionIndex(0); }
private static void ParseSoundFile(AI.AIID ai_id) { ScriptParser scriptParser = new ScriptParser(); scriptParser.Parse("AI/" + ai_id.ToString() + "Sounds", true); AISoundModule.s_IdleClips[(int)ai_id] = new List <AudioClip>(); AISoundModule.s_PanicClips[(int)ai_id] = new List <AudioClip>(); AISoundModule.s_DeathClips[(int)ai_id] = new List <AudioClip>(); for (int i = 0; i < scriptParser.GetKeysCount(); i++) { Key key = scriptParser.GetKey(i); if (key.GetName() == "Idle") { for (int j = 0; j < key.GetVariablesCount(); j++) { CJVariable variable = key.GetVariable(j); AudioClip item = Resources.Load("Sounds/AI/" + ai_id.ToString() + "/" + variable.SValue) as AudioClip; AISoundModule.s_IdleClips[(int)ai_id].Add(item); } } else if (key.GetName() == "Panic") { for (int k = 0; k < key.GetVariablesCount(); k++) { CJVariable variable2 = key.GetVariable(k); AudioClip item2 = Resources.Load("Sounds/AI/" + ai_id.ToString() + "/" + variable2.SValue) as AudioClip; AISoundModule.s_PanicClips[(int)ai_id].Add(item2); } } else if (key.GetName() == "Death") { for (int l = 0; l < key.GetVariablesCount(); l++) { CJVariable variable3 = key.GetVariable(l); AudioClip item3 = Resources.Load("Sounds/AI/" + ai_id.ToString() + "/" + variable3.SValue) as AudioClip; AISoundModule.s_DeathClips[(int)ai_id].Add(item3); } } } AISoundModule.s_Status[(int)ai_id] = true; }
private void Catch(AI.AIID id) { if (id != AI.AIID.None) { GameObject prefab = GreenHellGame.Instance.GetPrefab(id.ToString()); GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab); gameObject.name = prefab.name; this.m_AI = gameObject.GetComponent <AI>(); this.m_AI.m_Trap = this; Component[] components = gameObject.GetComponents(typeof(Component)); for (int i = 0; i < components.Length; i++) { Type type = components[i].GetType(); if (type != typeof(Transform) && type != typeof(BoxCollider) && type != typeof(Animator) && type != typeof(AI) && !type.IsSubclassOf(typeof(AI)) && type != typeof(SkinnedMeshRenderer) && type != typeof(AnimationEventsReceiver)) { UnityEngine.Object.Destroy(components[i]); } } this.m_AI.m_BoxCollider.isTrigger = true; this.m_AI.m_Trap = this; if (GreenHellGame.Instance.GetPrefab(this.m_AI.m_ID.ToString() + "_Body")) { AIInTrapTrigger aiinTrapTrigger = gameObject.AddComponent <AIInTrapTrigger>(); aiinTrapTrigger.m_AI = this.m_AI; } else { this.m_AI.AddDeadBodyComponent(); } Transform transform; if (this.m_SpecificAIDummies.ContainsKey((int)this.m_AI.m_ID)) { transform = this.m_SpecificAIDummies[(int)this.m_AI.m_ID]; } else if (this.m_AIDummy) { transform = this.m_AIDummy; } else { transform = base.transform; } gameObject.transform.position = transform.position; gameObject.transform.rotation = transform.rotation; this.UpdateEffect(); } if (this.m_Bait && this.m_Bait.m_Item) { this.m_Bait.DeleteItem(); } this.SetArmed(false); this.m_ChanceToCatchOutsideSpawner = 0f; }
private void TakeFish() { if (!this.m_Fish) { return; } AI component = this.m_Fish.GetComponent <AI>(); AI.AIID id = component.m_ID; Item item = ItemsManager.Get().CreateItem(id.ToString() + "_Body", false); InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, true); UnityEngine.Object.Destroy(component.gameObject); this.m_Fish = null; }
private void InitializeGoalParsers() { int num = 0; for (int i = 0; i < 44; i++) { AI.AIID aiid = (AI.AIID)i; string script_name = aiid.ToString(); this.LoadGoalScript(script_name, num); num++; } foreach (string script_name2 in this.m_AdditionalGoalScripts) { this.LoadGoalScript(script_name2, num); num++; } }
private void InitializeAnimatorDataParsers() { for (int i = 0; i < 44; i++) { List <TextAssetParser> list = new List <TextAssetParser>(); AI.AIID aiid = (AI.AIID)i; string text = aiid.ToString() + "AnimatorData"; TextAsset textAsset = Resources.Load("Scripts/AI/" + text) as TextAsset; if (textAsset) { TextAssetParser textAssetParser = new TextAssetParser(textAsset); list.Add(textAssetParser); this.m_AnimatorDataParsers.Add(text, textAssetParser); Resources.UnloadAsset(textAsset); } else { Debug.Log("Can't load animator data script - " + text); } } }
public override void OnExecute(TriggerAction.TYPE action) { base.OnExecute(action); AI.AIID id = this.m_AI.m_ID; Item item = ItemsManager.Get().CreateItem(id.ToString() + "_Body", false); if (id == AI.AIID.PoisonDartFrog) { List <Renderer> componentsDeepChild = General.GetComponentsDeepChild <Renderer>(base.gameObject); Material material = null; for (int i = 0; i < componentsDeepChild.Count; i++) { material = componentsDeepChild[i].material; } item.ApplyMaterial(material); } if (!item.Take()) { Inventory3DManager.Get().DropItem(item); } UnityEngine.Object.Destroy(this.m_AI.gameObject); this.m_AI = null; }
private void TakeFish() { if (!this.m_Fish) { return; } AI component = this.m_Fish.GetComponent <AI>(); AI.AIID id = component.m_ID; Item item = ItemsManager.Get().CreateItem(id.ToString() + "_Body", false); InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, true); UnityEngine.Object.Destroy(component.gameObject); this.m_Fish = null; this.SetState(FishingController.State.Idle); Animator componentDeepChild = General.GetComponentDeepChild <Animator>(item.gameObject); if (componentDeepChild != null) { componentDeepChild.SetBool("Backpack", true); } HintsManager.Get().HideHint("Cast_FishingRod"); }
private void InitializeGoalParsers() { for (int i = 0; i < 39; i++) { List <TextAssetParser> list = new List <TextAssetParser>(); AI.AIID aiid = (AI.AIID)i; string text = aiid.ToString() + "Goals"; string path = "Scripts/AI/" + text; TextAsset textAsset = Resources.Load(path) as TextAsset; if (textAsset) { TextAssetParser textAssetParser = new TextAssetParser(textAsset); list.Add(textAssetParser); this.m_GoalParsersByName.Add(text, textAssetParser); Resources.UnloadAsset(textAsset); } else { for (int j = 0; j < 9999; j++) { AI.AIID aiid2 = (AI.AIID)i; text = aiid2.ToString() + "Goals_" + j.ToString(); path = "Scripts/AI/" + text; textAsset = (Resources.Load(path) as TextAsset); if (!textAsset) { break; } TextAssetParser textAssetParser2 = new TextAssetParser(textAsset); list.Add(textAssetParser2); this.m_GoalParsersByName.Add(text, textAssetParser2); Resources.UnloadAsset(textAsset); } } this.m_GoalParsers.Add(i, list); } }
private void OnEnterState() { WeaponSpearController.State spearState = this.m_SpearState; switch (spearState) { case WeaponSpearController.State.UnAim: case WeaponSpearController.State.ThrowUnAim: this.m_Player.StopAim(); break; case WeaponSpearController.State.AttackDown: this.Attack(); this.m_WasWaterHit = false; this.m_CanHitWater = false; PlayerAudioModule.Get().PlayAttackSound(1f, false); this.m_Player.DecreaseStamina(this.m_Player.GetStaminaDecrease(StaminaDecreaseReason.Attack) * Skill.Get <SpearSkill>().GetStaminaMul()); break; case WeaponSpearController.State.Attack: this.Attack(); this.m_WasWaterHit = false; this.m_CanHitWater = false; PlayerAudioModule.Get().PlayAttackSound(1f, false); this.m_Player.DecreaseStamina(this.m_Player.GetStaminaDecrease(StaminaDecreaseReason.Attack) * Skill.Get <SpearSkill>().GetStaminaMul()); this.m_Player.StopAim(); break; default: if (spearState == WeaponSpearController.State.Aim) { this.m_Player.StartAim(Player.AimType.SpearFishing); } break; case WeaponSpearController.State.ThrowAim: this.m_Player.StartAim(Player.AimType.SpearHunting); break; case WeaponSpearController.State.Throw: this.m_Player.StopAim(); this.m_Player.DecreaseStamina(this.m_Player.GetStaminaDecrease(StaminaDecreaseReason.Throw) * Skill.Get <SpearSkill>().GetStaminaMul()); break; case WeaponSpearController.State.Presentation: { this.m_ImpaledObject.transform.parent = null; AI component = this.m_ImpaledObject.GetComponent <AI>(); this.m_ImpaledIsStingRay = false; this.m_ImpaledArowana = false; this.m_ImpaledPiranha = false; AI.AIID id = component.m_ID; Item item = ItemsManager.Get().CreateItem(id.ToString() + "_Body", false); Item currentItem = this.m_Player.GetCurrentItem(Hand.Right); Vector3 b = (currentItem.m_DamagerStart.position - currentItem.m_DamagerEnd.position).normalized * -0.07f; item.transform.rotation = currentItem.m_DamagerStart.rotation; if (component.m_ID == AI.AIID.Arowana) { this.m_ImpaledArowana = true; item.transform.Rotate(Vector3.forward, -60f); } else if (component.m_ID == AI.AIID.Piranha) { this.m_ImpaledPiranha = true; item.transform.Rotate(Vector3.forward, -90f); } else if (component.IsStringray()) { this.m_ImpaledIsStingRay = true; item.transform.Rotate(Vector3.forward, -210f); } else { item.transform.Rotate(Vector3.forward, 0f); this.m_ImpaledIsStingRay = false; } item.transform.position = currentItem.m_DamagerStart.position + b; item.transform.parent = this.m_Player.GetCurrentItem(Hand.Right).transform; item.m_BlockGrabAnimOnExecute = true; item.m_AttachedToSpear = true; this.m_ItemBody = item; UnityEngine.Object.Destroy(this.m_ImpaledObject.gameObject); this.m_ImpaledObject = null; item.m_CanBeOutlined = false; this.PlayCatchAnimation(); break; } } }
private void Catch(AI.AIID id, int index) { if (id != AI.AIID.None) { GameObject prefab = GreenHellGame.Instance.GetPrefab(id.ToString()); GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab); gameObject.name = prefab.name; AI component = gameObject.GetComponent <AI>(); component.m_Trap = this; Behaviour[] components = gameObject.GetComponents <Behaviour>(); for (int i = 0; i < components.Length; i++) { Type type = components[i].GetType(); if (type != typeof(Transform) && type != typeof(BoxCollider) && type != typeof(Animator) && type != typeof(AI) && !type.IsSubclassOf(typeof(AI)) && type != typeof(SkinnedMeshRenderer) && type != typeof(AnimationEventsReceiver) && type != typeof(GuidComponent) && type != typeof(ReplicationComponent) && type != typeof(Relevance)) { if (components[i] is IReplicatedBehaviour) { components[i].enabled = false; } else { UnityEngine.Object.Destroy(components[i]); } } } component.m_BoxCollider.isTrigger = true; component.m_Trap = this; if ((this.m_Effect == Trap.Effect.Block || this.m_Info.m_ID == ItemID.Snare_Trap) && component.m_SoundModule) { component.m_SoundModule.RequestSound(AISoundType.Panic); } if (GreenHellGame.Instance.GetPrefab(component.m_ID.ToString() + "_Body")) { gameObject.AddComponent <AIInTrapTrigger>().m_AI = component; } else { component.AddDeadBodyComponent(); } Transform transform; if (this.m_SpecificAIDummies.ContainsKey((int)component.m_ID)) { transform = this.m_SpecificAIDummies[(int)component.m_ID][index]; } else if (this.m_AIDummy) { transform = this.m_AIDummy; } else { transform = base.transform; } gameObject.transform.position = transform.position; gameObject.transform.rotation = transform.rotation; if (this.m_WaterColl) { Vector3 position = gameObject.transform.position; position.y = this.m_WaterColl.bounds.max.y - component.m_BoxCollider.size.y * 0.5f; gameObject.transform.position = position; } this.UpdateEffect(); this.m_AIs.Add(component); } if (this.m_Bait && this.m_Bait.m_Item) { this.m_Bait.DeleteItem(); } this.SetArmed(false); this.m_ChanceToCatchOutsideSpawner = 0f; }