Ejemplo n.º 1
0
    protected override void InitPrefabItem(object data)
    {
        content = data as QuestionInstance;
        if (content == null)
        {
            MyDebug.LogYellow("QuestionInstance is null!!");
            return;
        }
        Init();
        questionIndex.text = content.index + ".";
        int           count    = content.instance.Count;
        StringBuilder question = new StringBuilder();

        question.Append(content.instance[0].ToString());
        for (int i = 1; i < count - 2; i++)
        {
            question.Append(content.symbol);
            question.Append(content.instance[i].ToString());
        }
        question.Append("=");
        question.Append(content.instance[count - 1].ToString());
        questionContent.text = question.ToString();
        if (content.instance[count - 2] != content.instance[count - 1])
        {
            questionRightAnswerBg.SetActive(true);
            questionRightAnswer_Text.text = content.instance[count - 2].ToString();
            questionContent.color         = Color.red;
        }
    }
Ejemplo n.º 2
0
    public static GameObject GetGameObjectContainsName(GameObject root, string name)
    {
        GameObject result = null;

        if (root != null)
        {
            Transform[] objArray = root.GetComponentsInChildren <Transform>(true);
            if (objArray != null)
            {
                for (int i = 0; i < objArray.Length; i++)
                {
                    if (objArray[i].name.Contains(name))
                    {
                        result = objArray[i].gameObject;
                        break;
                    }
                }
            }
        }
        if (result == null)
        {
            MyDebug.LogYellow("Can not find :" + name);
        }
        return(result);
    }
Ejemplo n.º 3
0
    protected override void InitPrefabItem(object data)
    {
        content = data as AchievementInstance;
        if (content == null)
        {
            MyDebug.LogYellow("AchievementInstance is null!!");
            return;
        }

        Init();
        bool notHasAchievement = string.IsNullOrEmpty(content.finishTime);

        achievementName.text = LanguageController.Instance.GetLanguage(content.mainTitleIndex);
        achievementItem_WithoutAchievement.SetActive(notHasAchievement);
        if (!notHasAchievement)
        {
            achievementImage.sprite = SkinController.Instance.GetSprite(content.imageIndex);
        }
        List <GameObject> stars = CommonTool.GetGameObjectsContainName(gameObject, "Star");

        for (int i = 0; i < stars.Count; i++)
        {
            stars[i].SetActive((i + 1) <= content.star);
        }
    }
Ejemplo n.º 4
0
    public void CentralReceiveMessage(string address, string characteristic, byte[] bytes)
    {
        MyDebug.LogGreen("CentralReceiveMessage");

        BluetoothMessage msg = new BluetoothMessage(bytes);

        if (msg == null)
        {
            MyDebug.LogYellow("CentralReceiveMessage: Message is NULL!");
            return;
        }

        MyDebug.LogGreen("Index:" + msg.index + ", Result:" + msg.result + ", name:" + msg.name);

        if (msg.index == 0)
        {
            UnityEngine.Random.InitState(msg.result);
            GuiController.Instance.CompetitionGUI = GuiFrameID.BluetoothFrame;
            GuiController.Instance.SwitchWrapper(GuiFrameID.BluetoothFightFrame);
        }
        else
        {
            if (BLEReceiveMessage != null)
            {
                BLEReceiveMessage(msg);
            }
        }
    }
