Пример #1
0
    void ShowEffectData()
    {
        if (mCurStateEffect == 0)
        {
            return;
        }
        excel_state_effect effectExcel = excel_state_effect.Find(mCurStateEffect);

        EditorGUILayout.LabelField("效果ID", string.Format("{0}", effectExcel.id));
        effectExcel.name = EditorGUILayout.TextField("效果名称", effectExcel.name);

        StateItemType stateItemType = (StateItemType)effectExcel.type;

        int[]    values = new int[(int)StateItemType.Count];
        string[] texts  = new string[(int)StateItemType.Count];
        for (int i = 0; i < (int)StateItemType.Count; ++i)
        {
            StateItemType v = (StateItemType)i;
            values[i] = i;
            texts[i]  = string.Format("{0:D2}. {1}", i, v.ToDescription());
        }
        effectExcel.type = EditorGUILayout.IntPopup("效果类型", effectExcel.type, texts, values);

        StateEffectEditorRegister.StateEffectEditorMethod method = null;
        if (StateEffectEditorRegister.mStateEffectMethods.TryGetValue(stateItemType, out method))
        {
            method(effectExcel);
        }
    }
 static void SetIntArrayCount(excel_state_effect e, int count)
 {
     if (e.dataIntArray == null)
     {
         e.dataIntArray = new int[count];
     }
     if (e.dataIntArray.Length != count)
     {
         e.dataIntArray = new int[count];
     }
 }
