Ejemplo n.º 1
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data         = param[0] as CommandParam;
            bool         isContentSet = true;
            bool         isTermSet    = true;
            bool         isSpriteSet  = true;
            bool         isVoiceSet   = true;

            if (data.option != null)
            {
                isContentSet = data.option.sayText;
                isTermSet    = data.option.sayTerm;
                isSpriteSet  = data.option.saySprite;
                isVoiceSet   = data.option.sayVoice;
            }

            if (isTermSet)   //if(data.iconDisplay.StartsWith("Hide"))
            {
                this.overrideTerm = data.name;
                if (string.IsNullOrEmpty(data.name))
                {
                    showIcon = false;
                }
            }
            if (isContentSet)
            {
                if (data.locText.Count > 0)
                {
                    this.storyText = data.locText[0].content;
                }

                csvCommandKey = data.keys;
            }

            if (isVoiceSet)
            {
                AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();
                if (ADVKeys != null)
                {
                    if (!string.IsNullOrEmpty(data.arg2))
                    {
                        voiceOverClip = ADVKeys.GetVoiceByKey(data.arg2);
                        if (voiceOverClip == null)
                        {
                            Debug.Log("找不到Voice檔:" + data.arg2 + " , 於 行數 " + (this.itemId - 3));
                        }
                    }
                }
            }

            if (isSpriteSet)
            {
                AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();
                if (ADVKeys != null)
                {
                    if (!string.IsNullOrEmpty(data.image))
                    {
                        string[] tempSplit = data.image.Split('&');
                        data.image = tempSplit[0];

                        portraitEquip.Clear();
                        if (tempSplit.Length > 1)
                        {
                            for (int i = 1; i < tempSplit.Length; i++)
                            {
                                portraitEquip.Add(tempSplit[i]);
                            }
                        }

                        //從AdvKey 取得 Sprite 資源
                        portrait = ADVKeys.GetAvatarByKey(data.image);
                        //如果有填Key 但又找不到的話
                        if (portrait == null && !string.IsNullOrEmpty(data.image))
                        {
                            Debug.Log("找不到Avatar檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                            #if UNITY_EDITOR
                            portrait = AdvEditorConfig.Instance.DefaultSprite;
                            #endif
                        }
                        else
                        {
                            //順利找到圖的話, 記錄這張圖進字典
                            spriteHistoryEditor[data.name] = portrait;
                        }
                    }
                    //沒填 Portrait Name,可能是沿用圖檔, 需確認是否有填姓名
                    else
                    {
                        if (!string.IsNullOrEmpty(data.name))
                        {
                            if (spriteHistoryEditor.ContainsKey(data.name))
                            {
                                portrait = spriteHistoryEditor[data.name];
                            }
                        }
                    }
                }
            }



            /* Reading Text File
             * this.storyText  = param[0].ToString();
             * if(param[1].ToString() != ""){
             *  Character _character = GameObject.Find(param[1].ToString()).GetComponent<Character>();
             *  if(_character != null){
             *      character = _character;
             *  }
             * }
             * if(param[2].ToString() != ""){
             *  if(character != null){
             *      portrait = character.GetPortrait(param[2].ToString());
             *  }
             * }
             */

            //舊版本, 需設置Character來驅動 Say

            /*
             * Character targetCharacter = null;
             * //this area is for Simple Talk System , it can pass data.content
             * if(data.content != null){
             *  //Find Character by Content
             *  foreach (var item in Character.ActiveCharacters)
             *  {
             *      if(item.charactorContent == data.content){
             *          targetCharacter = item;
             *      }
             *  }
             *  //Otherwise, Create Character GameObject
             *  if(targetCharacter == null){
             *      targetCharacter = new GameObject(data.content.nameText).AddComponent<Character>();
             *      targetCharacter.charactorContent = data.content;
             *      targetCharacter.SetDataByContent();
             *  }
             * } else if(data.characterName != ""){
             *  //Find Character by name
             *  foreach (var item in Character.ActiveCharacters)
             *  {
             *      if(item.charactorContent != null){
             *          if(item.charactorContent.nameText == data.characterName){
             *              targetCharacter = item;
             *          }
             *      } else if(item.NameText == data.characterName){
             *          targetCharacter = item;
             *      }
             *  }
             *  //Otherwise, Create Character GameObject
             *  if(targetCharacter == null){
             *      targetCharacter = new GameObject(data.characterName).AddComponent<Character>();
             *      targetCharacter.SetStandardText(data.characterName);
             *      Debug.LogWarning("Character Data is Created by default, need to Assign Character Content");
             *  }
             * }
             * //Assign Character Data
             * character = targetCharacter;
             *
             * //驅動 Portrait 內容
             * if(data.portrait != null){
             *  portrait = data.portrait;
             * } else if(data.portraitName != "" && character != null) {
             *  portrait = character.GetPortrait(data.portraitName);
             * }
             */
        }
