Beispiel #1
0
    public static void WriteSkills()
    {
        string stageMapPath = Application.dataPath + "/XiaoChu/ResourcesTest/SkillBase.csv";

        System.IO.StreamWriter write = new System.IO.StreamWriter(stageMapPath);
        string titleLine             = "ID,,,,CD,PreCD,Script,SameRate,BombRate,TrapType,TrapParam1,TrapParam2,TrapParam3,TrapParam4";

        write.WriteLine(titleLine);
        foreach (var skillInfo in _BoxSkillList)
        {
            string skillLine = skillInfo._ID + ",,,," + skillInfo._CD + "," + skillInfo._PreCD + ",SkillBoxBall," +
                               GameDataValue.ConfigFloatToInt(skillInfo._IncludeSameRate) + "," + GameDataValue.ConfigFloatToInt(skillInfo._IncludeBombRate)
                               + "," + (int)skillInfo._TrapType;
            for (int i = 0; i < 4; ++i)
            {
                if (i < skillInfo._TrapParam.Count)
                {
                    skillLine += "," + skillInfo._TrapParam[i];
                }
                else
                {
                    skillLine += ",0";
                }
            }
            write.WriteLine(skillLine);
        }
        write.Close();
    }
Beispiel #2
0
    public void InitMonster(MonsterBaseRecord monster, int level)
    {
        _MonsterRecord = monster;

        _Attack = (GameDataValue.GetLevelHP(level)) * monster.Attack / 10;
        _Attack = Mathf.Max(_Attack, 1);

        float hprate = GameDataValue.GetMonsterHPRate(monster.HP);

        _HP          = (int)(GameDataValue.GetLevelAtk(level) * BattleField.GetBallNumRate(12) * hprate * GameDataValue.GetMonsterHPGemFix(level));
        _MaxHP       = _HP;
        _ElementType = monster.ElementType;
        //_Diff = LogicManager.Instance.EnterStageInfo.Level;
        _Diff   = 100;
        _Skills = new List <SkillBase>();
        foreach (var skillrecord in monster.Skills)
        {
            if (skillrecord == null)
            {
                continue;
            }

            var skillBase = SkillBase.GetSkillInstance(skillrecord);
            if (skillBase != null)
            {
                skillBase.InitSkill(this, skillrecord);
                _Skills.Add(skillBase);
            }
        }
    }
Beispiel #3
0
    public void RefreshGemItem(GemDataItem gemItem)
    {
        _Name.text = StrDictionary.GetFormatStr(gemItem.GemRecord.NameDict);
        ResourceManager.Instance.SetImage(_Icon, gemItem.GemRecord.Icon);
        if (gemItem.GemExAttrRecord != null)
        {
            _SkillPanel.gameObject.SetActive(true);
            ResourceManager.Instance.SetImage(_SkillIcon, gemItem.GemExAttrRecord.Icon);
            _SkillDesc.text = StrDictionary.GetFormatStr(gemItem.GemExAttrRecord.NameDict);
        }
        else
        {
            _SkillPanel.gameObject.SetActive(false);
        }

        for (int i = 0; i < _AttrText.Count; ++i)
        {
            _AttrText[i].text = GameDataValue.ConfigIntToPersent(gemItem.GemRecord.Attrs[i]) + "%";
        }

        if (gemItem == GemDataPack.Instance.SelectedGemItem)
        {
            _BtnEquip.gameObject.SetActive(false);
            _BtnEquiped.gameObject.SetActive(true);
        }
        else
        {
            _BtnEquip.gameObject.SetActive(true);
            _BtnEquiped.gameObject.SetActive(false);
        }
    }
Beispiel #4
0
    public void Refresh()
    {
        _CurrencyOwn.ShowOwnCurrency(_ExChangeMoneyID);

        int value = _CostDiamond.Value;

        _Exchange1.ShowCurrency(_ExChangeMoneyID, GameDataValue.DiamondExchange(_ExChangeMoneyID, value));
    }
Beispiel #5
0
    public float GetHPBallRate()
    {
        if (GemExAttrRecord != null && GemExAttrRecord.Script.Equals("HPEnhance"))
        {
            int param = int.Parse(GemExAttrRecord.Params[0]);
            return(GameDataValue.ConfigIntToFloat(param));
        }

        float addHPRate = GameDataValue.ConfigIntToFloat(GemDataPack.Instance.SelectedGemItem.GemRecord.Attrs[5]);

        return(addHPRate);
    }
