Exemplo n.º 1
0
 public static CharacterDB.Character ReserveCharacter(string characterID)
 {
     CharacterDB.Character character = CharacterDB.FindCharacter(characterID);
     if (character == null)
     {
         character = new CharacterDB.Character(characterID);
         CharacterDB.mCharacters.Add(character);
     }
     return(character);
 }
Exemplo n.º 2
0
        public static CharacterDB.Character FindCharacter(string characterID)
        {
            CharacterDB.LoadDatabase();
            int hashCode = characterID.GetHashCode();

            for (int index = CharacterDB.mCharacters.Count - 1; index >= 0; --index)
            {
                if (CharacterDB.mCharacters[index].HashID == hashCode && CharacterDB.mCharacters[index].CharacterID == characterID)
                {
                    return(CharacterDB.mCharacters[index]);
                }
            }
            return((CharacterDB.Character)null);
        }
Exemplo n.º 3
0
 public static GameObject ComposeCharacter(string characterID, string jobID)
 {
     CharacterDB.Character character = CharacterDB.FindCharacter(characterID);
     if (character == null)
     {
         Debug.LogError((object)("Character '" + characterID + "' not found."));
         return((GameObject)null);
     }
     for (int index = 0; index < character.Jobs.Count; ++index)
     {
         if (!(character.Jobs[index].JobID == jobID))
         {
             ;
         }
     }
     Debug.LogError((object)("Character '" + characterID + "'can't be '" + jobID + "'."));
     return((GameObject)null);
 }
Exemplo n.º 4
0
 public bool LoadAddModels(int job_index)
 {
     if (this.mNumLoadRequests > 0)
     {
         return(false);
     }
     CharacterDB.Character character = CharacterDB.FindCharacter(this.mCharacterID);
     if (character == null)
     {
         Debug.LogError((object)("Unknown character '" + this.mCharacterID + "'"));
         return(false);
     }
     if (job_index < 0 || job_index >= character.Jobs.Count)
     {
         return(false);
     }
     this.StartCoroutine(this.AsyncSetup(character, job_index));
     return(true);
 }
Exemplo n.º 5
0
        protected override void Start()
        {
            base.Start();
            this.mCharacterDataLists.Clear();
            this.mUnitObjectLists.Clear();
            this.mCharacterSettingsLists.Clear();
            this.mFaceAnimationLists.Clear();
            CharacterDB.Character character = CharacterDB.FindCharacter(this.mCharacterID);
            if (character == null)
            {
                Debug.LogError((object)("Unknown character '" + this.mCharacterID + "'"));
                this.SetLoadError();
            }
            else
            {
                this.mJobResourceID = !string.IsNullOrEmpty(this.mJobID) ? MonoSingleton <GameManager> .Instance.GetJobParam(this.mJobID).model : "none";

                string str = (string)null;
                if (this.mUnitData != null && this.mUnitData.Jobs != null)
                {
                    ArtifactParam selectedSkin = this.mUnitData.GetSelectedSkin(Array.FindIndex <JobData>(this.mUnitData.Jobs, (Predicate <JobData>)(j => j.Param.iname == this.mJobID)));
                    str = selectedSkin == null ? (string)null : selectedSkin.asset;
                }
                if (string.IsNullOrEmpty(str))
                {
                    str = this.mJobResourceID;
                }
                int jobIndex = -1;
                for (int index = 0; index < character.Jobs.Count; ++index)
                {
                    if (character.Jobs[index].JobID == str)
                    {
                        jobIndex = index;
                        break;
                    }
                }
                if (jobIndex < 0)
                {
                    jobIndex = 0;
                }
                this.StartCoroutine(this.AsyncSetup(character, jobIndex));
            }
        }
Exemplo n.º 6
0
 public static CharacterDB.Job FindCharacter(string characterID, string jobResourceID)
 {
     CharacterDB.Character character = CharacterDB.FindCharacter(characterID);
     if (character == null)
     {
         return((CharacterDB.Job)null);
     }
     if (string.IsNullOrEmpty(jobResourceID))
     {
         jobResourceID = "none";
     }
     for (int index = 0; index < character.Jobs.Count; ++index)
     {
         if (character.Jobs[index].JobID == jobResourceID)
         {
             return(character.Jobs[index]);
         }
     }
     return(character.Jobs[0]);
 }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
 public static void ReloadDatabase()
 {
     CharacterDB.UnloadAll();
     CharacterDB.LoadDatabase();
 }
Exemplo n.º 9
0
        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);
                        }
                    }
                }
            }
        }