Esempio n. 1
0
    private void InitOrUpdateView()
    {
        int i = 0;

        for (; i < collection.dataGroups.Length; i++)
        {
            var z = i;
            if (z == 0)
            {
                currentGacha = collection.dataGroups[z];
            }

            if (i < gachaTabList.Count)
            {
                gachaTabList[z].SetupAction(collection.dataGroups[z], ShowLayout);
            }
            else
            {
                var tab = Instantiate(prefab, gachaAnchor);
                tab.SetupAction(collection.dataGroups[z], ShowLayout);
                gachaTabList.Add(tab);
            }
        }
        layout.UpdateView(currentGacha);
    }
Esempio n. 2
0
    public void SetupAction(GachaData data, Action <GachaData> showGachaView)
    {
        this.data = data;

        nameTab.text = "Tab " + data.id;
        showGacha    = showGachaView;
    }
Esempio n. 3
0
    public GachaData RandomGet()
    {
        int Weight    = 0;
        int SelectNum = 0;

        SelectNum = Mathf.RoundToInt(Total * Random.Range(0.0f, 1.0f));

        Debug.Log("선택된 카드의 가중치" + SelectNum);

        for (int i = 0; i < Deck.Count; i++)
        {
            Weight += Deck[i].Weight;
            if (SelectNum <= Weight)
            {
                GachaData Temp = new GachaData(Deck[i]);

                string Key = Temp.Name + Random.Range(0, 20000);

                Temp.Key  = Key;
                Temp.Lock = 1;

                FirstAppearenceImage.gameObject.SetActive(true);
                StarsController.gameObject.SetActive(true);

                Debug.Log(Temp.Image);

                GetImage.sprite = Resources.Load(Temp.Image, typeof(Sprite)) as Sprite;

                if (Temp.Appearence == 0)
                {
                    FirstGet       = GameObject.Find("FirstAppearenceImage").transform.Find("FirstGet").GetComponent <Text>();
                    FirstGet.color = new Color(255, 255, 0, 255);

                    Temp.Appearence    = 1;
                    Deck[i].Appearence = 1;
                    CharacterDataSave();
                }

                switch (Temp.Rank)
                {
                case CardRank.S:   StarsController.Play("Five");   Debug.Log("S 랭크");  StartCoroutine(AnimationCheck("Five"));       break;

                case CardRank.A:   StarsController.Play("Four");   Debug.Log("A 랭크");  StartCoroutine(AnimationCheck("Four"));       break;

                case CardRank.B:   StarsController.Play("Three");  Debug.Log("B 랭크"); StartCoroutine(AnimationCheck("Three"));       break;

                default: break;
                }
                return(Temp);
            }
        }
        return(null);
    }
Esempio n. 4
0
    public void CharacterDataLoad(string FileName, LoadType Type)
    {
        PickUpButton.interactable = false;

        Deck.Clear();
        Total = 0;

        List <Dictionary <string, object> > StringData;

        if (Type == LoadType.Stream)
        {
            StringData = CSVReader.Read(FileName);
        }
        else
        {
            StringData = CSVReader.AssetRead(FileName);
        }


        for (int i = 0; i < StringData.Count; i++)
        {
            GachaData TempCharacter = new GachaData();

            TempCharacter.Name  = StringData[i]["Name"].ToString();
            TempCharacter.Image = StringData[i]["Image"].ToString();

            switch (StringData[i]["Rank"])
            {
            case "S": TempCharacter.Rank = CardRank.S; break;

            case "A": TempCharacter.Rank = CardRank.A; break;

            case "B": TempCharacter.Rank = CardRank.B; break;

            default: break;
            }

            TempCharacter.Property   = StringData[i]["Property"].ToString();
            TempCharacter.Power      = int.Parse(StringData[i]["Power"].ToString());
            TempCharacter.Appearence = int.Parse(StringData[i]["Appearence"].ToString());
            TempCharacter.Weight     = int.Parse(StringData[i]["Weight"].ToString());
            TempCharacter.Level      = int.Parse(StringData[i]["Level"].ToString());
            TempCharacter.MaxLevel   = int.Parse(StringData[i]["MaxLevel"].ToString());
            TempCharacter.NowExp     = int.Parse(StringData[i]["NowExp"].ToString());
            TempCharacter.MaxExp     = int.Parse(StringData[i]["MaxExp"].ToString());
            TempCharacter.Enhance    = int.Parse(StringData[i]["Enhance"].ToString());

            Deck.Add(TempCharacter);
        }

        PickUpButton.interactable = true;
    }
