示例#1
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data = param[0] as CommandParam;

            AdvKeyContent bgKeys = AdvKeyContent.GetCurrentInstance();

            if (string.Equals(data.command, "CgOff", System.StringComparison.OrdinalIgnoreCase))
            {
                display = BackgroundDisplayType.HideAll;
                return;
            }
            if (bgKeys != null)
            {
                spriteCG = bgKeys.GetDiceCGByKey(data.image);
                if (spriteCG == null)
                {
                    if (!string.IsNullOrEmpty(data.image))
                    {
                        AdvUtility.LogWarning("找不到CG檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                    }
                }
                else
                {
                    atlasCG = spriteCG.AtlasAsset;
                }
            }
        }
示例#2
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data = param[0] as CommandParam;

            AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();

            if (ADVKeys != null)
            {
                if (!string.IsNullOrEmpty(data.image))
                {
                    musicClip = ADVKeys.GetBGMByKey(data.image);
                }
            }
        }
示例#3
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data = param[0] as CommandParam;

            UIBillboardController _prefab = null;

            AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();

            if (ADVKeys != null)
            {
                _prefab = ADVKeys.GetBillboardPrefabByKey(data.image);
                if (_prefab != null)
                {
                    if (!string.IsNullOrEmpty(data.name))
                    {
                        useBody = data.name;
                    }

                    if (!string.IsNullOrEmpty(data.arg2))
                    {
                        string[] splite = data.arg2.Split('|');
                        useEquips = new List <string>();
                        foreach (var item in splite)
                        {
                            useEquips.Add(item);
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(data.image))
                {
                    AdvUtility.LogWarning("找不到Billboard prefab檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                    if (Application.isPlaying)
                    {
                        //_diceSprite = AdvManager.Instance.DefaultDiceSprite;
                    }
                }
            }

            targetPrefab       = _prefab;
            display            = StageExtend.GetDisplayTypeByCommand(data.command);
            spriteDistance     = StageExtend.GetBbDistanceByString(data.arg1);
            toPosition         = StageExtend.GetBbPositionByString(data.target);
            hideWhich          = StageExtend.GetBbHideByString(data.target);
            useDefaultSettings = true;
        }
示例#4
0
        public void InitializeByParams(object[] param)
        {
            CommandParam data = param[0] as CommandParam;

            AdvKeyContent bgKeys = AdvKeyContent.GetCurrentInstance();

            if (bgKeys != null)
            {
                spriteBackground = bgKeys.GetBackgroundByKey(data.image);
                if (spriteBackground == null && !string.IsNullOrEmpty(data.image))
                {
                    AdvUtility.LogWarning("找不到BG檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                }
            }
            if (data.command == "BgOff")
            {
                display = BackgroundDisplayType.HideAll;
            }
        }
示例#5
0
        public void InitializeByParams(object[] param)
        {
            FungusExt.CommandParam data = param[0] as FungusExt.CommandParam;
            this._inSceneTarget = AdvUtility.GetAdvTargetObjectByString(data.target);

            AdvKeyContent ADVKeys = AdvKeyContent.GetCurrentInstance();

            if (ADVKeys != null)
            {
                if (!string.IsNullOrEmpty(data.image))
                {
                    //從AdvKey 取得 Asset 資源
                    this.timelineAsset = ADVKeys.GetTimelineByKey(data.image);

                    //如果有填Key 但又找不到的話
                    if (this.timelineAsset == null)
                    {
                        AdvUtility.LogWarning("找不到Timeline檔:" + data.image + " , 於 行數 " + (this.itemId - 3));
                    }
                }
            }
        }
示例#6
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);
             * }
             */
        }
示例#7
0
    //主要CSV 讀入部分
    public static void CreateBlockByCSV(FlowchartExtend srcFlowchart, string csvFile, bool inEditor)
    {
        //讀入 CSV 檔案,使其分為 string 二維陣列
        CsvParser csvParser = new CsvParser();

        string[][] csvTable = csvParser.Parse(csvFile);

        //判斷CSV 檔案 有無內容
        if (csvTable.Length <= 1)
        {
            AdvUtility.Log("No data rows in file");
            return;
        }

        //搜尋開頭字串正不正確
        int id_key     = Array.IndexOf(csvTable[0], AdvUtility.TitleKeys);
        int id_command = Array.IndexOf(csvTable[0], AdvUtility.TitleCommand);
        int id_target  = Array.IndexOf(csvTable[0], AdvUtility.TitleTarget);
        int id_arg1    = Array.IndexOf(csvTable[0], AdvUtility.TitleArg1);
        int id_arg2    = Array.IndexOf(csvTable[0], AdvUtility.TitleArg2);
        int id_image   = Array.IndexOf(csvTable[0], AdvUtility.TitleImage);
        int id_name    = Array.IndexOf(csvTable[0], AdvUtility.TitleName);

        //判斷CSV 檔案格式正不正確
        if (id_command == -1)
        {
            AdvUtility.LogWarning("確認 CSV 是否為逗號分隔 (?");
            LogBox("確認 CSV 檔案是否為逗號分隔 (? ");
            return;
        }
        if (id_key == -1 || id_command == -1 || id_target == -1)
        {
            AdvUtility.LogWarning("CSV 檔案沒有正確的開頭資訊 (Keys, Command, Target, Arg1, Arg2, Content_zh-tw)");
            return;
        }

        //至此 CSV檔案正常
        srcFlowchart.csvBackup = csvFile;

        if (AdvKeyContent.GetCurrentInstance() == null)
        {
            AdvUtility.LogWarning("Adv Keys 尚未初始化! 資源讀取將會失敗!");
        }

        if (srcFlowchart.AutoGenerateBlock != null)
        {
            AdvUtility.LogWarning("該Block 已經使用過Create指令, 將清除並重新Create!");
        }

        foreach (var comp in srcFlowchart.GetComponents <Component>())
        {
            if (!(comp is Transform) && !(comp is FlowchartExtend))
            {
                MonoBehaviour.DestroyImmediate(comp, true);
            }
        }

        //視覺化建立的 Block 的位置
        Vector2 newNodePosition = Vector2.zero;

        newNodePosition = new Vector2(
            50 / srcFlowchart.Zoom - srcFlowchart.ScrollPos.x + UnityEngine.Random.Range(-10.0f, 10.0f),
            50 / srcFlowchart.Zoom - srcFlowchart.ScrollPos.y + UnityEngine.Random.Range(-10.0f, 10.0f)
            );
        newNodePosition = GetNewBlockPosition(ref newNodePosition, new Vector2(50, 50));

        //1. 儲存Block 資訊用於CSV架構
        //2. SearchHandler為搜尋Block標籤用的事件,當新Block建立時,觸發事件去找該Block是不是該Command要找的Block
        Dictionary <string, Block> blockTree     = new Dictionary <string, Block>();
        SearchBlockHandler         searchHandler = new SearchBlockHandler();

        //建立入口Block
        Block baseBlock = srcFlowchart.CreateBlock(newNodePosition);

        srcFlowchart.AutoGenerateBlock = baseBlock;                       //Main Block 設置完成
        baseBlock.BlockName            = AdvUtility.CSVImportedBlockName; //Main Block 名稱設置為 Main
        blockTree.Add(baseBlock.BlockName, baseBlock);

        //第一行指令設置為 建立入口用
        Call Entrance = AddCommandToBlock(srcFlowchart, baseBlock, GetTypeOfCommand("CallExtend")) as Call;

        //1. 正在添加的Block
        //2. 該Command 對應的背景, 用於跳場景用
        Block             workBlock      = baseBlock;
        ControlBackground workBackground = null;

        srcFlowchart.csvLines = new List <AdvCSVLine>();                 //重置 CSV Lines , 這樣的設置前提是每個 Flowchart只匯入一個 CSV

        LogBox("初始化完畢...");

        //針對每一行CSV做處理
        for (int i = 1; i < csvTable.Length; i++)
        {
            //建立新的CSV Line, 讀入該Line資料進去
            AdvCSVLine thisLine = new AdvCSVLine(csvTable[0], csvTable[i]);
            //加入該CSV Line 進入 flowchart CSVLine 集合
            srcFlowchart.csvLines.Add(thisLine);

            string srcCommand = csvTable[i][id_command];
            bool   comResult  = false;

            //如果Command是*記錄點,建立Block,否則建立Command
            if (srcCommand.StartsWith("*"))
            {
                comResult = true;
                string _name = srcCommand;
                workBlock           = srcFlowchart.CreateBlock(GetNewBlockPosition(ref newNodePosition, new Vector2(150, 50)));
                workBlock.BlockName = _name;
                blockTree.Add(workBlock.BlockName, workBlock);
                thisLine.generateBlock = workBlock;
                searchHandler.createBlockEvent?.Invoke(workBlock);
            }
            else
            {
                Command newCommand = CreateCommand(srcFlowchart, workBlock, csvTable[0], csvTable[i], searchHandler);
                if (newCommand != null)
                {
                    comResult = true;
                    SetupCommand(srcFlowchart, newCommand, i, csvTable[i][id_key]);

                    //設置flowchart中,CSVLine表key值對應的Command , 用於更新資料
                    thisLine.generatedCommand = newCommand;

                    //如果指令是背景, 設置切入劇情時的背景
                    if (newCommand.GetType() == typeof(ControlBackground))
                    {
                        workBackground = newCommand as ControlBackground;
                    }
                }
            }

            if (comResult == false)
            {
                LogBox("讀取第 " + i + " 行指令 失敗 , 指令碼(Command)錯誤");
            }
            else
            {
                LogBox("讀取第 " + i + " 行指令 成功");
            }
        }
        LogBox("文本讀取完畢!");
    }
示例#8
0
    public static List <AdvCSVLine> UpdateBlockByCSV(FlowchartExtend srcFlowchart, string csvFile, AdvUpdateOption advOption, bool inEditor)
    {
        //讀入 CSV 檔案,使其分為 string 二維陣列
        CsvParser csvParser = new CsvParser();

        string[][] csvTable = csvParser.Parse(csvFile);

        //判斷CSV 檔案 有無內容
        if (csvTable.Length <= 1)
        {
            AdvUtility.Log("No data rows in file");
            return(null);
        }

        //搜尋開頭字串正不正確
        int id_key     = Array.IndexOf(csvTable[0], AdvUtility.TitleKeys);
        int id_command = Array.IndexOf(csvTable[0], AdvUtility.TitleCommand);
        int id_target  = Array.IndexOf(csvTable[0], AdvUtility.TitleTarget);
        int id_arg1    = Array.IndexOf(csvTable[0], AdvUtility.TitleArg1);
        int id_arg2    = Array.IndexOf(csvTable[0], AdvUtility.TitleArg2);
        int id_image   = Array.IndexOf(csvTable[0], AdvUtility.TitleImage);
        int id_name    = Array.IndexOf(csvTable[0], AdvUtility.TitleName);

        //判斷CSV 檔案格式正不正確
        if (id_command == -1)
        {
            AdvUtility.LogWarning("確認 CSV 是否為逗號分隔 (?");
            LogBox("確認 CSV 檔案是否為逗號分隔 (? ");
            return(null);
        }
        if (id_key == -1 || id_command == -1 || id_target == -1 || csvTable[0].Length <= CSVLanguageDataStart)
        {
            AdvUtility.LogWarning("CSV 檔案沒有正確的開頭資訊 (Keys, Command, Target, Arg1, Arg2, Text)");
            return(null);
        }
        //至此 CSV檔案正常
        srcFlowchart.csvBackup = csvFile;

        if (AdvKeyContent.GetCurrentInstance() == null)
        {
            AdvUtility.LogWarning("Adv Keys 尚未初始化! 資源讀取將會失敗!");
        }

        if (advOption == null)
        {
            advOption = new AdvUpdateOption();
        }

        SearchBlockHandler searchHandler  = new SearchBlockHandler();
        ControlBackground  workBackground = null;
        Block srcBlock    = srcFlowchart.MainBlock;
        int   srcCmdIndex = 0;

        SetCSVLineReadyToUpdate(srcFlowchart.csvLines);

        //針對每一行CSV做更新
        for (int i = 1; i < csvTable.Length; i++)
        {
            //取出Command 以及 Key
            string srcCommandString = csvTable[i][id_command];
            string cmdKey           = csvTable[i][id_key];

            //建立新的CSVLine
            AdvCSVLine newLine = new AdvCSVLine(csvTable[0], csvTable[i]);

            //尋找舊的CSVLine
            AdvCSVLine oldLine = SearchLineByKey(srcFlowchart.csvLines, cmdKey);

            //若CSV Line中具有該key
            if (oldLine != null)
            {
                //從Key提取 Command , 設置該 Command 所在 Block
                //2019.7.25 有可能這個Command 已經被編劇砍掉了,所以回傳null,但CSVLine 還保留著這個 Reference
                Command srcCmd = oldLine.generatedCommand;

                //如果是*Block CSVLine, 則不會有 Command
                if (srcCmd != null)
                {
                    //這邊的動作是為了追蹤已經到哪個Block,哪個Line, 使得新指令能夠依賴此資訊插入
                    //srcBlock = srcCmd.ParentBlock; // Fungus 的 ParentBlock 為 Property
                    srcBlock = FindParentBlock(srcFlowchart, srcCmd);
                    if (srcBlock == null)
                    {
                        //Fungus 的 ParentBlock 為 Property , 這是不可序列化的, 因此只限定於開啟prefab時, 此值才能運作
                        AdvUtility.LogError("更新失敗, 嘗試跳出Prefab 視窗後,重新進入Prefab");
                        throw new NullReferenceException("更新失敗, 嘗試跳出Prefab 視窗後,重新進入Prefab");
                    }
                    srcCmdIndex = srcBlock.CommandList.FindIndex(x => x == srcCmd);
                }

                //更新targetLine (AdvCSVLine)資料 , 但僅止於CSVLine資料更新, 實際Prefab 要不要動還是以參數為主
                newLine.generatedCommand = srcCmd;
                ReplaceLine(srcFlowchart.csvLines, oldLine, newLine);

                CmdResult cmdResult     = CmdResult.Error;
                string    ResultMessage = "";

                //在該Key中,如果Cmd值相同,則更新資料,(不同則新增資料 待製作)
                if (String.Equals(oldLine.Command, newLine.Command, StringComparison.OrdinalIgnoreCase))
                {
                    if (srcCommandString.StartsWith("*"))
                    {
                        //以新Block 為基準工作
                        if (oldLine.generateBlock != null)
                        {
                            srcBlock    = oldLine.generateBlock;
                            srcCmdIndex = -1;
                        }
                        else
                        {
                            //以舊Key 來補救 舊Key 無 Cmd資訊
                            string _oldName  = oldLine.Command;
                            Block  workBlock = srcFlowchart.FindBlock(_oldName);
                            if (workBlock != null)
                            {
                                srcBlock    = workBlock;
                                srcCmdIndex = -1;

                                newLine.generateBlock = srcBlock;
                                cmdResult             = CmdResult.Success;
                                AdvUtility.Log("> 以舊Key 更新 GenerateBlock");
                            }
                        }
                        newLine.generateBlock = srcBlock;

                        if (advOption.blockName)
                        {
                            cmdResult = CmdResult.Success;
                        }
                        else
                        {
                            cmdResult = CmdResult.Ignore;
                        }
                    }
                    else
                    {
                        //確保這個 Command 沒被編劇砍掉 才執行
                        if (srcCmd != null)
                        {
                            cmdResult = SetCommandPara(srcCmd, csvTable[0], csvTable[i], advOption, searchHandler);
                            //更新command中的 CSVLine, Key
                            SetupCommand(srcFlowchart, srcCmd, i, cmdKey);
                            //如果指令是背景, 設置切入劇情時的背景
                            if (srcCmd.GetType() == typeof(ControlBackground))
                            {
                                workBackground = srcCmd as ControlBackground;
                            }
                        }
                        else
                        {
                            ResultMessage += $"該 command ({oldLine.Command}) 已於flowchart中刪除\n";
                        }
                    }
                }
                else
                {
                    //不同Command 可能是 Block 不同
                    if (srcCommandString.StartsWith("*"))
                    {
                        Block oldBlock = oldLine.generateBlock;
                        if (oldBlock != null)
                        {
                            //以新Block 為基準工作
                            srcBlock    = oldLine.generateBlock;
                            srcCmdIndex = -1;

                            newLine.generateBlock = srcBlock;

                            if (advOption.blockName)
                            {
                                srcBlock.BlockName = srcCommandString;
                                searchHandler.createBlockEvent?.Invoke(srcBlock);
                                cmdResult = CmdResult.Success;
                            }
                            else
                            {
                                cmdResult = CmdResult.Ignore;
                            }
                        }
                        else
                        {
                            AdvUtility.Log("> 舊Key 不包含 Block 資訊 , 嘗試以舊 Name 找 Block");

                            //允許不同, 執行以下 Block 命名相關指令, 記錄點,建立Block
                            string _oldName  = oldLine.Command;
                            string _newName  = srcCommandString;
                            Block  workBlock = srcFlowchart.FindBlock(_oldName);
                            //AdvUtility.Log("尋找Block:" + _oldName + " ,  結果 :" + workBlock);
                            if (workBlock != null)
                            {
                                //以新Block 為基準工作
                                srcBlock    = workBlock;
                                srcCmdIndex = -1;

                                newLine.generateBlock = srcBlock;

                                if (advOption.blockName)
                                {
                                    workBlock.BlockName = _newName;
                                    searchHandler.createBlockEvent?.Invoke(workBlock);
                                    //AdvUtility.Log("啟動 Invoke");
                                    cmdResult = CmdResult.Success;
                                }
                                else
                                {
                                    cmdResult = CmdResult.Ignore;
                                }
                            }
                            else
                            {
                                AdvUtility.Log("> 無法找到舊Block 名稱 : " + _oldName);
                            }
                        }
                    }
                    else
                    {
                        //不處理不同Cmd的情況
                        ResultMessage += $"來源與目標的 Command 類型不同 , 放棄更新 {oldLine.Command} != {newLine.Command}\n";
                    }
                }

                if (cmdResult == CmdResult.Error)
                {
                    AdvUtility.Log("> 更新指令 from key:" + cmdKey + " >> <color=red>失敗</color> (" + srcFlowchart.GetName() + ") >> " + ResultMessage);
                }
                //else if(cmdResult == CmdResult.Success)
                //    AdvUtility.Log("> 更新指令 from key:" + cmdKey + " 成功 (" + srcFlowchart.GetName() + ")");
            }
            else
            {
                //如果沒有該Key, 則新增資料
                AdvUtility.Log("> <color=magenta>找不到Key值:" + cmdKey + " , 因此建立新指令</color>");
                bool cmdResult = false;

                if (srcCommandString.StartsWith("*"))
                {
                    cmdResult = true;
                    string  _name       = srcCommandString;
                    Vector2 newPosition = new Vector2(srcBlock._NodeRect.x, srcBlock._NodeRect.y);
                    srcBlock    = srcFlowchart.CreateBlock(newPosition + new Vector2(100, 75));
                    srcCmdIndex = -1;

                    srcBlock.BlockName = _name;

                    newLine.generateBlock = srcBlock;
                    srcFlowchart.csvLines.Add(newLine);
                    searchHandler.createBlockEvent?.Invoke(srcBlock);
                }
                else
                {
                    //## Command 會接在Block最後面,因此需要調換位置
                    Command newCommand = CreateCommand(srcFlowchart, srcBlock, csvTable[0], csvTable[i], searchHandler);
                    if (newCommand != null)
                    {
                        cmdResult = true;
                        SetupCommand(srcFlowchart, newCommand, i, cmdKey);

                        //## 需要調換Command位置
                        srcBlock.CommandList.RemoveAt(srcBlock.CommandList.Count - 1);
                        srcBlock.CommandList.Insert(srcCmdIndex + 1, newCommand);
                        srcCmdIndex = srcCmdIndex + 1;

                        //設置flowchart中,CSVLine表key值對應的Command , 用於更新資料
                        newLine.generatedCommand = newCommand;
                        srcFlowchart.csvLines.Add(newLine);

                        //如果指令是背景, 設置切入劇情時的背景
                        if (newCommand.GetType() == typeof(ControlBackground))
                        {
                            workBackground = newCommand as ControlBackground;
                        }
                    }
                }

                if (cmdResult == false)
                {
                    AdvUtility.Log("> 更新指令 from key:" + cmdKey + " >> <color=red>失敗</color> (" + srcFlowchart.GetName() + ")");
                }
                //else
                //    AdvUtility.Log("> 更新指令 from key:" + cmdKey + " 成功 (" + srcFlowchart.GetName() + ")");
            }
        }

        AdvUtility.Log("> 更新指令 順利結束");

        List <AdvCSVLine> outdate = GetCSVLineNeverUpdate(srcFlowchart.csvLines);

        return(outdate);
    }
示例#9
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;
        }
