Beispiel #1
0
        private float DrawWaveList(float startX, float startY)
        {
            maxSubWaveSize = 1;

            for (int i = 0; i < instance.waveList.Count; i++)
            {
                if (waveFoldList.Count <= i)
                {
                    waveFoldList.Add(true);
                }
                if (waveOFoldList.Count <= i)
                {
                    waveOFoldList.Add(true);
                }

                waveFoldList[i] = EditorGUI.Foldout(new Rect(startX, startY, widthS * 2, 15), waveFoldList[i], "Wave - " + (i + 1), TDE.foldoutS);

                if (removeIdx != i)
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "remove"))
                    {
                        removeIdx = i;
                    }
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "Insert"))
                    {
                        instance.waveList.Insert(i, new Wave());
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "cancel"))
                    {
                        removeIdx = -1;
                    }
                    GUI.color = new Color(1, .2f, .2f, 1f);
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "confirm"))
                    {
                        instance.waveList.RemoveAt(i);
                        removeIdx = -1;   i -= 1; continue;
                    }
                    GUI.color = white;
                }

                Wave wave = instance.waveList[i];

                if (waveFoldList[i])
                {
                    startX += 15;

                    TDE.Label(startX, startY += spaceY, width, 15, "SubWave (" + wave.subWaveList.Count + "):");
                    if (GUI.Button(new Rect(startX + spaceX, startY - 1, widthS, 15), "-1"))
                    {
                        if (wave.subWaveList.Count > 1)
                        {
                            wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1);
                        }
                    }
                    if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, widthS, 15), "+1"))
                    {
                        wave.subWaveList.Add(new SubWave());
                    }

                    float cachedY = startY + spaceY;
                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        startY = DrawSubWaveBlock(startX + (n * (subWaveBlockWidth + 10)), cachedY, wave.subWaveList[n], n, i);
                    }

                    startY += 5;

                    TDE.Label(startX, startY, width, height, "Time to Next Wave: ", "Time in second before next wave is spawned");
                    wave.timeToNextWave = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), wave.timeToNextWave);

                    float cachedX = startX;                     //startY+=spaceY;

                    TDE.Label(startX, startY += spaceY, width, height, "Gain On Clear: ", "gain when the wave is cleared", TDE.headerS);
                    TDE.Label(startX         += spaceX, startY, width, height, "Rsc: ", "Resource");          startX += 30;

                    RscManager.MatchRscList(wave.rscGainOnCleared, 0);

                    for (int n = 0; n < RscDB.GetCount(); n++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(n), RscDB.GetName(n));
                        wave.rscGainOnCleared[n] = EditorGUI.FloatField(new Rect(startX + height, startY, widthS - height, height), wave.rscGainOnCleared[n]);
                        startX += widthS + 2;
                    }

                    startX += widthS * .5f;
                    TDE.Label(startX, startY, width, height, "Perk rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 55, startY, height, height), PerkDB.GetRscIcon());
                    wave.perkRscGainOnCleared       = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.perkRscGainOnCleared);

                    startX += widthS * 1.5f;
                    TDE.Label(startX, startY, width, height, "Ability rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 65, startY, height, height), AbilityDB.GetRscIcon());
                    wave.abilityRscGainOnCleared    = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.abilityRscGainOnCleared);

                    startX = cachedX;

                    startY += spaceY * 2f;
                    startX -= 15;
                }
                else
                {
                    float cachedX = startX;   startX += 180 + (removeIdx == i ? widthS * 1.5f : 0);

                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        if (wave.subWaveList[n].prefab == null)
                        {
                            continue;
                        }
                        TDE.DrawSprite(new Rect(startX, startY, height * 1.5f, height * 1.5f), wave.subWaveList[n].prefab.icon);
                        TDE.Label(startX + height * 1.5f + 2, startY, widthS, height, "x" + wave.subWaveList[n].spawnCount);
                        startX += widthS + height * 1.5f;
                    }

                    startX = cachedX;

                    startY += spaceY * 2f;
                }

                maxSubWaveSize = Mathf.Max(waveFoldList[i] ? instance.waveList[i].subWaveList.Count : 1, maxSubWaveSize);
            }

            return(startY + spaceY * 2);
        }
