public bool SetActivateUnitObject(int idx) { if (idx < 0 || idx >= this.mUnitObjectLists.Count) { return(false); } int index = 0; while (index < this.mUnitObjectLists.Count && !UnityEngine.Object.op_Equality((UnityEngine.Object) this.mUnitObject, (UnityEngine.Object) this.mUnitObjectLists[index])) { ++index; } using (List <GameObject> .Enumerator enumerator = this.mUnitObjectLists.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.SetActive(false); } } this.mUnitObject = this.mUnitObjectLists[idx]; this.mUnitObject.SetActive(true); this.SetAnimationComponent((Animation)this.mUnitObject.GetComponent <Animation>()); if (idx < this.mCharacterDataLists.Count) { this.mCharacterData = this.mCharacterDataLists[idx]; } if (idx < this.mCharacterSettingsLists.Count) { this.mCharacterSettings = this.mCharacterSettingsLists[idx]; } if (idx < this.mFaceAnimationLists.Count) { this.mFaceAnimation = this.mFaceAnimationLists[idx]; } return(idx != index); }
public void LoadImmediately(string characterID, ESex sex, string jobID) { CharacterDB.Character character = CharacterDB.FindCharacter(characterID); if (character != null) { int index = character.IndexOfJob(jobID); if (string.IsNullOrEmpty(jobID) || index >= 0) { CharacterDB.Job job = character.Jobs[index]; if (!string.IsNullOrEmpty(job.BodyName)) { this.Body = (GameObject)Resources.Load <GameObject>("CH/BODY/" + job.BodyName); if (Object.op_Equality((Object)this.Body, (Object)null)) { Debug.LogError((object)("Failed to load " + job.BodyName)); } else { if (!string.IsNullOrEmpty(job.BodyTextureName)) { this.BodyTexture = (Texture2D)Resources.Load <Texture2D>("CH/BODYTEX/" + job.BodyTextureName); if (Object.op_Equality((Object)this.BodyTexture, (Object)null)) { Debug.LogError((object)("Failed to load " + job.BodyTextureName)); goto label_24; } } if (!string.IsNullOrEmpty(job.BodyAttachmentName)) { this.BodyAttachment = (GameObject)Resources.Load <GameObject>("CH/BODYOPT/" + job.BodyAttachmentName); if (Object.op_Equality((Object)this.BodyAttachment, (Object)null)) { Debug.LogError((object)("Failed to load " + job.BodyAttachmentName)); goto label_24; } } if (!string.IsNullOrEmpty(job.HeadName)) { this.Head = (GameObject)Resources.Load <GameObject>("CH/HEAD/" + job.HeadName); if (Object.op_Equality((Object)this.Head, (Object)null)) { Debug.LogError((object)("Failed to load " + job.HeadName)); goto label_24; } } if (!string.IsNullOrEmpty(job.HairName)) { this.Hair = (GameObject)Resources.Load <GameObject>("CH/HAIR/" + job.HairName); if (Object.op_Equality((Object)this.Hair, (Object)null)) { Debug.LogError((object)("Failed to load " + job.HairName)); goto label_24; } } if (!string.IsNullOrEmpty(job.HeadAttachmentName)) { this.HeadAttachment = (GameObject)Resources.Load <GameObject>("CH/HEADOPT/" + job.HeadAttachmentName); if (Object.op_Equality((Object)this.HeadAttachment, (Object)null)) { Debug.LogError((object)("Failed to load " + job.HeadAttachmentName)); goto label_24; } } this.HairColor0 = job.HairColor0; this.HairColor1 = job.HairColor1; return; } } } else { this.Body = (GameObject)Resources.Load <GameObject>("Units/" + sex.ToPrefix() + characterID); if (Object.op_Inequality((Object)this.Body, (Object)null)) { return; } Debug.LogError((object)("Failed to load " + sex.ToPrefix() + characterID)); } } label_24: this.Body = (GameObject)Resources.Load <GameObject>("Units/NULL"); this.BodyAttachment = (GameObject)null; this.BodyTexture = (Texture2D)null; this.Head = (GameObject)null; this.HeadAttachment = (GameObject)null; this.Hair = (GameObject)null; }
public static void LoadDatabase() { if (CharacterDB.mDBLoaded) { return; } CharacterDB.mDBLoaded = true; string s = AssetManager.LoadTextData(CharacterDB.DatabasePath); if (string.IsNullOrEmpty(s)) { Debug.LogError((object)"Failed to load CharacterDB"); } else { char[] chArray = new char[1] { '\t' }; CharacterDB.mCharacters.Clear(); using (StringReader stringReader = new StringReader(s)) { string str1 = stringReader.ReadLine(); if (string.IsNullOrEmpty(str1)) { return; } string[] array = str1.Split(chArray); int index1 = Array.IndexOf <string>(array, "ID"); int index2 = Array.IndexOf <string>(array, "JOB"); int index3 = Array.IndexOf <string>(array, "BODY"); int index4 = Array.IndexOf <string>(array, "BODY_TEXTURE"); int index5 = Array.IndexOf <string>(array, "BODY_ATTACHMENT"); int index6 = Array.IndexOf <string>(array, "HEAD"); int index7 = Array.IndexOf <string>(array, "HEAD_ATTACHMENT"); int index8 = Array.IndexOf <string>(array, "HAIR"); int index9 = Array.IndexOf <string>(array, "HAIR_COLOR1"); int index10 = Array.IndexOf <string>(array, "HAIR_COLOR2"); int index11 = Array.IndexOf <string>(array, "PREFIX"); int index12 = Array.IndexOf <string>(array, "MOVABLE"); string str2; while ((str2 = stringReader.ReadLine()) != null) { string[] strArray = str2.Split(chArray); if (str2.Length > 0) { CharacterDB.Character character = CharacterDB.ReserveCharacter(strArray[index1]); CharacterDB.Job job = new CharacterDB.Job(); job.JobID = strArray[index2]; job.HashID = job.JobID.GetHashCode(); job.HairName = strArray[index8]; job.BodyName = strArray[index3]; job.BodyTextureName = strArray[index4]; job.BodyAttachmentName = strArray[index5]; job.HeadName = strArray[index6]; job.HeadAttachmentName = strArray[index7]; job.HairColor0 = GameUtility.ParseColor(strArray[index9]); job.HairColor1 = GameUtility.ParseColor(strArray[index10]); job.Movable = true; if (index11 != -1) { job.AssetPrefix = strArray[index11]; } int result; if (index12 != -1 && int.TryParse(strArray[index12], out result)) { job.Movable = result != 0; } character.Jobs.Add(job); } } } } }