Esempio n. 1
0
    public static BaseStateItem CreateStateItem(StateItemType type)
    {
        Queue <BaseStateItem> pool = null;

        if (!StateItemPool.TryGetValue(type, out pool))
        {
            pool = new Queue <BaseStateItem>();
            StateItemPool.Add(type, pool);
        }

        BaseStateItem stateItem = null;

        if (pool.Count == 0)
        {
            stateItem = NewStateItem(type);
        }
        else
        {
            stateItem = pool.Dequeue();
        }
        if (stateItem != null)
        {
            return(stateItem);
        }

        return(null);
    }
Esempio n. 2
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);
        }
    }
Esempio n. 3
0
    public void DelStateItem(BaseStateItem stateItem)
    {
        StateItemType        type  = stateItem.stateItemType;
        List <BaseStateItem> items = mStateItems[(int)StateItemType.Count];

        if (items == null)
        {
            return;
        }
        if (items.Count == 0)
        {
            return;
        }
        BaseStateItem lastItem = items[items.Count - 1];

        items.Remove(stateItem);

        lastItem.Exit();

        if (lastItem == stateItem && items.Count > 0)
        {
            lastItem = items[items.Count - 1];
            lastItem.OnOverlay();
        }
    }
Esempio n. 4
0
    public static void DeleteAction(BaseStateItem stateItem)
    {
        StateItemType         type = stateItem.stateItemType;
        Queue <BaseStateItem> pool = null;

        if (!StateItemPool.TryGetValue(type, out pool))
        {
            return;
        }
        pool.Enqueue(stateItem);
    }
Esempio n. 5
0
 public StateMgr(Character cha)
 {
     mOwner = cha;
     for (int i = 0; i < mDefaultStateItems.Length; ++i)
     {
         StateItemType type = (StateItemType)i;
         BaseStateItem item = BaseStateItem.CreateStateItem(type);
         mDefaultStateItems[i] = item;
     }
     for (int i = 0; i < mCannotFlagCount.Length; ++i)
     {
         mCannotFlagCount[i] = 0;
     }
 }
Esempio n. 6
0
    private int GetStat(StateItemType type)
    {
        switch (type)
        {
        case StateItemType.MyMaxEnergy:
            return(MyMaxEnergy);

        case StateItemType.MyEnergy:
            return(MyEnergy);

        case StateItemType.MyFood:
            return(MyFood);

        case StateItemType.MyHappiness:
            return(MyHappiness);

        case StateItemType.MyHealth:
            return(MyHealth);

        case StateItemType.FamilyFood:
            return(FamilyFood);

        case StateItemType.FamilyHappiness:
            return(FamilyHappiness);

        case StateItemType.FamilyHealth:
            return(FamilyHealth);

        case StateItemType.Age:
            return(Age);

        case StateItemType.Money:
            return(Money);

        case StateItemType.MySalary:
            return(MoneyPerWorkshift);

        case StateItemType.PartnerSalary:
            return(MoneyPerPartnersWorkshift);

        case StateItemType.FoodSupplies:
            return(FoodSupplies);

        default:
            throw new Exception("This type is not implemented in StatsDifference: " + type.ToString());
        }
    }
Esempio n. 7
0
    public void AddStateItem(BaseStateItem stateItem)
    {
        StateItemType        type  = stateItem.stateItemType;
        List <BaseStateItem> items = mStateItems[(int)StateItemType.Count];

        if (items == null)
        {
            items = new List <BaseStateItem>();
            mStateItems[(int)type] = items;
        }

        stateItem.Enter();

        items.Add(stateItem);

        stateItem.OnOverlay();
    }
Esempio n. 8
0
    private static BaseStateItem NewStateItem(StateItemType type)
    {
        BaseStateItem stateItem = null;

        switch (type)
        {
        case StateItemType.CannotFlag:
            stateItem = new StateItemCannotFlag();
            break;

        case StateItemType.ModifyHp:
            stateItem = new StateItemModifyHp();
            break;
        }
        stateItem.stateItemType = type;

        return(stateItem);
    }
Esempio n. 9
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);
        }
    }
Esempio n. 10
0
    public static string ToDescription(this StateItemType enumType)
    {
        Type type = typeof(StateItemType);

        try
        {
            FieldInfo info = type.GetField(enumType.ToString());
            if (info == null)
            {
                return("Unkown");
            }
            EnumDescriptionAttribute descAttribute = info.GetCustomAttributes(typeof(EnumDescriptionAttribute), true)[0] as EnumDescriptionAttribute;
            if (descAttribute != null)
            {
                return(descAttribute.Description);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning(e.Message);
        }
        return(type.ToString());
    }
Esempio n. 11
0
 private static int PerMinute(GameplayConstants constants, StateItemType type)
 {
     return(constants.GetChangePerMinute(type.ToString()));
 }
Esempio n. 12
0
 private static int InitValue(GameplayConstants constants, StateItemType type)
 {
     return(constants.GetInitialValue(type.ToString()));
 }
Esempio n. 13
0
    public int GetStat(string type)
    {
        StateItemType typeEnum = (StateItemType)Enum.Parse(typeof(StateItemType), type);

        return(GetStat(typeEnum));
    }