Ejemplo n.º 5
0
    public void DeleteAchievement(string achievementName, bool withAction = false)
    {
        if (!PlayerPrefs.HasKey(achievementName))
        {
            MyDebug.LogYellow("Wrong AchievementName!");
            return;
        }

        PlayerPrefs.DeleteKey(achievementName);
        PlayerPrefs.DeleteKey(achievementName + "Star");
        WriteFinishTime(achievementName, "", 0);

        string lastestAchievement = PlayerPrefs.GetString("LastestAchievement", "");

        if (lastestAchievement.Contains(achievementName))
        {
            lastestAchievement = lastestAchievement.Replace(achievementName + ",", "");
            PlayerPrefs.SetString("LastestAchievement", lastestAchievement);
        }

        if (withAction && OnAchievementDeleted != null)
        {
            OnAchievementDeleted();
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// GuiWrapper切换,有缩放动画
    /// </summary>
    /// <param name="targetID"></param>
    /// <param name="isIn"></param>
    public void SwitchWrapperWithScale(GuiFrameID targetID, bool isIn)
    {
        root.GetComponent <GraphicRaycaster>().enabled = false;
        Object reource = GetGuiResource(targetID);

        if (reource == null)
        {
            MyDebug.LogYellow("Can not load reousce: " + targetID.ToString());
            return;
        }
        GameObject targetWrapper = Object.Instantiate(reource, root.transform) as GameObject;

        if (isIn)
        {
            targetWrapper.transform.DOScale(Vector3.zero, TweenDuration).
            From().
            SetEase(Ease.OutQuint).
            OnComplete(() => TweenComplete(targetWrapper));
        }
        else
        {
            targetWrapper.transform.SetAsFirstSibling();
            GuiFrameWrapper topGui = null;
            if (guiFrameStack.Count > 0)
            {
                topGui = guiFrameStack.Peek();
            }
            if (topGui)
            {
                topGui.transform.DOScale(Vector3.zero, TweenDuration).
                SetEase(Ease.OutQuint).
                OnComplete(() => TweenComplete(targetWrapper));
            }
        }
    }
Ejemplo n.º 7
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);

        switch (btn.name)
        {
        case "WeChatBtn":
            ShareImage(PlatformType.WeChat);
            break;

        case "WeChatMomentsBtn":
            ShareImage(PlatformType.WeChatMoments);
            break;

        case "SinaWeiboBtn":
            ShareImage(PlatformType.SinaWeibo);
            break;

        case "ShareFrameBg":
            shareBtnsBg.DOMoveY(endPos, duration, true);
            CommonTool.GuiScale(sharePage.gameObject, canvasGroup, false, () => GuiController.Instance.SwitchWrapper(GuiFrameID.None));
            break;

        case "AchievementDetailBtn":
            AchievementInstance instance = AchievementController.Instance.CurAchievementInstance;
            RecordController.Instance.CurSaveFileInstance = RecordController.Instance.ReadRecord(instance.finishTime);
            GuiController.Instance.SwitchWrapper(GuiFrameID.SaveFileFrame, true);
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 8
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);
        switch (btn.name)
        {
        case "ConfirmBtn":
            if (instance.confirmAction != null)
            {
                instance.confirmAction();
            }
            GuiController.Instance.SwitchWrapper(GuiFrameID.None);
            break;

        case "CancelBtn":
            if (instance.cancelAction != null)
            {
                instance.cancelAction();
            }
            GuiController.Instance.SwitchWrapper(GuiFrameID.None);
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 9
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);
        switch (btn.name)
        {
        case "Rank2StartFrameBtn":
        case "RankData2StartFrameBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.StartFrame, false);
            break;

        case "RankDataBtn":
            if (isDownloading)
            {
                return;
            }
            isDownloading = true;
            curInstance   = new CategoryInstance(curPatternID, curAmountID, curSymbolID, curDigitID, curOperandID);
            GameManager.Instance.DownloadRecord(curInstance, OnDownloadSucceed, OnDownloadFail);
            break;

        case "RankData2RankFrameBtn":
            CommonTool.GuiHorizontalMove(rankDataContent, Screen.width, MoveID.RightOrUp, canvasGroup, false);
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 刷新toggles的排列位置
    /// </summary>
    /// <param name="toggleGroup"></param>
    /// <param name="togglesAnchoredPositon"></param>
    /// <param name="curID"></param>
    private void RefreshToggleGroup(ToggleGroup toggleGroup, List <Vector2> togglesAnchoredPositon, int curID)
    {
        if (!toggleGroup)
        {
            MyDebug.LogYellow("toggleGroup is null!");
            return;
        }
        if (togglesAnchoredPositon == null || togglesAnchoredPositon.Count == 0)
        {
            MyDebug.LogYellow("togglesAnchoredPositon NO data!");
            return;
        }

        toggleGroup.SetAllTogglesOff();
        List <Vector2> tempTogglesAnchoredPositon = new List <Vector2>(togglesAnchoredPositon);
        Vector2        curToggleAnchoredPositon   = tempTogglesAnchoredPositon[0];

        tempTogglesAnchoredPositon.RemoveAt(0);
        tempTogglesAnchoredPositon.Insert(curID, curToggleAnchoredPositon);
        for (int i = 0; i < toggleGroup.toggles.Count; i++)
        {
            RectTransform toggleRectTransform = toggleGroup.toggles[i].transform as RectTransform;
            toggleRectTransform.anchoredPosition = tempTogglesAnchoredPositon[i];
        }
        toggleGroup.toggles[curID].isOn = true;
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 将streaming path 下的文件copy到对应用
    /// 为什么不直接用io函数拷贝,原因在于streaming目录不支持,
    /// 不管理是用getStreamingPath_for_www,还是Application.streamingAssetsPath,
    /// io方法都会说文件不存在
    /// </summary>
    /// <param name="fileName"></param>
    public static IEnumerator CopyImage(string fileName)
    {
        string desDir = Application.persistentDataPath + "/Image/";

        if (!Directory.Exists(desDir))
        {
            Directory.CreateDirectory(desDir);
        }
        string des = desDir + fileName;
        string src = GetStreamingPathForWWW() + "/Image/" + fileName;
        WWW    www = new WWW(src);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            MyDebug.LogYellow("www.error:" + www.error);
        }
        else
        {
            if (File.Exists(des))
            {
                File.Delete(des);
            }
            FileStream fsDes = File.Create(des);
            fsDes.Write(www.bytes, 0, www.bytes.Length);
            fsDes.Flush();
            fsDes.Close();
        }
        www.Dispose();
    }
Ejemplo n.º 12
0
    protected override void OnDropdownClick(Dropdown dpd)
    {
        base.OnDropdownClick(dpd);
        switch (dpd.name)
        {
        case "PatternDropdown":
        case "OperandDropdown":
            break;

        case "AmountDropdown":
            curAmountID = (AmountID)dpd.value;
            break;

        case "SymbolDropdown":
            curSymbolID = (SymbolID)dpd.value;
            RefreshDigitDropdown(dpd.value);
            break;

        case "DigitDropdown":
            curDigitID = (DigitID)(dpd.value + delta);
            break;

        default:
            MyDebug.LogYellow("Can not find Dropdown: " + dpd.name);
            break;
        }
    }
Ejemplo n.º 13
0
    public static void AssetsDefaultPrefab()
    {
        string spriteDir = Application.dataPath + "/Resources/Skin/Default";

        if (!Directory.Exists(spriteDir))
        {
            Directory.CreateDirectory(spriteDir);
        }

        for (int i = 0; i < Selection.objects.Length; i++)
        {
            string path   = AssetDatabase.GetAssetPath(Selection.objects[i]);
            Sprite sprite = AssetDatabase.LoadAssetAtPath <Sprite>(path);
            if (!sprite)
            {
                MyDebug.LogYellow("Can not get SPRITE!");
                return;
            }
            GameObject go = new GameObject(sprite.name);
            go.AddComponent <SpriteRenderer>().sprite = sprite;
            string allPath = spriteDir + "/" + sprite.name + ".prefab";
            if (File.Exists(allPath))
            {
                File.Delete(allPath);
            }
            string prefabPath = allPath.Substring(allPath.IndexOf("Assets"));
            PrefabUtility.CreatePrefab(prefabPath, go);
            DestroyImmediate(go);
        }
    }
Ejemplo n.º 14
0
    private void ShowNextQuestion(bool isFirst)
    {
        if (result.Length <= 0 && !isFirst)
        {
            return;
        }

        if (result.Length > 0)//check
        {
            curInstance.Add(int.Parse(result.ToString()));
            resultList.Add(curInstance);
            if (pattern == "Number" && resultList.Count == amount)
            {
                FightOver();
                return;
            }
        }
        curInstance = FightController.Instance.GetQuestionInstance();
        if (curInstance == null)
        {
            MyDebug.LogYellow("curInstance is NULL!");
            FightOver();
        }
        question.Length = 0;
        question.Append(curInstance[0].ToString());
        for (int i = 1; i < curInstance.Count - 1; i++)
        {
            question.Append(symbol);
            question.Append(curInstance[i].ToString());
        }
        questionImg_Text.text = question.ToString();
        ClearResultText();
    }
Ejemplo n.º 15
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);
        switch (btn.name)
        {
        case "Category2StartFrameBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.StartFrame, false);
            break;

        case "Category2FightFrameBtn":
            CategoryInstance curCategoryInstance = new CategoryInstance(curPatternID, curAmountID, curSymbolID, curDigitID, curOperandID);
            GuiController.Instance.CompetitionGUI        = GuiFrameID.CategoryFrame;
            FightController.Instance.CurCategoryInstance = curCategoryInstance;
            GuiController.Instance.SwitchWrapper(GuiFrameID.FightFrame);
            break;

        //case "CategoryTipBtn":
        //case "CategoryTipBg":
        //case "CategoryTipPage":
        //    categoryTipBg.SetActive(!categoryTipBg.activeSelf);
        //    break;
        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 16
0
 public void ResetList()
 {
     if (CurCategoryInstance.symbolID == SymbolID.Division)
     {
         workList.Clear();
         DivisionDataBase divisionDataBase = dataBase.Find(x => x.digitID == CurCategoryInstance.digitID && x.operandID == CurCategoryInstance.operandID);
         if (divisionDataBase != null)
         {
             List <DivisionQuestionList> qList = divisionDataBase.questionList;
             for (int i = 0; i < qList.Count; i++)
             {
                 List <int> questionList = new List <int>();
                 for (int j = 0; j < qList[i].questionList.Count; j++)
                 {
                     questionList.Add(qList[i].questionList[j]);
                 }
                 workList.Add(questionList);
             }
         }
         else
         {
             MyDebug.LogYellow("divisionDataBase == null! digitID = " + CurCategoryInstance.digitID + ", operandID:" + CurCategoryInstance.operandID);
         }
     }
     else
     {
         checkList.Clear();
     }
 }
Ejemplo n.º 17
0
    protected override void OnDropdownClick(Dropdown dpd)
    {
        base.OnDropdownClick(dpd);
        switch (dpd.name)
        {
        case "LayoutDropdown":
            tempLayoutID = dpd.value;
            horizontalLayoutTipBg.SetActive((LayoutID)tempLayoutID == LayoutID.Horizontal && !firstInLayout);
            break;

        case "HandednessDropdown":
            tempHandednessID = dpd.value;
            break;

        case "KeyboardDropdown":
            tempKeyboardID = dpd.value;
            break;

        default:
            MyDebug.LogYellow("Can not find Dropdown:" + dpd.name);
            break;
        }
        RefreshLayoutSketch();
        layoutApplyBtn.interactable = true;
    }
Ejemplo n.º 18
0
    public void PeripheralReceiveMessage(string UUID, byte[] bytes)
    {
        MyDebug.LogGreen("PeripheralReceiveMessage");
        BluetoothMessage msg = new BluetoothMessage(bytes);

        if (msg == null)
        {
            MyDebug.LogYellow("PeripheralReceiveMessage: Message is NULL!");
            return;
        }

        MyDebug.LogGreen("Index:" + msg.index + ", Result:" + msg.result + ", name:" + msg.name);

        if (msg.index == 0)
        {
            UnityEngine.Random.InitState(msg.result);
            CurPeripheralInstance = new PeripheralInstance("", msg.name);
            SetSendMessageFunc(false);
            BLESendMessage(msg);
            GuiController.Instance.CompetitionGUI = GuiFrameID.BluetoothFrame;
            GuiController.Instance.SwitchWrapper(GuiFrameID.BluetoothFightFrame);
        }
        else
        {
            if (BLEReceiveMessage != null)
            {
                BLEReceiveMessage(msg);
            }
        }
    }
Ejemplo n.º 19
0
 protected virtual void OnDropdownClick(Dropdown dpd)
 {
     if (!dpd)
     {
         MyDebug.LogYellow("Dropdown is NULL!");
         return;
     }
 }
Ejemplo n.º 20
0
 protected virtual void OnToggleClick(Toggle tgl)
 {
     if (!tgl)
     {
         MyDebug.LogYellow("Toggle is NULL!");
         return;
     }
 }
Ejemplo n.º 21
0
 protected virtual void OnButtonClick(Button btn)
 {
     if (!btn)
     {
         MyDebug.LogYellow("Button is NULL!");
         return;
     }
 }
Ejemplo n.º 22
0
    /// <summary>
    /// 获取游客信息
    /// </summary>
    /// <returns></returns>
    private IEnumerator SilentLogin(System.Action OnSucceed, System.Action <string> OnFail)
    {
        MyDebug.LogGreen("VisitorURL: " + VisitorURL);
        WWW www = new WWW(VisitorURL);

        float responseTime = 0;

        while (!www.isDone && responseTime < TimeOut)
        {
            responseTime += Time.deltaTime;
            yield return(www);
        }

        if (www.isDone)
        {
            LoginResponse response = JsonUtility.FromJson <LoginResponse>(www.text);
            MyDebug.LogGreen("www.text: " + www.text);
            if (response != null)
            {
                if (response.code == (int)CodeID.SUCCESS)
                {
                    m_IsLogining = false;
                    IsNewPlayer  = true;
                    Token        = response.token;
                    UserID       = response.data.id;
                    if (OnSucceed != null)
                    {
                        OnSucceed();
                    }
                    yield break;
                }
                else if (response.code == (int)CodeID.GAME_VERSION_ERROR)
                {
                    MyDebug.LogYellow("Silent Login Fail:" + response.code);
                }
                else
                {
                    MyDebug.LogYellow("Silent Login Fail:" + response.code);
                }
            }
            else
            {
                MyDebug.LogYellow("Silent Login Fail: Message Is Not Response!");
            }
        }
        else
        {
            MyDebug.LogYellow("Silent Login Fail Fail: " + www.error);
        }

        m_IsLogining = false;
        string message = c_LanguageCtrl.GetLanguage("Text_20066");

        if (OnFail != null)
        {
            OnFail(message);
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    /// 获取排行榜详情
    /// </summary>
    /// <param name="form"></param>
    /// <param name="OnSucceed"></param>
    /// <param name="OnFail"></param>
    /// <returns></returns>
    public IEnumerator GetRankDetail(WWWForm form, Action <string> OnSucceed, Action <string> OnFail)
    {
        WWW www = new WWW(DetailURL, form);

        float responseTime = 0;

        while (!www.isDone && responseTime < TimeOut)
        {
            responseTime += Time.deltaTime;
            yield return(www);
        }

        string message = "";

        if (www.isDone)
        {
            GetDetailResponse response = JsonUtility.FromJson <GetDetailResponse>(www.text);
            if (response != null)
            {
                if (response.code == (int)CodeID.SUCCESS)
                {
                    MyDebug.LogGreen("Get Rank Detail Succeed!");
                    if (OnSucceed != null)
                    {
                        OnSucceed(response.data);
                    }
                    yield break;
                }
                else if (response.code == (int)CodeID.GAME_VERSION_ERROR)
                {
                    MyDebug.LogYellow("Get Rank Detail Fail:" + response.code);
                    message = LanguageController.Instance.GetLanguage("Text_20079");
                }
                else
                {
                    MyDebug.LogYellow("Get Rank Detail Fail:" + response.code);
                    message = LanguageController.Instance.GetLanguage("Text_20066");
                }
            }
            else
            {
                MyDebug.LogYellow("Get Rank Detail Fail: Message Is Not Response!");
                message = LanguageController.Instance.GetLanguage("Text_20066");
            }
        }
        else
        {
            MyDebug.LogYellow("Get Rank Detail Fail: Long Time!");
            message = LanguageController.Instance.GetLanguage("Text_20067");
        }

        if (OnFail != null)
        {
            OnFail(message);
        }
    }
Ejemplo n.º 24
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);

        switch (btn.name)
        {
        case "Bluetooth2StartFrameBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.StartFrame, false);
            break;

        case "BluetoothCentralBtn":
            InitializeBluetooth(true);
            break;

        case "BluetoothPeripheralBtn":
            InitializeBluetooth(false);
            break;

        case "BackFromContentBtn":
            scaning = false;
            BluetoothLEHardwareInterface.RemoveCharacteristics();
            BluetoothLEHardwareInterface.RemoveServices();
            BluetoothLEHardwareInterface.DeInitialize(() =>
            {
                MyDebug.LogGreen("DeInitialize Success!");
            });
            CommonTool.GuiHorizontalMove(bluetoothCategoryContent, Screen.width, MoveID.RightOrUp, canvasGroup, false);
            break;

        case "BackFromScanResultBtn":
        case "BluetoothAdvertisingStopBtn":
            bluetoothPeripheralDetailBg.SetActive(false);
            bluetoothConnectWaiting.SetActive(false);
            bluetoothAdvertisingStopBtn.SetActive(false);
            StopScan();
            break;

        case "BluetoothScanBtn":
            StartScan();
            break;

        case "ConnectCancelBtn":
            bluetoothPeripheralDetailBg.SetActive(false);
            break;

        case "BluetoothReScanBtn":
            ReScan();
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 25
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);
        switch (btn.name)
        {
        case "0":
        case "1":
        case "2":
        case "3":
        case "4":
        case "5":
        case "6":
        case "7":
        case "8":
        case "9":
            RefreshResultText(btn.name);
            break;

        case "NextBtn":
            ShowNextQuestion(false);
            break;

        case "ClearBtn":
            ClearResultText();
            break;

        case "OrderBtn":
            ChangeInputOrder();
            break;

        case "TimeBtn":
            ChangeTimeVisibility();
            break;

        case "Fight2SettlementFrameBtn":
            giveUpBg.SetActive(true);
            break;

        case "GiveUpBg":
        case "CancelBtn":
            giveUpBg.SetActive(false);
            break;

        case "ConfirmBtn":
            StopAllCoroutines();
            CancelInvoke();
            GuiController.Instance.SwitchWrapperWithMove(GuiController.Instance.CompetitionGUI, MoveID.RightOrUp, false);
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
Ejemplo n.º 26
0
    public static void ExchangeAchievement()
    {
        string       addressList       = Application.dataPath + "/Achievement.txt";
        string       targetList        = Application.dataPath + "/Resources/Achievement/Achievement.txt";
        StreamReader mutiLanguageAsset = new StreamReader(addressList);

        if (mutiLanguageAsset == null)
        {
            MyDebug.LogYellow("Can not find: " + addressList);
            return;
        }
        char[] charSeparators = new char[] { "\r"[0], "\n"[0] };
        string asset          = mutiLanguageAsset.ReadToEnd();

        string[] lineArray = asset.Split(charSeparators, System.StringSplitOptions.RemoveEmptyEntries);
        string[] lineList;
        List <AchievementInstance> achList = new List <AchievementInstance>();

        for (int j = 1; j < lineArray.Length; j++)
        {
            AchievementInstance instance = new AchievementInstance();
            lineList = lineArray[j].Split(',');
            instance.achievementName = lineList[0];
            float.TryParse(lineList[1], out instance.accuracy);
            float.TryParse(lineList[2], out instance.meanTime);
            instance.mainTitleIndex    = lineList[3];
            instance.subTitleIndex     = lineList[4];
            instance.imageIndex        = lineList[5];
            instance.chapterImageIndex = lineList[6];
            int patternID = 0;
            int amountID  = 0;
            int symbolID  = 0;
            int digitID   = 0;
            int operandID = 0;
            int.TryParse(lineList[7], out patternID);
            int.TryParse(lineList[8], out amountID);
            int.TryParse(lineList[9], out symbolID);
            int.TryParse(lineList[10], out digitID);
            int.TryParse(lineList[11], out operandID);
            CategoryInstance cInstance = new CategoryInstance(patternID, amountID, symbolID, digitID, operandID);
            instance.cInstance = cInstance;
            int.TryParse(lineList[12], out instance.difficulty);
            instance.finishTime = "";
            instance.star       = 0;
            achList.Add(instance);
        }
        if (File.Exists(targetList))
        {
            File.Delete(targetList);
        }
        string toSave = JsonHelper.ToListJson <AchievementInstance>(achList);

        CommonTool.SetData(targetList, toSave);
    }
Ejemplo n.º 27
0
    public static string GetDataFromDataPath(string path)
    {
        if (!File.Exists(path))
        {
            MyDebug.LogYellow("File does not exit:" + path);
            return(null);
        }
        StreamReader streamReader = File.OpenText(path);
        string       data         = streamReader.ReadToEnd();

        streamReader.Close();
        return(data);
    }
Ejemplo n.º 28
0
 public static void FindUISprite()
 {
     Transform[] objArray = Selection.gameObjects[0].GetComponentsInChildren <Transform>(true);
     for (int i = 0; i < objArray.Length; i++)
     {
         Image image = objArray[i].GetComponent <Image>();
         if (image && image.sprite && image.sprite.name == "UISprite" && image.color == Color.white)
         {
             string path = GetPath(objArray[i]);
             MyDebug.LogYellow(path);
         }
     }
 }
Ejemplo n.º 29
0
    public static IEnumerator LoadImage(string path, Image image)
    {
        WWW www = new WWW(path);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            MyDebug.LogYellow("www.error:" + www.error);
        }
        image.sprite = Sprite.Create(www.texture, new Rect(new Vector2(0, 0), new Vector2(www.texture.width, www.texture.height)), Vector2.zero);
        www.Dispose();
    }
Ejemplo n.º 30
0
 /// <summary>
 /// 刷新Dropdown的状态
 /// </summary>
 /// <param name="dpd"></param>
 /// <param name="index"></param>
 private void RefreshDropdown(Dropdown dpd, int index)
 {
     if (!dpd)
     {
         MyDebug.LogYellow("Dropdown is null!");
         return;
     }
     for (int i = 0; i < dpd.options.Count; i++)
     {
         dpd.options[i].text = LanguageController.Instance.GetLanguage(dpd.options[i].text);
     }
     dpd.value = index;
     dpd.RefreshShownValue();
 }