Esempio n. 5
0
    public void UpdateView(GachaData gachaData)
    {
        this.gachaData = gachaData;

        iconCurrencyGacha1.sprite  = LoadResourceController.GetMoneyIcon(gachaData.GetRequireGacha1().resId);
        iconCurrencyGacha10.sprite = LoadResourceController.GetMoneyIcon(gachaData.GetRequireGacha10().resId);

        priceGacha1.text  = gachaData.GetRequireGacha1().resNumber.ToString();
        priceGacha10.text = gachaData.GetRequireGacha10().resNumber.ToString();
        timeGacha1.text   = "";

        background.sprite = LoadResourceController.GetGachaBackground(gachaData.id);
        iconGacha.sprite  = LoadResourceController.GetGachaIcon(gachaData.id);

        SetupFreeGacha();
    }
Esempio n. 6
0
 public GachaData(GachaData Data)
 {
     this.Name       = Data.Name;
     this.Image      = Data.Image;
     this.Rank       = Data.Rank;
     this.Property   = Data.Property;
     this.Power      = Data.Power;
     this.Appearence = Data.Appearence;
     this.Weight     = Data.Weight;
     this.Level      = Data.Level;
     this.MaxLevel   = Data.MaxLevel;
     this.NowExp     = Data.NowExp;
     this.MaxExp     = Data.MaxExp;
     this.Enhance    = Data.Enhance;
     this.Key        = Data.Key;
     this.Lock       = Data.Lock;
 }
Esempio n. 7
0
        // Get a heroes' list
        public List <int> PickHeroes(int gachaId)
        {
            var ret       = new List <int>();
            var gachaData = new GachaData();

            // Set gachaData
            GachaTable.Instance.SelectByGachaId(gachaId).TryGetValue(gachaId, out gachaData);

            // Pick heroes
            for (int i = 0; i < MaxNumberOfVending; i++)
            {
                int grade  = GetRandomGrade(gachaData);
                int heroId = PickOneHero(grade);
                ret.Add(heroId);
            }
            return(ret);
        }
Esempio n. 8
0
    IEnumerator GachaDirectionRoutine()
    {
        SetMachineOpening();

        UseCoin();

        yield return(new WaitForSeconds(0.5f));

        //흔들림
        shakeAnimator.SetTrigger("Shake");
        yield return(new WaitForSeconds(2.0f));

        //상자 나타남
        uiGachaPopup.gameObject.SetActive(true);
        uiGachaPopup.transform.position = itemSpawnPosit.position;
        uiGachaPopup.SetIcon(ballSprites[Random.Range(0, ballSprites.Count)]);
        uiGachaPopup.FadeImage(ballSpawnTime);
        iTween.MoveTo(uiGachaPopup.gameObject, iTween.Hash("position", itemStopPosit.position, "time", ballSpawnTime, "easeType", "easeOutQuart"));
        yield return(new WaitForSeconds(ballSpawnTime));

        //화면 밝아지는 연출
        flash.color = new Color(1f, 1f, 1f, 0f);
        iTween.FadeTo(flash.gameObject, iTween.Hash("alpha", 1f, "Time", flashTime, "loopType", "pingpong", "easeType", "easeInQutQuart"));

        yield return(new WaitForSeconds(flashTime * 0.5f));

        GachaData item = DataManager.Instance.dataBaseLoader.GetRandomGachaItem;

        uiGachaPopup.SetIcon(getIcon(item.fileName));
        yield return(new WaitForSeconds(flashTime * 0.5f));

        flash.color = new Color(1f, 1f, 1f, 0f);
        iTween.Stop(flash.gameObject);

        uiGachaPopup.ShowItemInfoText(itemSpawnTime, item.itemName);
        uiItemBoard.UpdateItemInfo(item.itemName);

        yield return(new WaitForSeconds(itemSpawnTime));

        uiGachaPopup.ShowConfirmButton(confirmButtonSpawnTime);
    }
Esempio n. 9
0
    public void Return()
    {
        if (Deck.Count > 0)
        {
            if (ResourceManager.Instance.CanCasting())
            {
                Result = RandomGet();

                if (Result != null)
                {
                    CharacterInventory.Instance.CharacterList.Add(Result);

                    Debug.Log("1회 뽑기 완료");
                }
            }
            else
            {
                NotEnoughJewelImage.gameObject.SetActive(true);
                Debug.Log("자원이 부족합니다.");
            }
        }
    }
Esempio n. 10
0
        // Get random grade by probabilities
        protected int GetRandomGrade(GachaData gachaData)
        {
            const int MULTI            = 1000000;
            int       ret              = 0;
            int       totalProbability = gachaData.TotalProbability * MULTI;

            // Select none-zero columns.
            var probabilities = gachaData.Probability.Where(x => x.Value != 0).ToDictionary(x => x.Key, x => x.Value * MULTI);
            int cumulative    = 0;

            int randomNumber = RandomNumberCreator.Instance.MTRandom.Next(0, totalProbability);

            foreach (var probability in probabilities)    // No exception
            {
                cumulative += probability.Value;
                if (randomNumber <= cumulative)
                {
                    ret = probability.Key;
                    break;
                }
            }

            return(ret);
        }
Esempio n. 11
0
    /* 저장과 불러오기 */

    public void DataLoad(string FileDirectory, LoadType Type, List <GachaData> TargetList)
    {
        List <Dictionary <string, object> > StringData;

        if (Type == LoadType.Stream)
        {
            StringData = CSVReader.Read(FileDirectory);
        }
        else
        {
            StringData = CSVReader.AssetRead(FileDirectory);
        }

        for (int i = 0; i < StringData.Count; i++)
        {
            GachaData TempCharacter = new GachaData();

            if (StringData[i]["Name"] != null)
            {
                TempCharacter.Name = StringData[i]["Name"].ToString();
            }

            if (StringData[i]["Image"] != null)
            {
                TempCharacter.Image = StringData[i]["Image"].ToString();
            }

            switch (StringData[i]["Rank"])
            {
            case "S": TempCharacter.Rank = CardRank.S; break;

            case "A": TempCharacter.Rank = CardRank.A; break;

            case "B": TempCharacter.Rank = CardRank.B; break;

            default: break;
            }

            if (StringData[i]["Property"] != null)
            {
                TempCharacter.Property = StringData[i]["Property"].ToString();
            }

            if (StringData[i]["Power"] != null)
            {
                TempCharacter.Power = int.Parse(StringData[i]["Power"].ToString());
            }

            if (StringData[i]["Appearence"] != null)
            {
                TempCharacter.Appearence = int.Parse(StringData[i]["Appearence"].ToString());
            }

            if (StringData[i]["Weight"] != null)
            {
                TempCharacter.Weight = int.Parse(StringData[i]["Weight"].ToString());
            }

            if (StringData[i]["Level"] != null)
            {
                TempCharacter.Level = int.Parse(StringData[i]["Level"].ToString());
            }

            if (StringData[i]["MaxLevel"] != null)
            {
                TempCharacter.MaxLevel = int.Parse(StringData[i]["MaxLevel"].ToString());
            }

            if (StringData[i]["NowExp"] != null)
            {
                TempCharacter.NowExp = int.Parse(StringData[i]["NowExp"].ToString());
            }

            if (StringData[i]["MaxExp"] != null)
            {
                TempCharacter.MaxExp = int.Parse(StringData[i]["MaxExp"].ToString());
            }

            if (StringData[i]["Enhance"] != null)
            {
                TempCharacter.Enhance = int.Parse(StringData[i]["Enhance"].ToString());
            }

            if (StringData[i]["Key"] != null)
            {
                TempCharacter.Key = StringData[i]["Key"].ToString();
            }

            if (StringData[i]["Lock"] != null)
            {
                TempCharacter.Lock = int.Parse(StringData[i]["Lock"].ToString());
            }

            TargetList.Add(TempCharacter);
        }
    }
Esempio n. 12
0
 private void ShowLayout(GachaData data)
 {
     layout.UpdateView(data);
 }
Esempio n. 13
0
    private void OnGUI()
    {
        if (pGachaData == null)
        {
            pGachaData = new GachaData();
        }

        FileData = EditorGUILayout.ObjectField(FileData, typeof(GachaData), true) as GachaData; //データを編集するなら
        if (FileData != null)                                                                   //中身が入ったら
        {
            pGachaData = FileData;
        }

        pGachaData.GachaName = EditorGUILayout.TextField("ガチャのタイトル", pGachaData.GachaName); //オブジェクトの名前

        EditorGUILayout.Space();                                                            //改行スペース
        EditorGUILayout.Space();                                                            //改行スペース

        pGachaData.TopTexture = EditorGUILayout.ObjectField(pGachaData.TopTexture, typeof(Texture2D), true) as Texture2D;

        EditorGUILayout.Space(); //改行スペース
        EditorGUILayout.Space(); //改行スペース


        EditorGUILayout.BeginVertical(GUI.skin.box);
        {
            ///////////////////////  ピックアップ  //////////////////////////////////////////////////

            if (isTab[0] = EditorGUILayout.Foldout(isTab[0], "Pickup"))  //Pickupのタブ
            {
                for (int i = 0; i < pGachaData.GachaContents.Count; ++i) //表示
                {
                    if (pGachaData.GachaContents[i].isPickup == true)
                    {
                        GachaData.Data tmpData = pGachaData.GachaContents[i];
                        EditorGUILayout.BeginHorizontal();
                        {
                            tmpData.DataFile = EditorGUILayout.ObjectField(pGachaData.GachaContents[i].DataFile, typeof(GachaObjectData), true) as GachaObjectData;

                            if (GUILayout.Button("除外", GUILayout.Width(80), GUILayout.Height(15)))
                            {
                                tmpData.isPickup = !pGachaData.GachaContents[i].isPickup;
                            }
                            if (GUILayout.Button("削除", GUILayout.Width(50), GUILayout.Height(15)))
                            {
                                pGachaData.GachaContents.Remove(pGachaData.GachaContents[i]);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        pGachaData.GachaContents[i] = tmpData;
                    }
                }


                GachaData.Data data = new GachaData.Data();
                data.DataFile = EditorGUILayout.ObjectField("追加", null, typeof(GachaObjectData), true) as GachaObjectData; //追加

                if (data.DataFile != null)                                                                                 //データが入ったら
                {
                    data.isPickup = true;
                    pGachaData.GachaContents.Add(data);
                }
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////



            ///////////////////////  はずれの中身  ////////////////////////////////////////////////////////
            if (isTab[1] = EditorGUILayout.Foldout(isTab[1], "中身"))      //Pickupのタブ
            {
                for (int i = 0; i < pGachaData.GachaContents.Count; ++i) //表示
                {
                    if (pGachaData.GachaContents[i].isPickup == false)
                    {
                        GachaData.Data tmpData = pGachaData.GachaContents[i];
                        EditorGUILayout.BeginHorizontal();
                        {
                            tmpData.DataFile = EditorGUILayout.ObjectField(pGachaData.GachaContents[i].DataFile, typeof(GachaObjectData), true) as GachaObjectData;

                            if (GUILayout.Button("ピックアップ", GUILayout.Width(80), GUILayout.Height(15)))
                            {
                                tmpData.isPickup = !pGachaData.GachaContents[i].isPickup;
                            }

                            if (GUILayout.Button("削除", GUILayout.Width(50), GUILayout.Height(15)))
                            {
                                pGachaData.GachaContents.Remove(pGachaData.GachaContents[i]);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        pGachaData.GachaContents[i] = tmpData;
                    }
                }


                GachaData.Data data = new GachaData.Data();
                data.DataFile = EditorGUILayout.ObjectField("追加", null, typeof(GachaObjectData), true) as GachaObjectData; //追加

                if (data.DataFile != null)                                                                                 //データが入ったら
                {
                    data.isPickup = false;
                    pGachaData.GachaContents.Add(data);
                }
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////
        }
        EditorGUILayout.EndVertical();



        EditorGUILayout.BeginHorizontal();
        {
            if (FileData == null && GUILayout.Button("ファイル保存"))
            {
                for (int i = (int)GachaObjectData.RARITY.SR; i <= (int)GachaObjectData.RARITY.SSR; i++)
                {
                    Calculation(i);
                }
                if (pGachaData.GachaName != "Name")
                {
                    AssetDatabase.CreateAsset(pGachaData, "Assets/Gacha/GachaData/" + pGachaData.GachaName + ".asset");//ファイル書き出し
                    Debug.Log(pGachaData.GachaName + "作成しました");
                }
                else
                {
                    Debug.Log("ファイル名をちゃんと入力してね");
                }
            }
            else if (FileData != null && GUILayout.Button("上書き"))
            {
                Debug.Log("上書き完了");
            }

            if (GUILayout.Button("新規作成"))
            {
                FileData   = null;
                pGachaData = new GachaData();
                Debug.Log("新規作成しました");
            }
        }
        EditorGUILayout.EndHorizontal();
    }