Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        BattleField battleField = target as BattleField;

        if (GUILayout.Button("测试掉线"))
        {
            battleField.DisConnect();
        }

        if (GUILayout.Button("测试重连"))
        {
            battleField.TestReconnect();
        }

        if (GUILayout.Button("DrawPlacement"))
        {
            DrawPlacementArea();
        }

        if (GUILayout.Button("PlaceBuilding"))
        {
            battleField.TestBattleMgr.AddStructureWithID(27, 3, 611110);
        }

        if (GUILayout.Button("ChangePlacement"))
        {
            var gos = GameObject.FindGameObjectsWithTag("placement");
            for (int i = 0; i < gos.Length; ++i)
            {
                var go    = gos[i];
                var name  = go.name;
                var index = System.Int32.Parse(name);
                if (index >= 27 && index <= 29)
                {
                    {
                        var greenTrans = go.transform.Find("Green/Quad");
                        var mat        = UnityEditor.AssetDatabase.LoadAssetAtPath <Material>("Assets/Effect/skill/texture/tx/Materials/Untitled1 (2).mat");
                        if (mat != null)
                        {
                            var meshRenderer = greenTrans.GetComponent <MeshRenderer>();
                            meshRenderer.material = mat;
                            greenTrans.localScale = new Vector3(1.63f, 1.63f, 1.63f);
                        }
                        else
                        {
                            Debug.LogError("load wrong!!!");
                        }
                    }

                    {
                        var redTrans = go.transform.Find("Red/Quad");
                        var mat      = UnityEditor.AssetDatabase.LoadAssetAtPath <Material>("Assets/Effect/skill/texture/tx/Materials/Untitled11.mat");
                        if (mat != null)
                        {
                            var meshRenderer = redTrans.GetComponent <MeshRenderer>();
                            meshRenderer.material = mat;
                            redTrans.localScale   = new Vector3(1.63f, 1.63f, 1.63f);
                        }
                        else
                        {
                            Debug.LogError("load wrong!!!");
                        }
                    }
                }
            }
        }
#if UNITY_EDITOR
        #region 作弊模式
        var titleStyle = new GUIStyle();
        titleStyle.alignment = TextAnchor.MiddleCenter;
        titleStyle.richText  = true;
        titleStyle.fontSize  = 20;
        GUILayout.Label("\n<color=#FF0000>↓↓↓ 作弊指令 ↓↓↓</color>", titleStyle);

        GUILayout.BeginHorizontal();
        GUILayout.Label("战斗速度:", GUILayout.MaxWidth(70));
        if (GUILayout.Button("慢放 ◀", GUILayout.MaxWidth(100)))
        {
            Time.timeScale = 0.1f;
        }
        if (GUILayout.Button("正常 ▶", GUILayout.MaxWidth(100)))
        {
            Time.timeScale = 1;
        }
        if (GUILayout.Button("快进 ▶▶", GUILayout.MaxWidth(100)))
        {
            Time.timeScale = 10;
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("属性设置:", GUILayout.MaxWidth(70));
        var fow = GUILayout.Toggle(isFOWActive, "战争迷雾", GUILayout.MaxWidth(100));
        if (isFOWActive != fow)
        {
            FogOfWarManager.Instance.SetActiveFOW(fow);
            isFOWActive = fow;
        }
        var ai = GUILayout.Toggle(isAIActive, "开启AI摆兵 TODO", GUILayout.MaxWidth(100));
        if (isAIActive != ai)
        {
            isAIActive = ai;
        }
        var invincible = GUILayout.Toggle(isInvincible, "开启战神无敌 TODO", GUILayout.MaxWidth(100));
        if (isInvincible != invincible)
        {
            isInvincible = invincible;
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(10);

        if (GUILayout.Button("给我加钱 + 1000"))
        {
            CustomHelper.SetPlayerGold(0, 1000);
        }

        if (GUILayout.Button("给我加战斗力 + 1000"))
        {
            battleField.AddPlayerProductivity(0, 1000);
        }

        if (GUILayout.Button("☢☢☢ Big Bang ☢☢☢ TODO"))
        {
        }


        GUILayout.Space(10);

        GUILayout.Label("设置兵种卡:");
        GUILayout.BeginVertical("Box");
        addCardPos = EditorGUILayout.IntSlider("添加手卡的位置:", addCardPos, 1, 10);

        int unitIdx = unitIds.FindIndex(x => x == addCardID);

        GUILayout.BeginHorizontal();
        unitIdx   = EditorGUILayout.Popup("选择你要添加的英雄:", unitIdx, unitNames.ToArray());
        addCardID = EditorGUILayout.IntField(addCardID, GUILayout.MaxWidth(50));
        GUILayout.EndHorizontal();

        Texture unitPic = null;
        if (unitIdx >= 0)
        {
            addCardID = unitIds[unitIdx];

            int    unitID   = addCardID / 10 % 10000;
            var    unitcfg  = BattleManager.UnitConfig.Instance.GetData(unitID);
            string unitPath = "Assets/LuaFramework/MyResources/Textures/" + unitcfg.IconFolder + "/" + unitcfg.UnitIcon + ".png";
            unitPic = EditorGUIUtility.Load(unitPath) as Texture;
        }
        EditorGUILayout.ObjectField("当前选中的英雄:", unitPic, typeof(Texture), true);

        if (GUILayout.Button("加手卡"))
        {
            if (unitIdx >= 0)
            {
                battleField.TestBattleMgr.SetHandCard(0, addCardPos - 1, addCardID);
            }
        }
        GUILayout.EndVertical();

        GUILayout.Space(10);

        GUILayout.Label("设置法术卡:");
        GUILayout.BeginVertical("Box");
        addMagicPos = EditorGUILayout.IntSlider("添加法术的位置:", addMagicPos, 1, 5);

        int skillIdx = skillIds.FindIndex(x => x == addMagicID);

        GUILayout.BeginHorizontal();
        skillIdx   = EditorGUILayout.Popup("选择你要添加的法术:", skillIdx, skillNames.ToArray());
        addMagicID = EditorGUILayout.IntField(addMagicID, GUILayout.MaxWidth(50));
        GUILayout.EndHorizontal();

        Texture skillPic = null;
        if (skillIdx >= 0)
        {
            addMagicID = skillIds[skillIdx];

            var    skillcfg  = BattleManager.SkillConfig.Instance.GetData(addMagicID);
            string skillPath = "Assets/LuaFramework/MyResources/Textures/IconSpell/" + skillcfg.SkillImg + ".png";
            skillPic = EditorGUIUtility.Load(skillPath) as Texture;
        }
        EditorGUILayout.ObjectField("当前选中的法术:", skillPic, typeof(Texture), true);

        if (GUILayout.Button("学法术"))
        {
            if (skillIdx >= 0)
            {
                CustomHelper.GuideBuySkill(0, addMagicID, 3, 3 + addMagicPos);
            }
        }
        GUILayout.EndVertical();

        if (GUILayout.Button("给AI摆兵 TODO"))
        {
        }
        GUILayout.Label("<color=#FF0000>↑↑↑ 作弊指令 ↑↑↑</color>", titleStyle);

        #endregion
#endif
    }