示例#10
0
        // Update is called once per frame
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            BillboardPrefab t = target as BillboardPrefab;

            if (shouldUpdatePrefab == true)
            {
                shouldUpdatePrefab = false;

                if (t._TargetPrefab != null)
                {
                    listEmoji = t._TargetPrefab.GetEmojiListString().ToArray();
                    listBody  = t._TargetPrefab.GetBodyListString().ToArray();
                    listEquip = t._TargetPrefab.GetEquipListString().ToArray();
                }
                else
                {
                    listEmoji = new string[] {}
                };
            }

            EditorGUILayout.PropertyField(displayProp);
            if (t._Display != DisplayType.None)
            {
                if (t._Display != DisplayType.MoveToFront)
                {
                    if (t._Display != DisplayType.Hide)
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(targetPrefabProp, new GUIContent("角色立繪Prefab"));

                        if (AdvKeyContent.GetCurrentInstance().GroupBillboardPrefab != null)
                        {
                            CommandEditor.ObjectField <UIBillboardController>(targetPrefabProp,
                                                                              new GUIContent("In folder (Prefabs/ADV)", "Dynamic Emoji Prefab (UIBillboardController)"),
                                                                              new GUIContent("<None>"),
                                                                              AdvKeyContent.GetCurrentInstance().GroupBillboardPrefab);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            shouldUpdatePrefab = true;
                        }

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PropertyField(useEmojiProp, new GUIContent("使用表情"));
                        int emojiIndex = EditorGUILayout.Popup(emojiId, listEmoji, EditorStyles.popup);
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PropertyField(useBodyProp, new GUIContent("使用衣服"));
                        int bodyIndex = EditorGUILayout.Popup(bodyId, listBody, EditorStyles.popup);
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PropertyField(useEquipsProp, new GUIContent("使用裝備(我前面有箭頭)"), true);
                        int equipIndex = EditorGUILayout.Popup(equipId, listEquip, EditorStyles.popup);
                        EditorGUILayout.EndHorizontal();


                        if (emojiIndex != emojiId)
                        {
                            useEmojiProp.stringValue = listEmoji[emojiIndex];
                        }
                        if (bodyIndex != bodyId)
                        {
                            useBodyProp.stringValue = listBody[bodyIndex];
                        }
                        if (equipIndex != equipId)
                        {
                            t._UseEquips.Add(listEquip[equipIndex]);
                            EditorUtility.SetDirty(t);
                        }

                        EditorGUILayout.PropertyField(flipFaceProp, new GUIContent("水平翻轉 ?"));
                        EditorGUILayout.PropertyField(spriteDistanceProp, new GUIContent("立繪所在距離"));
                    }
                    if (t._Display == DisplayType.Hide)
                    {
                        EditorGUILayout.PropertyField(hideWhichProp, new GUIContent("隱藏哪個位置"));
                    }

                    if (t._Display == DisplayType.Show || t._Display == DisplayType.Replace || (t._Move && t._Display == DisplayType.Hide))
                    {
                        EditorGUILayout.PropertyField(toPositionProp, new GUIContent("目標位置"));
                        EditorGUILayout.PropertyField(positionShiftProp, new GUIContent("目標位置加上偏移"));
                        EditorGUILayout.PropertyField(positionShiftValueProp, new GUIContent("偏移倍數"));
                    }
                    EditorGUILayout.LabelField("-- 移動設定 --", EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(moveProp, new GUIContent("移動動畫 ?"));

                    if (t._Move)
                    {
                        if (!t._ShiftIntoPlace)
                        {
                            EditorGUILayout.PropertyField(fromPositionProp, new GUIContent("從哪個相對位置滑入"));
                        }
                    }


                    EditorGUILayout.PropertyField(useDefaultSettingsProp, new GUIContent("使用預設數值 ?"));

                    if (!t._UseDefaultSettings)
                    {
                        if (t._Move)
                        {
                            if (t._Display != DisplayType.Hide)
                            {
                                EditorGUILayout.PropertyField(shiftIntoPlaceProp, new GUIContent("從目標位置附近滑入?"));
                                if (t._ShiftIntoPlace)
                                {
                                    EditorGUILayout.PropertyField(shiftOffsetProp, new GUIContent("從哪邊滑入(偏移量)"));
                                }
                            }
                        }
                        EditorGUILayout.PropertyField(fadeDurationProp, new GUIContent("淡出 / 淡入時間"));
                        if (t._Move)
                        {
                            EditorGUILayout.PropertyField(moveDurationProp, new GUIContent("滑動時間"));
                        }
                    }

                    EditorGUILayout.PropertyField(waitUntilFinishedProp);
                }
                else
                {
                    EditorGUILayout.PropertyField(toPositionProp, new GUIContent("哪個位置"));
                }
            }

            //EditorGUILayout.PropertyField(serializedObject.FindProperty("myVariable"), new GUIContent("aDifferentLabel"));

            serializedObject.ApplyModifiedProperties();
        }
    }