Ejemplo n.º 2
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data = param[0] as CommandParam;

            Sprite           _sprite = null;
            DicedSpriteAtlas _atlas;
            DicedSprite      _diceSprite = null;

            AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();

            if (ADVKeys != null)
            {
                //尋找立繪圖區(DiceAtlas)
                _atlas = ADVKeys.GetDiceAtlasByKey(data.image);
                if (_atlas != null)
                {
                    spriteAtlas = _atlas;
                    _diceSprite = ADVKeys.GetDiceBillboardByKeyContain("Normal", _atlas);

                    if (_diceSprite == null)
                    {
                        AdvUtility.LogWarning("找不到Billboard檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                        if (Application.isPlaying)
                        {
                            //_diceSprite = FungusExtendEditorConfig.Instance.DefaultDiceSprite;
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(data.image))
                {
                    //可能是使用怪物圖
                    _sprite = ADVKeys.GetEnemyByKey(data.image);

                    if (_sprite == null)
                    {
                        AdvUtility.LogWarning("找不到Billboard檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                        if (Application.isPlaying)
                        {
                            //_diceSprite = AdvManager.Instance.DefaultDiceSprite;
                        }
                    }
                }

                /*
                 * _diceSprite = ADVKeys.GetDiceBillboardByKey(data.billboardKey);  // ex: Lica_Normal
                 * if(_diceSprite == null && !string.IsNullOrEmpty(data.billboardKey)) {
                 *  AdvUtility.LogWarning("找不到Billboard檔:" + data.billboardKey + " , 於 行數 " + (this.itemId - 3));
                 *  _diceSprite = AdvManager.Instance.DefaultDiceSprite;
                 * }
                 */

                /* // 舊版 UI 型 立繪
                 * //尋找立繪圖區
                 * _sprite = ADVKeys.GetBillboardByKey(data.billboardKey);
                 * if(_sprite == null){
                 * //可能使用怪物圖區,尋找怪物圖區
                 *  _sprite = ADVKeys.GetEnemyByKey(data.billboardKey);
                 * }
                 * //兩者皆沒有,替換為香菇
                 * if(_sprite == null && !string.IsNullOrEmpty(data.billboardKey)){
                 *
                 *  AdvUtility.LogWarning("找不到Billboard檔:" + data.billboardKey + " , 於 行數 " + (this.itemId - 3));
                 *  _sprite = AdvManager.Instance.DefaultSprite;
                 * }
                 */
            }

            spriteBillboard        = _sprite;
            spriteDynamicBillboard = _diceSprite;
            display        = StageExtend.GetDisplayTypeByCommand(data.command);
            spriteDistance = StageExtend.GetBbDistanceByString(data.arg1);
            toPosition     = StageExtend.GetBbPositionByString(data.target);
            hideWhich      = StageExtend.GetBbHideByString(data.target);
            //flipFace = flipFace;
            useDefaultSettings = true;
            //fadeDuration = fadeDuration;
            //moveDuration = moveDuration;
            //shiftOffset = shiftOffset;
            //move = move;
            //shiftIntoPlace = shiftIntoPlace;
            //waitUntilFinished = waitUntilFinished;
        }