Beispiel #6
0
    public override void InitSkill(MotionBase motionBase, SkillBaseRecord skillBase)
    {
        base.InitSkill(motionBase, skillBase);

        _SameRate = GameDataValue.ConfigIntToFloat(skillBase.Param[0]);
        _BombRate = GameDataValue.ConfigIntToFloat(skillBase.Param[1]);
        _TrapType = (BallType)skillBase.Param[2];
        _FindPosNum.Clear();
        _FindPosNum.Add(skillBase.Param[3]);
        _FindPosNum.Add(skillBase.Param[4]);
        _FindPosNum.Add(skillBase.Param[5]);
        _FindPosNum.Add(skillBase.Param[6]);
    }
        private void LoadConfigData(byte[] data, string dataClassName, int enConfig)
        {
            using (var memoryStream = new MemoryStream(data))
            {
                using (var binaryReader = new BinaryReader(memoryStream, Encoding.ASCII))
                {
                    List<GameDataValue> keyTypes = new List<GameDataValue>();
                    int count = binaryReader.ReadInt16();

                    if (count == 0)
                    {
                        return;
                    }

                    for (int i = 0; i < count; i++)
                    {
                        GameDataValue gameDataValue = new GameDataValue();
                        gameDataValue.KeyName = new string(binaryReader.ReadChars(binaryReader.ReadInt16()));
                        gameDataValue.KeyType = binaryReader.ReadInt16();
                        keyTypes.Add(gameDataValue);
                    }

                    //定义参数类型数组  
                    Type[] tps = new Type[2];
                    tps[0] = typeof(BinaryReader);
                    tps[1] = typeof(List<GameDataValue>);

                    //定义参数数组  
                    object[] obj = new object[2];
                    obj[0] = (object)binaryReader;
                    obj[1] = (object)keyTypes;

                    short keyType = (short)EnConfigKeyType.OneID;
                    keyType = binaryReader.ReadInt16();

                    List<GameData> dataList = new List<GameData>();
                    var type = Type.GetType(dataClassName);// 通过类名获取同名类

                    if (type != null)
                    {
                        while (binaryReader.PeekChar() != -1)
                        {
                            var gameData = type.GetConstructor(tps).Invoke(obj) as GameData;
                            dataList.Add(gameData);
                        }

                        GameDataUtility.InitConfig(enConfig, keyType, dataList);
                    }
                }
            }
        }
Beispiel #8
0
    public void OnBtnExchange()
    {
        int costDiamondValue = _CostDiamond.Value;

        if (PlayerDataPack.Instance.DecMoney(PlayerDataPack.MoneyDiamond, costDiamondValue))
        {
            int addValue = GameDataValue.DiamondExchange(_ExChangeMoneyID, costDiamondValue);
            PlayerDataPack.Instance.AddMoney(_ExChangeMoneyID, addValue);
        }
        else
        {
            UIRechargePack.ShowAsyn();
        }
    }
Beispiel #9
0
    public Vector2 GetNextLevelAttrs()
    {
        int tarLevel = Level + 1;

        if (IsLevelMaxLevel(Level))
        {
            tarLevel = Level;
        }
        if (tarLevel == 1)
        {
            tarLevel = 2;
        }

        int attrLevel = GetUpGrageLevelToAttrLevel(tarLevel);

        return(new Vector2(GameDataValue.GetLevelAtk(attrLevel), GameDataValue.GetLevelHP(attrLevel)));
    }
Beispiel #10
0
    private void InitRole()
    {
        _RoleMotion = new MotionBase();

        var attr = WeaponDataPack.Instance.SelectedWeaponItem.GetCurLevelAttrs();
        //_RoleMotion._Attack = (int)attr[0];
        //_RoleMotion._MaxHP = (int)attr[1];

        int stageLevel = int.Parse(_StageRecord.Id);
        int testLevel  = stageLevel;
        int attrValue  = Mathf.Max(testLevel, 1);

        _RoleMotion._Attack = GameDataValue.GetLevelAtk(attrValue);
        _RoleMotion._MaxHP  = GameDataValue.GetLevelHP(attrValue);

        _RoleMotion._HP          = _RoleMotion._MaxHP;
        _RoleMotion._ElementType = ELEMENT_TYPE.NONE;
    }
Beispiel #11
0
    public static float GetRoleAtkElementRate(ELEMENT_TYPE eleType)
    {
        GemRecord gemRecord = null;

        if (GemDataPack.Instance.SelectedGemItem.GemRecord != null)
        {
            gemRecord = GemDataPack.Instance.SelectedGemItem.GemRecord;
        }

        if (gemRecord == null)
        {
            return(1);
        }

        int baseValue = 10000;

        switch (eleType)
        {
        case ELEMENT_TYPE.FIRE:
            baseValue = gemRecord.Attrs[0];
            break;

        case ELEMENT_TYPE.ICE:
            baseValue = gemRecord.Attrs[1];
            break;

        case ELEMENT_TYPE.WIND:
            baseValue = gemRecord.Attrs[2];
            break;

        case ELEMENT_TYPE.LIGHT:
            baseValue = gemRecord.Attrs[3];
            break;

        case ELEMENT_TYPE.DARK:
            baseValue = gemRecord.Attrs[4];
            break;
        }



        return(GameDataValue.ConfigIntToFloat(baseValue));
    }
