コード例 #1
0
 public virtual void Save(BinaryHelper helper)
 {
     PropertyInfo[] propInfo = GetType().GetProperties();
     foreach (PropertyInfo info in propInfo)
     {
         if (info.PropertyType == typeof(string))
         {
             helper.Write(info.GetValue(this, null) as string);
         }
         else if (info.PropertyType == typeof(int))
         {
             helper.Write((int)info.GetValue(this, null));
         }
         else if (info.PropertyType == typeof(float))
         {
             helper.Write((float)info.GetValue(this, null));
         }
         else if (info.PropertyType == typeof(bool))
         {
             helper.Write((bool)info.GetValue(this, null));
         }
         else if (info.PropertyType == typeof(short))
         {
             helper.Write((short)info.GetValue(this, null));
         }
         else if (info.PropertyType == typeof(List <int>))
         {
             helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <int>));
         }
         else if (info.PropertyType == typeof(List <float>))
         {
             helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <float>));
         }
         else if (info.PropertyType == typeof(List <string>))
         {
             helper.Write(ConvertorTool.ListToString(info.GetValue(this, null) as List <string>));
         }
         else
         {
             Debug.Log("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name);
         }
     }
 }
コード例 #2
0
 public virtual void Load(BinaryHelper helper)
 {
     PropertyInfo[] propInfo = GetType().GetProperties();
     foreach (PropertyInfo info in propInfo)
     {
         if (info.PropertyType == typeof(string))
         {
             info.SetValue(this, helper.ReadString(), null);
         }
         else if (info.PropertyType == typeof(int))
         {
             info.SetValue(this, helper.ReadInt(), null);
         }
         else if (info.PropertyType == typeof(float))
         {
             info.SetValue(this, helper.ReadFloat(), null);
         }
         else if (info.PropertyType == typeof(bool))
         {
             info.SetValue(this, helper.ReadBool(), null);
         }
         else if (info.PropertyType == typeof(short))
         {
             info.SetValue(this, (short)helper.ReadInt(), null);
         }
         else if (info.PropertyType == typeof(List <int>))
         {
             info.SetValue(this, ConvertorTool.StringToList_Int(helper.ReadString()), null);
         }
         else if (info.PropertyType == typeof(List <float>))
         {
             info.SetValue(this, ConvertorTool.StringToList_Float(helper.ReadString()), null);
         }
         else if (info.PropertyType == typeof(List <string>))
         {
             info.SetValue(this, ConvertorTool.StringToList_String(helper.ReadString()), null);
         }
         else
         {
             Debug.Log("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name);
         }
     }
 }
コード例 #3
0
ファイル: NPCInfoTable.cs プロジェクト: moto2002/snowbattle
 public void Save(BinaryHelper helper)
 {
     helper.Write(ID);
     helper.Write(StrName);
     helper.Write(ModelId);
     helper.Write(ModelScale);
     helper.Write(WeaponID);
     helper.Write(RaceType);
     helper.Write(IsPush);
     helper.Write(AIType);
     helper.Write(Type);
     helper.Write(BossAIXmlName);
     helper.Write(BossAIXmlSubName);
     helper.Write(InterSubType);
     helper.Write(NpcSay);
     helper.Write(Level);
     helper.Write(HPMax);
     helper.Write(HPCount);
     helper.Write(PhyAttack);
     helper.Write(MagAttack);
     helper.Write(PhyDefend);
     helper.Write(MagDefend);
     helper.Write(HitRate);
     helper.Write(Avoid);
     helper.Write(CritRate);
     helper.Write(CritParam);
     helper.Write(Resist);
     helper.Write(WoundParam);
     helper.Write(AnitInterfereRate);
     helper.Write(AnitInterruptRate);
     helper.Write(AnitRepelRate);
     helper.Write(AnitLauncherRate);
     helper.Write(RotateSpeed);
     helper.Write(SwitchRotateSpeed);
     helper.Write(MoveSpeed);
     helper.Write(AnimationSpeed);
     helper.Write(AttackRange);
     helper.Write(CallNpcRange);
     helper.Write(AlertRange);
     helper.Write(CancelAlertRange);
     helper.Write(AlertPeriod);
     helper.Write(LargeRate);
     helper.Write(SmallRate);
     helper.Write(VisionRange);
     helper.Write(MaxChaseRange);
     helper.Write(RetreatDistance);
     helper.Write(RetreatSpeed);
     helper.Write(RetreatTime);
     helper.Write(StaminaMax);
     helper.Write(StaminaRestoreValue);
     helper.Write(StaminaRestorePeriod);
     helper.Write(StaminaEvent);
     helper.Write(StaminaSkillID);
     helper.Write(StaminaReset);
     helper.Write(ConvertorTool.ListToString(GiftBuffIDList));
     helper.Write(DropID);
     helper.Write(ConvertorTool.ListToString(SkillList));
     helper.Write(ConvertorTool.ListToString(PassiveSkillList));
     helper.Write(functionNum);
     if (NpcFuncArgs != null)
     {
         functionNum = NpcFuncArgs.Count;
     }
     if (functionNum > 0)
     {
         foreach (NpcFuncArg val in NpcFuncArgs)
         {
             val.Save(helper);
         }
     }
 }
コード例 #4
0
ファイル: NPCInfoTable.cs プロジェクト: moto2002/snowbattle
 public void Load(BinaryHelper helper)
 {
     ID                   = helper.ReadInt();
     StrName              = helper.ReadString();
     ModelId              = helper.ReadInt();
     ModelScale           = helper.ReadFloat();
     WeaponID             = helper.ReadInt();
     RaceType             = helper.ReadInt();
     IsPush               = helper.ReadBool();
     AIType               = helper.ReadInt();
     Type                 = helper.ReadInt();
     BossAIXmlName        = helper.ReadString();
     BossAIXmlSubName     = helper.ReadString();
     InterSubType         = helper.ReadInt();
     NpcSay               = helper.ReadInt();
     Level                = helper.ReadInt();
     HPMax                = helper.ReadFloat();
     HPCount              = helper.ReadInt();
     PhyAttack            = helper.ReadFloat();
     MagAttack            = helper.ReadFloat();
     PhyDefend            = helper.ReadFloat();
     MagDefend            = helper.ReadFloat();
     HitRate              = helper.ReadFloat();
     Avoid                = helper.ReadFloat();
     CritRate             = helper.ReadFloat();
     CritParam            = helper.ReadFloat();
     Resist               = helper.ReadFloat();
     WoundParam           = helper.ReadFloat();
     AnitInterfereRate    = helper.ReadFloat();
     AnitInterruptRate    = helper.ReadFloat();
     AnitRepelRate        = helper.ReadFloat();
     AnitLauncherRate     = helper.ReadFloat();
     RotateSpeed          = helper.ReadFloat();
     SwitchRotateSpeed    = helper.ReadFloat();
     MoveSpeed            = helper.ReadFloat();
     AnimationSpeed       = helper.ReadFloat();
     AttackRange          = helper.ReadFloat();
     CallNpcRange         = helper.ReadFloat();
     AlertRange           = helper.ReadFloat();
     CancelAlertRange     = helper.ReadFloat();
     AlertPeriod          = helper.ReadFloat();
     LargeRate            = helper.ReadFloat();
     SmallRate            = helper.ReadFloat();
     VisionRange          = helper.ReadFloat();
     MaxChaseRange        = helper.ReadFloat();
     RetreatDistance      = helper.ReadFloat();
     RetreatSpeed         = helper.ReadFloat();
     RetreatTime          = helper.ReadFloat();
     StaminaMax           = helper.ReadInt();
     StaminaRestoreValue  = helper.ReadFloat();
     StaminaRestorePeriod = helper.ReadFloat();
     StaminaEvent         = helper.ReadInt();
     StaminaSkillID       = helper.ReadInt();
     StaminaReset         = helper.ReadFloat();
     GiftBuffIDList       = ConvertorTool.StringToList_Float(helper.ReadString());
     DropID               = helper.ReadInt();
     SkillList            = ConvertorTool.StringToList_Int(helper.ReadString());
     PassiveSkillList     = ConvertorTool.StringToList_Int(helper.ReadString());
     functionNum          = helper.ReadInt(); // NpcFuncArgs 的数量
     if (functionNum > 0)
     {
         NpcFuncArgs = new List <NpcFuncArg>();
         for (int i = 0; i < functionNum; ++i)
         {
             NpcFuncArg val = new NpcFuncArg();
             val.Load(helper);
             NpcFuncArgs.Add(val);
         }
     }
 }
コード例 #5
0
 public static bool SetValue <T>(PropertyInfo info, T obj, ICell cell)
 {
     if (info.PropertyType == typeof(string))
     {
         if ((cell != null) && (cell.CellType == CellType.STRING))
         {
             info.SetValue(obj, cell.StringCellValue, null);
         }
         else
         {
             info.SetValue(obj, "", null);
         }
     }
     else if (info.PropertyType == typeof(int))
     {
         if ((cell != null) && (cell.CellType == CellType.NUMERIC))
         {
             info.SetValue(obj, (int)cell.NumericCellValue, null);
         }
         else
         {
             info.SetValue(obj, 0, null);
         }
     }
     else if (info.PropertyType == typeof(float))
     {
         if ((cell != null) && (cell.CellType == CellType.NUMERIC))
         {
             info.SetValue(obj, (float)cell.NumericCellValue, null);
         }
         else
         {
             info.SetValue(obj, 0.0f, null);
         }
     }
     else if (info.PropertyType == typeof(bool))
     {
         if ((cell != null) && (cell.CellType == CellType.NUMERIC))
         {
             info.SetValue(obj, cell.NumericCellValue != 0, null);
         }
         else
         {
             info.SetValue(obj, false, null);
         }
     }
     else if (info.PropertyType == typeof(short))
     {
         if ((cell != null) && (cell.CellType == CellType.NUMERIC))
         {
             info.SetValue(obj, (short)cell.NumericCellValue, null);
         }
         else
         {
             info.SetValue(obj, 0, null);
         }
     }
     else if (info.PropertyType == typeof(List <int>))
     {
         string s = "";
         if (cell != null && cell.CellType == CellType.STRING)
         {
             s = cell.StringCellValue;
         }
         info.SetValue(obj, ConvertorTool.StringToList_Int(s), null);
     }
     else if (info.PropertyType == typeof(List <float>))
     {
         string s = "";
         if (cell != null && cell.CellType == CellType.STRING)
         {
             s = cell.StringCellValue;
         }
         info.SetValue(obj, ConvertorTool.StringToList_Float(s), null);
     }
     else if (info.PropertyType == typeof(List <string>))
     {
         string s = "";
         if (cell != null && cell.CellType == CellType.STRING)
         {
             s = cell.StringCellValue;
         }
         info.SetValue(obj, ConvertorTool.StringToList_String(s), null);
     }
     else
     {
         Debug.LogError("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name);
         return(false);
     }
     return(true);
 }
コード例 #6
0
    public static T GenericObj <T>(IRow row) where T : new()
    {
        int index = 0;
        T   obj   = new T();

        PropertyInfo[] propInfo = typeof(T).GetProperties();
        foreach (PropertyInfo info in propInfo)
        {
            ICell cell = row.GetCell(index++);
            if (info.PropertyType == typeof(string))
            {
                if (cell != null && cell.CellType == CellType.STRING)
                {
                    info.SetValue(obj, cell.StringCellValue, null);
                }
            }
            else if (info.PropertyType == typeof(int))
            {
                if (cell != null && cell.CellType == CellType.NUMERIC)
                {
                    info.SetValue(obj, (int)cell.NumericCellValue, null);
                }
            }
            else if (info.PropertyType == typeof(float))
            {
                if (cell != null && cell.CellType == CellType.NUMERIC)
                {
                    info.SetValue(obj, (float)cell.NumericCellValue, null);
                }
            }
            else if (info.PropertyType == typeof(bool))
            {
                if (cell != null && cell.CellType == CellType.NUMERIC)
                {
                    info.SetValue(obj, cell.NumericCellValue != 0, null);
                }
            }
            else if (info.PropertyType == typeof(short))
            {
                if (cell != null && cell.CellType == CellType.NUMERIC)
                {
                    info.SetValue(obj, (short)cell.NumericCellValue, null);
                }
            }
            else if (info.PropertyType == typeof(List <int>))
            {
                string s = "";
                if (cell != null && cell.CellType == CellType.STRING)
                {
                    s = cell.StringCellValue;
                }
                info.SetValue(obj, ConvertorTool.StringToList_Int(s), null);
            }
            else if (info.PropertyType == typeof(List <float>))
            {
                string s = "";
                if (cell != null && cell.CellType == CellType.STRING)
                {
                    s = cell.StringCellValue;
                }
                info.SetValue(obj, ConvertorTool.StringToList_Float(s), null);
            }
            else if (info.PropertyType == typeof(List <string>))
            {
                string s = "";
                if (cell != null && cell.CellType == CellType.STRING)
                {
                    s = cell.StringCellValue;
                }
                info.SetValue(obj, ConvertorTool.StringToList_String(s), null);
            }
            else
            {
                Debug.LogError("不支持的类型:" + info.PropertyType.ToString() + " " + info.Name);
            }
        }
        return(obj);
    }
コード例 #7
0
    public IEnumerator LoadDropItem(DropItemPerformanceType item)
    {
        yield return(new WaitForSeconds(0.2f));


        GameResPackage.AsyncLoadPackageData loadData = new GameResPackage.AsyncLoadPackageData();
        IEnumerator e = null;

        EventItemInfo eventInfo = GameTable.eventItemAsset.LookUp(item.m_intParam);

        DropItemPerformanceType.Type type = item.m_type;
        if (eventInfo != null)
        {
            type = (DropItemPerformanceType.Type)eventInfo.dropType;
        }

        switch (type)
        {
        // 卡牌
        case DropItemPerformanceType.Type.enCard:
        {
            DropItemPerformanceCard cardItem = (DropItemPerformanceCard)item;

            foreach (int cardId in cardItem.m_cardList)
            {
                e = NewDropItem(loadData, item, cardId);
                while (true)
                {
                    e.MoveNext();
                    if (loadData.m_isFinish)
                    {
                        break;
                    }
                    yield return(e.Current);
                }

                Debug.Log("....cardId:" + cardId);

                yield return(new WaitForSeconds(0.1f));
            }

            // 卡牌的增长数目
            Reward.Singleton.m_cardDesNum = Reward.Singleton.m_cardNum + cardItem.m_cardList.Count;

            break;
        }

        // 金钱
        case DropItemPerformanceType.Type.enGold:
        {
            // 如果有钱则掉落金币 效果
            if (item.m_intParam > 0)
            {
                int            min       = 15;
                int            max       = 30;
                WorldParamInfo worldInfo = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enDropGoldMinMax);
                if (null != worldInfo)
                {
                    List <int> cardList = ConvertorTool.StringToList_Int(worldInfo.StringTypeValue);
                    if (null != cardList && cardList.Count >= 2)
                    {
                        min = cardList[0];
                        max = cardList[1];
                    }
                }

                // 金币增长的数目
                int randomGold = UnityEngine.Random.Range(100, 1000);
                Reward.Singleton.m_goldDesNum = Reward.Singleton.m_goldNum + randomGold;

                int dropNum = UnityEngine.Random.Range(min, max);

                for (int i = 0; i < dropNum; i++)
                {
                    e = NewDropItem(loadData, item);
                    while (true)
                    {
                        e.MoveNext();
                        if (loadData.m_isFinish)
                        {
                            break;
                        }
                        yield return(e.Current);
                    }
                    yield return(new WaitForSeconds(0.01f));
                }
            }
            break;
        }

        // 钥匙
        case DropItemPerformanceType.Type.enKey:
        {
            e = NewDropItem(loadData, item, item.m_intParam);
            while (true)
            {
                e.MoveNext();
                if (loadData.m_isFinish)
                {
                    break;
                }
                yield return(e.Current);
            }
            break;
        }
        }
    }