Пример #3
0
    void StateEffectList(excel_state_group stateExcel)
    {
        if (stateExcel == null || stateExcel.stateEffectIDs == null)
        {
            return;
        }
        for (int i = 0; i < stateExcel.stateEffectIDs.Length; ++i)
        {
            int effectID = stateExcel.stateEffectIDs[i];
            excel_state_effect effectExcel = excel_state_effect.Find(effectID);
            if (effectExcel == null)
            {
                continue;
            }

            bool isExpand = expandStateEffects.Contains(effectExcel.id);
            bool isSel    = mCurStateEffect == effectExcel.id;

            EditorGUILayout.BeginHorizontal();
            Rect rcfold = EditorGUILayout.GetControlRect(GUILayout.Width(12.0f));
            Rect rcbtn  = EditorGUILayout.GetControlRect();
            EditorGUILayout.EndHorizontal();

            if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
            {
                if (rcbtn.Contains(Event.current.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("删除技能段"), false, StateMenuEvent, "delEffect*" + stateExcel.id + "*" + effectExcel.id);
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }

            GUIStyle skillStyle = EditorStyles.foldout;
            GUIStyle style      = isSel ? mStateStyleSelected : mStateStyleNormal;
            if (GUI.Button(rcbtn, "● 状态效果{" + effectExcel.id + "}::名称{" + effectExcel.name + "}", style))
            {
                if (!isSel)
                {
                    mCurStateGroup  = 0;
                    mCurStateEffect = effectExcel.id;
                }
                else
                {
                    mCurStateGroup  = 0;
                    mCurStateEffect = 0;
                }
            }
        }
    }
    ////////////////////////////////////////////////////////////////////////////////

    static void ModifyHp(excel_state_effect e)
    {
        SetIntArrayCount(e, 6);

        GUIContent c = null;

        bool isPct = (e.dataIntArray[0] != 0);

        isPct             = EditorGUILayout.ToggleLeft("按百分比改变血量", isPct);
        e.dataIntArray[0] = isPct ? 1 : 0;

        if (isPct)
        {
            c = new GUIContent("最大血量百分比(%)", "填100表示100%,正数表示增加,负数表示减少");
            float pct = (float)e.dataIntArray[1] * 0.01f;
            pct = EditorGUILayout.FloatField(c, pct);
            e.dataIntArray[1] = (int)(pct * 100.0f);
        }
        else
        {
            c = new GUIContent("改变血量", "正数表示增加,负数表示减少");
            e.dataIntArray[1] = EditorGUILayout.IntField(c, e.dataIntArray[1]);
        }

        c = new GUIContent("改变间隔", "单位毫秒,填0则只改变一次");
        e.dataIntArray[5] = EditorGUILayout.IntField(c, e.dataIntArray[5]);

        c = new GUIContent("附加Atb属性ID", "填AtbID,以这个Atb为参考增加/减少血量,填0则不附加血量");
        e.dataIntArray[2] = EditorGUILayout.IntField(c, e.dataIntArray[2]);

        if (e.dataIntArray[2] > 0)
        {
            c = new GUIContent("附加Atb百分比", "根据该Atb的一定百分比改变血量,正数表示增加,负数表示减少,填100表示100%");
            float pct = (float)e.dataIntArray[3] * 0.01f;
            pct = EditorGUILayout.FloatField(c, pct);
            e.dataIntArray[3] = (int)(pct * 100.0f);

            StateItemModifyHp.UseAtbType useAtbType = (StateItemModifyHp.UseAtbType)e.dataIntArray[4];

            int[]    values = Enum.GetValues(typeof(StateItemModifyHp.UseAtbType)) as int[];
            string[] texts  = new string[values.Length];
            for (int i = 0; i < texts.Length; ++i)
            {
                texts[i] = ((StateItemModifyHp.UseAtbType)values[i]).ToDescription();
            }
            e.dataIntArray[4] = EditorGUILayout.IntPopup("Atb来源", e.dataIntArray[4], texts, values);
        }
    }
Пример #5
0
    public void Enter()
    {
        mStartTime = Time.realtimeSinceStartup;

        for (int i = 0; i < mExcel.stateEffectIDs.Length; ++i)
        {
            int stateEffectID        = mExcel.stateEffectIDs[i];
            excel_state_effect excel = excel_state_effect.Find(stateEffectID);
            if (excel == null)
            {
                continue;
            }
            StateItemType stateItemType = (StateItemType)excel.type;

            BaseStateItem stateItem = BaseStateItem.CreateStateItem(stateItemType);
            stateItem.excel      = excel;
            stateItem.stateGroup = this;

            mStateMgr.AddStateItem(stateItem);
            mStateItems.Add(stateItem);
        }
    }
Пример #6
0
    int GetEmptyStateEffectID()
    {
        int id = 1;

        for (int i = 0; i < excel_state_effect.Count; ++i)
        {
            excel_state_effect excel = excel_state_effect.GetByIndex(i);
            if (excel.id < 1 || excel.id > 9999999)
            {
                continue;
            }
            if (id == excel.id)
            {
                ++id;
            }
            else
            {
                return(id);
            }
        }
        return(id);
    }
Пример #7
0
    void StateMenuEvent(object obj)
    {
        string strData = obj as string;

        if (string.IsNullOrEmpty(strData))
        {
            return;
        }
        string[] sdatas = strData.Split('*');
        if (sdatas == null || sdatas.Length < 1)
        {
            return;
        }
        string data0 = sdatas[0];

        if (data0 == "addState")
        {
            excel_state_group newState = new excel_state_group();
            newState.id   = GetEmptyStateID();
            newState.name = "newState";
            excel_state_group.Add(newState);
        }
        else if (data0 == "delState")
        {
        }
        else if (data0 == "addEffect")
        {
            int stateID = 0;
            if (!int.TryParse(sdatas[1], out stateID))
            {
                return;
            }
            if (!expandStateGroups.Contains(stateID))
            {
                expandStateGroups.Add(stateID);
            }
            excel_state_group stateExcel = excel_state_group.Find(stateID);
            if (stateExcel == null)
            {
                return;
            }
            excel_state_effect newEffect = new excel_state_effect();
            newEffect.id   = GetEmptyStateEffectID();
            newEffect.name = "newStage";
            if (stateExcel.stateEffectIDs == null)
            {
                stateExcel.stateEffectIDs = new int[1];
            }
            else
            {
                int[] origList = stateExcel.stateEffectIDs.Clone() as int[];
                stateExcel.stateEffectIDs = new int[stateExcel.stateEffectIDs.Length + 1];
                origList.CopyTo(stateExcel.stateEffectIDs, 0);
            }
            stateExcel.stateEffectIDs[stateExcel.stateEffectIDs.Length - 1] = newEffect.id;
            excel_state_effect.Add(newEffect);
        }
        else if (data0 == "delEffect")
        {
        }
        else if (data0 == "save")
        {
        }
    }