private void Produce()
        {
            VirusData data = new VirusData();

            data.SplitLevel      = SplitLevel;
            data.VirusColorLevel = CurColorLevel;
            data.HealthValue     = VirusTool.GetVirusHealthByColorLevel("SwallowVirus", VirusGameDataAdapter.GetLevel(), CurColorLevel);
            data.MoveSpeed       = 4;
            data.MoveDirection   = Quaternion.Euler(0, 0, Random.Range(0f, 360f)) * Vector3.up;

            float scale    = VirusTool.GetScaleByLevel(data.SplitLevel);
            var   newVirus = VirusMrg.Instance.SpawnVirus("SwallowVirus", data, transform.position, true);

            newVirus.transform.localScale = Vector3.zero;
            newVirus.transform.DOScale(new Vector3(scale, scale, 1), 0.5f).OnComplete(() =>
            {
                _isRunAway = false;
            });
        }
Пример #2
0
        protected override void RunAway()
        {
            var move = transform.GetComponent <VirusMove>();

            for (int i = 0; i < 3; i++)
            {
                int        level      = (int)(SplitLevel - 1);
                SplitLevel splitLevel = level < 0 ? SplitLevel.Level1 : (SplitLevel)level;
                float      angle      = Random.Range(i * 120, (i + 1) * 120);
                VirusData  data       = new VirusData();
                data.VirusColorLevel = VirusTool.GetColorLevel(CurColorLevel);
                data.SplitLevel      = splitLevel;
                data.MoveSpeed       = move.OriginSpeed;
                data.MoveDirection   = Quaternion.Euler(0, 0, angle) * Vector3.right;
                int t = VirusGameDataAdapter.GetLevel();
                data.HealthValue = VirusTool.GetVirusHealthByColorLevel("DartVirus", t, data.VirusColorLevel);
                VirusMrg.Instance.SpawnVirus("DartVirus", data, transform.position, true);
            }
        }
Пример #3
0
 protected void Divide(string virusName, ColorLevel colorLevel, int count)
 {
     if (SplitLevel > SplitLevel.Level1)
     {
         Vector3 pos   = transform.position;
         var     level = SplitLevel - 1;
         var     move  = transform.GetComponent <VirusMove>();
         for (int i = 0; i < count; i++)
         {
             VirusData data1 = new VirusData();
             data1.VirusColorLevel = VirusTool.GetColorLevel(colorLevel);
             data1.SplitLevel      = level;
             data1.MoveSpeed       = move.OriginSpeed;
             data1.MoveDirection   = Quaternion.Euler(0, 0, Random.Range(-45f, 45f)) * Vector3.up;
             data1.HealthValue     = VirusTool.GetVirusHealthByColorLevel(virusName, VirusGameDataAdapter.GetLevel(), data1.VirusColorLevel);
             VirusMrg.Instance.SpawnVirus(virusName, data1, pos, false);
         }
     }
 }
    private IEnumerator Spawn()
    {
        List <WaveVirusItem> items = WaveVirusDataAdapter.GetWaveVirus();

        int count = items.Count;
        int cc    = 0;

        _isSpawned = false;
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(0.3f, 0.8f)));

            VirusData  data       = new VirusData();
            Vector3    dir        = Quaternion.Euler(0, 0, Random.Range(-20f, 20f)) * Vector3.down;
            SplitLevel splitLevel = items[cc].SplitLevel;
            string     virusName  = items[cc].VirusName.ToString();

            int level = VirusGameDataAdapter.GetLevel();
            data.VirusColorLevel = items[cc].ColorLevel;
            data.HealthValue     = VirusTool.GetVirusHealthByColorLevel(virusName, level, data.VirusColorLevel);
            data.MoveSpeed       = 3;
            data.MoveDirection   = dir;
            data.SplitLevel      = splitLevel;
            SpawnVirus(virusName, data);

            cc++;
            if (cc >= count)
            {
                _isSpawned = true;
                WaveVirusDataAdapter.WaveIndex++;
                if (WaveVirusDataAdapter.WaveIndex >= WaveVirusDataAdapter.MaxWave)
                {
                    WaveVirusDataAdapter.IsNextWave = false;
                }
                yield break;
            }
        }
    }