Beispiel #1
0
    public static int Load(int level)
    {
        _data      = new WaveVirusData();
        _nameRoll  = new ChanceRoll();
        _colorRoll = new ChanceRoll();
        WaveIndex  = 0;
        IsNextWave = true;
        int endValue = 0;

        if (level == 2 || level % 5 == 0)
        {
            _data.HasBoss = true;
            _curBossName  = GetBossVirusName(level);
        }

        FillCache(level);
        FillVirusNames(level);
        FillNameRoll();
        FillColorRoll(level);
        endValue = FillData();
        if (_data.HasBoss)
        {
            WaveVirusItem boss = new WaveVirusItem();
            boss.SplitLevel = SplitLevel.Level5;
            boss.ColorLevel = ColorLevel.Level0;
            boss.VirusName  = _curBossName;
            _data.Data[1].Insert(0, boss);
            endValue += VirusTool.GetChildSplit(SplitLevel.Level5, boss.VirusName);
        }
        return(endValue);
    }
    public GameObject SpawnVirus(string virusName, VirusData data, Vector3 pos, bool isAdd)
    {
        //Debug.Log("***************virusName == " + virusName);
        var obj   = Pools.Spawn(virusName);
        var virus = obj.transform.GetComponent <BaseVirus>();

        if (!virusName.Equals("AdsorptionVirus"))
        {
            obj.transform.GetComponent <VirusSpriteSetter>().Set(_minOrderIndex);
            obj.GetComponent <BubbleEffectMrg>().Initi(_minOrderIndex, data.SplitLevel, data.VirusColorLevel);
            _minOrderIndex++;
        }
        else
        {
            obj.transform.GetComponent <VirusSpriteSetter>().Set(_maxOrderIndex);
            obj.GetComponent <BubbleEffectMrg>().Initi(_minOrderIndex, data.SplitLevel, data.VirusColorLevel);
            _maxOrderIndex--;
        }
        virus.Born(data);
        obj.transform.position = pos;
        if (isAdd)
        {
            var n = (VirusName)Enum.Parse(typeof(VirusName), virusName);
            _originCount += VirusTool.GetChildSplit(data.SplitLevel, n);
        }

        _virusObjects.Add(obj);
        return(obj);
    }
Beispiel #3
0
    private static int FillData()
    {
        List <WaveVirusItem> items = new List <WaveVirusItem>();

        foreach (var t1 in _data.Cache)
        {
            for (int i = 0; i < t1.Value; i++)
            {
                WaveVirusItem item      = new WaveVirusItem();
                int           nameIndex = _nameRoll.Roll();
                item.SplitLevel = t1.Key;
                item.VirusName  = _virusNames[nameIndex];
                item.ColorLevel = (ColorLevel)_colorRoll.Roll();
                items.Add(item);
            }
        }
        int count = items.Count;
        int t     = count / 2;

        items.Reshuffle();
        List <WaveVirusItem> list1 = new List <WaveVirusItem>();
        List <WaveVirusItem> list2 = new List <WaveVirusItem>();

        for (int i = 0; i < count; i++)
        {
            if (i < t - 1)
            {
                list1.Add(items[i]);
            }
            else
            {
                list2.Add(items[i]);
            }
        }
        _data.Data.Add(list1);
        _data.Data.Add(list2);
        int value = 0;

        for (int i = 0; i < items.Count; i++)
        {
            var item = items[i];
            value += VirusTool.GetChildSplit(item.SplitLevel, item.VirusName);
        }
        items.Clear();
        return(value);
    }
    public static int Load(int level)
    {
        _data      = new WaveVirusData();
        _nameRoll  = new ChanceRoll();
        _colorRoll = new ChanceRoll();
        WaveIndex  = 0;
        IsNextWave = true;
        if (IGamerProfile.Instance != null)
        {
            string bossType = IGamerProfile.gameLevel.mapData[level - 1].bossData.BossType;
            _data.HasBoss = bossType == "" ? false : true;
            if (_data.HasBoss == true)
            {
                _curBossName = GetBossVirusName(bossType);
            }
        }
        else
        {
            if (level == 2 || level % 5 == 0)
            {
                _data.HasBoss = true;
                _curBossName  = GetBossVirusName(level);
            }
        }

        FillCache(level);
        FillVirusNames(level);
        FillNameRoll();
        FillColorRoll(level);
        int endValue = FillData();

        if (_data.HasBoss)
        {
            WaveVirusItem boss = new WaveVirusItem();
            boss.SplitLevel = SplitLevel.Level5;
            boss.ColorLevel = ColorLevel.Level0;
            boss.VirusName  = _curBossName;
            _data.Data[MaxWave - 1].Insert(0, boss);
            endValue += VirusTool.GetChildSplit(SplitLevel.Level5, boss.VirusName);
        }
        return(endValue);
    }
    private static int FillData()
    {
        List <WaveVirusItem> items = new List <WaveVirusItem>();

        foreach (var t1 in _data.Cache)
        {
            for (int i = 0; i < t1.Value; i++)
            {
                WaveVirusItem item      = new WaveVirusItem();
                int           nameIndex = _nameRoll.Roll();
                item.SplitLevel = t1.Key;
                item.VirusName  = _virusNames[nameIndex];
                item.ColorLevel = (ColorLevel)_colorRoll.Roll();
                items.Add(item);
            }
        }

        int count = items.Count;

        items.Reshuffle();
        List <WaveVirusItem> list1 = new List <WaveVirusItem>();
        List <WaveVirusItem> list2 = new List <WaveVirusItem>();
        List <WaveVirusItem> list3 = new List <WaveVirusItem>();

        if (IGamerProfile.Instance != null)
        {
            int leval = VirusGameDataAdapter.GetLevel();
            FtGameLevel.MapData mpDt = IGamerProfile.gameLevel.mapData[leval - 1];
            int index  = 0;
            int maxNpc = mpDt.spawnDatas[index].NpcNum;
            for (int i = 0; i < count; i++)
            {
                if (list1.Count < maxNpc && index == 0)
                {
                    list1.Add(items[i]);
                    if (list1.Count == maxNpc)
                    {
                        index++;
                        maxNpc = mpDt.spawnDatas[index].NpcNum;
                    }
                }
                else if (list2.Count < maxNpc && index == 1)
                {
                    list2.Add(items[i]);
                    if (list2.Count == maxNpc)
                    {
                        index++;
                        maxNpc = mpDt.spawnDatas[index].NpcNum;
                    }
                }
                else
                {
                    list3.Add(items[i]);
                }
            }
        }
        else
        {
            int t = count / MaxWave;
            for (int i = 0; i < count; i++)
            {
                if (i < t)
                {
                    list1.Add(items[i]);
                }
                else if (i < 2 * t)
                {
                    list2.Add(items[i]);
                }
                else
                {
                    list3.Add(items[i]);
                }
            }
        }
        _data.Data.Add(list1);
        _data.Data.Add(list2);
        _data.Data.Add(list3);

        int value = 0;

        for (int i = 0; i < items.Count; i++)
        {
            var item = items[i];
            value += VirusTool.GetChildSplit(item.SplitLevel, item.VirusName);
        }
        items.Clear();
        return(value);
    }