Beispiel #2
0
        public float DrawGeneratorParameter(float startX, float startY)
        {
            instance.UpdateGeneratorUnitList();

            SpawnGenerator gen = instance.generator;  gen.Init();

            startX += 5;              spaceX += widthS;

            TDE.Label(startX, startY, width, height, "Wave Interval (Min/Max):", "The minimum and maximum value of the interval (in second) between two waves");
            gen.waveIntervalMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), gen.waveIntervalMin);
            gen.waveIntervalMax = EditorGUI.FloatField(new Rect(startX + spaceX + widthS, startY, widthS, height), gen.waveIntervalMax);

            gen.waveIntervalMin = Mathf.Max(0, gen.waveIntervalMin);          gen.waveIntervalMin = Mathf.Max(gen.waveIntervalMin, 0);
            gen.waveIntervalMax = Mathf.Max(0, gen.waveIntervalMax);  gen.waveIntervalMax = Mathf.Max(gen.waveIntervalMax, 0);

            TDE.Label(startX, startY += spaceY, width, height, "Use all path:", "When checked, all available path will be used (provided that there's enough subwave in the wave)");
            gen.useAllPath            = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.useAllPath);

            TDE.Label(startX, startY   += spaceY, width, height, "One SubWave per path:", "When checked, the total subwave count will be limited to number of path available");
            gen.limitSubWaveCountToPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.limitSubWaveCountToPath);

            TDE.Label(startX, startY += spaceY, width, height, "Mirror SubWave:", "When checked, all subwave will be similar except they uses different path");
            gen.similarSubWave        = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.similarSubWave);

            spaceX -= widthS;


            float cachedY = startY += spaceY * 2.5f;      float cachedX = startX;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Wave Setting:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attSubWaveCount, "SubWave Count:", "", null, 1);  startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attTotalUnitCount, "Total Unit Count:", "", null, 1);     startX += genAttBlockWidth + 10;

            startX += 15;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Gain On Wave Cleared:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Life Gain:");              startX += genAttBlockWidth + 10;


            //cachedY=startY+spaceY;	cachedX=startX;
            for (int i = 0; i < gen.attRscGainOnCleared.Count; i++)
            {
                DrawGenAttribute(startX, cachedY, gen.attRscGainOnCleared[i], RscDB.GetName(i), "", RscDB.GetIcon(i));
                startX += genAttBlockWidth + 10;
            }
            //startY+=genAttBlockHeight+spaceY; startX=cachedX;

            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon());         startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon());           startX += genAttBlockWidth + 10;

            startY += genAttBlockHeight + spaceY * 2;     startX = cachedX;

            for (int i = 0; i < gen.genItemList.Count; i++)
            {
                if (gen.genItemList[i].prefab == null)
                {
                    gen.genItemList.RemoveAt(i);    i -= 1;
                    continue;
                }
                startY = DrawGenItem(startX, startY, gen.genItemList[i]) + 10;
            }

            return(startY + spaceY * 2);
        }
Beispiel #3
0
        // Use this for initialization
        void Start()
        {
            GameObject lastSpaceObj = null;

            if (UIControl.IsGameScene())
            {
                lifeItem.Init();
                waveItem.Init();

                UpdateLifeDisplay(GameControl.GetLife());
                UpdateWaveDisplay(1);

                lastSpaceObj = spaceObjLife;
            }
            else
            {
                waveItem.rootObj.SetActive(false);
                spaceObjWave.SetActive(false);

                lifeItem.rootObj.SetActive(false);
                spaceObjLife.SetActive(false);
            }


            if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj)));
                    }
                    rscItemList[i].Init();
                    rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);

                    rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i);
                }
                UpdateResourceDisplay(RscManager.GetResourceList());

                lastSpaceObj = spaceObjRsc;
            }
            else
            {
                rscItemList[0].rootObj.SetActive(false);
                spaceObjRsc.SetActive(false);
            }


            if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost())
            {
                sliderAbilityRsc.gameObject.SetActive(false);
                spaceObjAbility.SetActive(false);
            }
            else
            {
                imgAbilityRsc.sprite = AbilityDB.GetRscIcon();
                UpdateAbilityRscDisplay(AbilityManager.GetRsc());
                lastSpaceObj = spaceObjAbility;
            }

            if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost())
            {
                perkRscItem.rootObj.SetActive(false);
                //spaceObjPerk.SetActive(false);
                lastSpaceObj.SetActive(false);
            }
            else
            {
                perkRscItem.Init();
                perkRscItem.imgMain.sprite = PerkDB.GetRscIcon();
                UpdatePerkRscDisplay(PerkManager.GetRsc());
            }



            //~ if(!UIControl.DisablePerkScreen()){
            //~ buttonPerk.Init();
            //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null);
            //~ }
            //~ else{
            //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false);
            //~ }


            //~ buttonFF.Init();
            //~ buttonFF.SetCallback(null, null, this.OnFFButton, null);

            //~ buttonPause.Init();
            //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null);
        }