Beispiel #12
0
    public static List <string> GetStarInfo(StageMapRecord stageMapRecord, int level)
    {
        List <string> starInfos = new List <string>();

        starInfos.Add("PassStage");

        int round   = 0;
        int monAtk  = 0;
        int roleAtk = 0;
        int waveIdx = 0;

        while (round < 50)
        {
            ++round;
            roleAtk += 1;
            float tempAtk = roleAtk;
            foreach (var monster in stageMapRecord._MapStageLogic._Waves[waveIdx].NPCs)
            {
                //var monsterInfo = TableReader.MonsterBase.GetRecord(monster);
                var   monsterInfo = RandomMonsterList[monster];
                float monHP       = GameDataValue.GetMonsterHPRate(monsterInfo.HpRate);
                tempAtk = tempAtk - monHP;
            }

            if (tempAtk > 0)
            {
                ++waveIdx;
                roleAtk = 0;
                if (waveIdx >= stageMapRecord._MapStageLogic._Waves.Count)
                {
                    break;
                }
            }
        }
        Debug.Log("GetStarInfo round:" + round);
        int randomStar2 = Random.Range(0, 2);

        if (randomStar2 == 0)
        {
            starInfos.Add("FightRound," + (round + 1));
        }
        else
        {
            int remainHpRandom = Random.Range(4, 9);
            starInfos.Add("RemainHP," + remainHpRandom);
        }

        int mapTrapCnt = 0;

        foreach (var trap in stageMapRecord._MapDefaults)
        {
            if (trap.Value.Contains("11") ||
                trap.Value.Contains("12") ||
                trap.Value.Contains("13") ||
                trap.Value.Contains("14"))
            {
                ++mapTrapCnt;
            }
        }

        if (mapTrapCnt > 8)
        {
            if (level > MAX_LEVEL * 0.7f)
            {
                starInfos.Add("Trap," + (mapTrapCnt));
            }
            else if (level > MAX_LEVEL * 0.5f)
            {
                starInfos.Add("Trap," + (mapTrapCnt - 1));
            }
            else if (level > MAX_LEVEL * 0.3f)
            {
                starInfos.Add("Trap," + (mapTrapCnt - 2));
            }
            else
            {
                starInfos.Add("Trap," + (mapTrapCnt - 3));
            }
        }
        else
        {
            float levelRate = (level / MAX_LEVEL) * 0.4f + 0.2f;
            starInfos.Add("Bomb," + (int)(round * levelRate));
        }

        return(starInfos);
    }
Beispiel #13
0
    public static List <int> GetHpBalls(StageMapRecord stageRecord)
    {
        List <int> fullDamageRound = new List <int>();

        int round   = 0;
        int monAtk  = 0;
        int roleAtk = 0;
        int waveIdx = 0;

        while (fullDamageRound.Count < 10)
        {
            ++round;
            roleAtk += 1;
            float tempAtk = roleAtk;
            foreach (var monster in stageRecord._MapStageLogic._Waves[waveIdx].NPCs)
            {
                var   monsterInfo = RandomMonsterList[monster];
                float monHP       = GameDataValue.GetMonsterHPRate(monsterInfo.HpRate);
                tempAtk = tempAtk - monHP;
                if (tempAtk <= 0)
                {
                    var atkSkill   = TableReader.SkillBase.GetRecord(monsterInfo.AttackSkill);
                    int skillRound = round - 1;
                    if (skillRound - atkSkill.PreCD == 0)
                    {
                        monAtk += monsterInfo.AttackRate;
                    }
                    else if (skillRound - atkSkill.PreCD > 0)
                    {
                        if (atkSkill.CD == 0)
                        {
                            monAtk += monsterInfo.AttackRate;
                        }
                        else if ((skillRound - atkSkill.PreCD) % atkSkill.CD == 0)
                        {
                            monAtk += monsterInfo.AttackRate;
                        }
                    }
                }
            }

            if (tempAtk > 0)
            {
                ++waveIdx;
                roleAtk = 0;
                if (waveIdx >= stageRecord._MapStageLogic._Waves.Count)
                {
                    break;
                }
            }

            if (monAtk >= 5)
            {
                monAtk = 0;
                fullDamageRound.Add(round);
            }
        }

        List <int> hpBall = new List <int>();

        foreach (var fullDamage in fullDamageRound)
        {
            int ballCnt = 0;
            for (int i = 0; i < fullDamage; ++i)
            {
                if (stageRecord._MapDefaults.Count > 4)
                {
                    ballCnt += Random.Range(10, 15);
                }
                else if (stageRecord._MapDefaults.Count > 6)
                {
                    ballCnt += Random.Range(6, 12);
                }
                else
                {
                    ballCnt += Random.Range(12, 20);
                }
            }

            hpBall.Add(ballCnt);
        }
        return(hpBall);
    }
Beispiel #14
0
    public Vector2 GetCurLevelAttrs()
    {
        int attrLevel = GetUpGrageLevelToAttrLevel(Level);

        return(new Vector2(GameDataValue.GetLevelAtk(attrLevel), GameDataValue.GetLevelHP(attrLevel)));
    }