Beispiel #4
0
        public override void Start()
        {
            base.Start();

            if (!PerkManager.IsEnabled())
            {
                thisObj.SetActive(false);
                return;
            }

            if (PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        costItemList.Add(new UIObject(UI.Clone(costItemList[0].rootObj)));
                    }
                    costItemList[i].Init();
                    costItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                }
            }
            else
            {
                costItemList[0].Init();
                costItemList[0].imgMain.sprite = PerkDB.GetRscIcon();
            }

            if (customLayout)
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < itemList.Count; i++)
                {
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);

                    bool matched = false;
                    for (int n = 0; n < perkList.Count; n++)
                    {
                        if (itemList[i].linkedPerkPID == perkList[n].prefabID)
                        {
                            itemList[i].linkedPerkIdx  = n;    matched = true;
                            itemList[i].imgMain.sprite = perkList[n].icon;
                        }
                    }

                    if (!matched)
                    {
                        Debug.LogWarning("No perk with matching prefab found");
                        itemList[i].rootObj.SetActive(false);
                        continue;
                    }

                    itemList[i].UnparentConnector();
                    itemList[i].UnparentConnectorBase();
                }
            }
            else
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (i > 0)
                    {
                        itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i)));
                    }
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);
                    itemList[i].linkedPerkIdx  = i;
                    itemList[i].imgMain.sprite = perkList[i].icon;
                }
            }

            buttonPurchase.Init();
            buttonPurchase.SetCallback(null, null, this.OnPurchaseButton, null);

            if (UIControl.IsGameScene())
            {
                buttonClose.Init();
                buttonClose.SetCallback(null, null, this.OnCloseButton, null);
            }

            if (!UIControl.IsGameScene())
            {
                canvasGroup.alpha = 1;
                thisObj.SetActive(true);
                StartCoroutine(DelayUpdateList());
            }
            else
            {
                thisObj.SetActive(false);
            }

            OnItem(itemList[0].rootObj);
        }
Beispiel #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "PerkManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Game Scene:", "Check to to indicate if the scene is not an actual game scene\nIntend if the a perk menu scene, purchased perk wont take effect ");
            instance.inGameScene = EditorGUILayout.Toggle(cont, instance.inGameScene);

            cont = new GUIContent("Carry Over:", "Check to have carry the progress made in previous level to this level, the progress made in this level will be carry over to the next level.\n\nIf this is the first level, the specified setting value is used instead");
            instance.carryOver = EditorGUILayout.Toggle(cont, instance.carryOver);

            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for perk cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            cont = new GUIContent("Resource:", "The resource used  to cast perk");
            if (instance.useRscManagerForCost)
            {
                EditorGUILayout.LabelField("Resource:", "-");
            }
            else
            {
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);
            }

            GUILayout.EndVertical();

            if (!instance.useRscManagerForCost)
            {
                Sprite icon = PerkDB.GetRscIcon();
                icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                PerkDB.SetRscIcon(icon);
            }

            GUILayout.EndHorizontal();


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = PerkDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Perk> perkList = PerkDB.GetList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].hideInInspector)
                    {
                        continue;
                    }

                    Perk perk = perkList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    float cachedL = EditorGUIUtility.labelWidth;      EditorGUIUtility.labelWidth = 80;
                    float cachedF = EditorGUIUtility.fieldWidth;      EditorGUIUtility.fieldWidth = 10;

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(perk.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the perk in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(perk.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(perk.prefabID);
                            instance.purchasedPrefabIDList.Remove(perk.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(perk.prefabID);
                        }
                    }

                    if (!instance.unavailablePrefabIDList.Contains(perk.prefabID))
                    {
                        EditorGUI.BeginChangeCheck();
                        flag = instance.purchasedPrefabIDList.Contains(perk.prefabID);
                        flag = EditorGUILayout.Toggle(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), flag);

                        if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                        {
                            if (flag)
                            {
                                instance.purchasedPrefabIDList.Add(perk.prefabID);
                            }
                            else
                            {
                                instance.purchasedPrefabIDList.Remove(perk.prefabID);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(" - purchased: ", "- ");
                    }

                    EditorGUIUtility.labelWidth = cachedL;    EditorGUIUtility.fieldWidth = cachedF;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }