Example #1
0
    private void OnPlayEnter()
    {
#if UNITY_EDITOR
        Debug.Log("Level: " + VirusGameDataAdapter.GetLevel());
#endif
        _uiMrg.MainPanel.Active();
        _virusPlayer.Invincible = false;
        _virusPlayer.SetPlayerState(true, true);
        virusMrg.GameStart();
    }
Example #2
0
 private void OnPlayEnter()
 {
     Debug.Log("Level:" + VirusGameDataAdapter.GetLevel());
     _uiMrg.TitlePanel.UnActive();
     _uiMrg.UpgradePanel.UnActive();
     _uiMrg.MainPanel.Active();
     _virusPlayer.Invincible = false;
     _virusPlayer.SetPlayerState(true, true);
     virusMrg.GameStart();
 }
Example #3
0
    public void GameStart()
    {
        _minOrderIndex = 0;
        _maxOrderIndex = 5000;
        _percent.Value = 1;
        _curCount      = 0;
        _isTiped       = false;

        _virusObjects = new List <GameObject>();
        _originCount  = WaveVirusDataAdapter.Load(VirusGameDataAdapter.GetLevel());
        StartCoroutine(Spawn());
    }
Example #4
0
        private void SpawnRightBullet()
        {
            var obj = BulletPools.Instance.Spawn("ViceBullet_1");

            obj.transform.parent        = _rightShootPos;
            obj.transform.localPosition = Vector3.zero;

            float value = Random.Range(5f, 10f) * VirusGameDataAdapter.GetLevel();

            _rightBullet = obj.GetComponent <ViceBullet1>();
            _rightBullet.Initi();
            _rightBullet.Initi(value);
        }
Example #5
0
        public override float StartCure(ICure icure, float healthValue)
        {
            if (Mathf.Abs(TotalHealth - VirusHealth.Value) > 0.1f)
            {
                _virusHealthAddEffect.StartHealthEffect(icure);
            }
            float vv         = base.StartCure(icure, healthValue);
            var   virusLevel = VirusTool.GetVirusColorLevel("VampireVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value);

            if (virusLevel != CurColorLevel)
            {
                CurColorLevel = virusLevel;
                VirusSprite.Initi(CurColorLevel);
                transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel);
            }
            return(vv);
        }
Example #6
0
        public override float StartCure(ICure iCure, float healthValue)
        {
            float vv         = base.StartCure(iCure, healthValue);
            var   virusLevel = VirusTool.GetVirusColorLevel("RegenerativeVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value);

            if (virusLevel != CurColorLevel)
            {
                CurColorLevel = virusLevel;
                VirusSprite.Initi(CurColorLevel);
                transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel);
            }
            if (Mathf.Abs(VirusHealth.Value - TotalHealth) < 0.1f)
            {
                _virusHealthAddEffect.StopHealthEffect(this);
            }
            return(vv);
        }
Example #7
0
    public virtual void Death(bool isEffect, bool isDivide, bool isCoin, bool isProp)
    {
        IsDeath = true;
        int level = VirusGameDataAdapter.GetLevel();
        int coin  = VirusTool.GetVirusDeathCoin(level);

        if (isEffect)
        {
            float scale     = transform.localScale.x;
            int   index     = Random.Range(1, 5);
            var   explosion = EffectPools.Instance.Spawn("Explosion" + index);
            explosion.transform.localScale = new Vector3(scale * 2f, scale * 2f, 1);
            explosion.transform.position   = transform.position;
            explosion.GetComponent <VirusFragmentMrg>().Initi(index - 1, Random.Range(5, 10));
            VirusSoundMrg.Instance.PlaySound(VirusSoundType.VirusDeath);
            VirusCameraShake.Instance.Shake();
        }

        if (isCoin)
        {
            if (coin > 0)
            {
                VirusGameDataAdapter.AddLevelCoin(coin);
                int count = Random.Range(1, 4);
                for (int i = 0; i < count; i++)
                {
                    EventManager.TriggerEvent(new UIVirusAddLevelCoinEvent(transform.position));
                }
            }
        }

        if (isProp)
        {
            string propName = VirusTool.GetPropName(level);
            if (!propName.Equals("None") && SplitLevel > SplitLevel.Level1)
            {
                var prop = PropPools.Instance.Spawn(propName + "Prop");
                prop.transform.position = transform.position;
                prop.GetComponent <VirusPropMove>().Initi();
                ScenePropMrg.Instance.Add(prop);
            }
        }
        VirusMrg.Instance.Remove(gameObject);
    }
Example #8
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);
            }
        }
Example #9
0
        public override void Injured(float damageValue, bool isEffect)
        {
            if (VirusHealth.Value - damageValue <= 0)
            {
                Death(true, true, true, true);
                return;
            }
            VirusHealth.Value -= damageValue;
            var virusLevel = VirusTool.GetVirusColorLevel("VampireVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value);

            if (virusLevel != CurColorLevel)
            {
                CurColorLevel = virusLevel;
                VirusSprite.Initi(CurColorLevel);
                transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel);
            }
            if (isEffect)
            {
                virusHurtEffect.StartHurtEffect();
            }
        }
Example #10
0
    /// <summary>
    /// 初始化4个单元地图
    /// </summary>
    public void Init()
    {
        m_MapData.m_MapList.Add(m_MapData.m_MapObj.transform);
        for (int i = 0; i < m_MapData.m_MapCount - 1; i++)
        {
            GameObject obj = QyCreateObject.Instantiate(m_MapData.m_MapObj, m_MapData.m_Parent);
            if (obj != null)
            {
                m_MapData.m_MapList.Add(obj.transform);
            }
        }

        for (int i = 0; i < m_MapData.m_MapCount; i++)
        {
            Vector3 pos = Vector3.zero;
            pos.x = (i - 1) * m_MapData.m_DisX;
            m_MapData.m_MapList[i].name          = "map0" + (i + 1).ToString();
            m_MapData.m_MapList[i].localPosition = pos;
            if (i != 1)
            {
                m_MapData.m_MapList[i].localScale = new Vector3(m_MapData.m_MinScale, m_MapData.m_MinScale, 1f);
            }
            else
            {
                m_MapData.m_MapList[i].localScale = new Vector3(m_MapData.m_MaxScale, m_MapData.m_MaxScale, 1f);
            }
        }

        if (IGamerProfile.Instance != null)
        {
            m_MapData.m_MaxLevel       = IGamerProfile.gameLevel.mapData.Length;
            m_MapData.m_UnlockMaxLevel = IGamerProfile.Instance.getLastLockedMap + 1;
        }
        m_MapData.m_CurLevel = VirusGameDataAdapter.GetLevel();
        //m_MapData.m_CurLevel = 2; m_MapData.m_MaxLevel = 2; m_MapData.m_UnlockMaxLevel = 1; //test
        InitCurrentLevel();
        UpdateLevalInfo();
        UpdateMapLevelLock();
    }
    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;
            }
        }
    }
Example #12
0
        public override void Injured(float damageValue, bool isEffect)
        {
            if (VirusHealth.Value - damageValue <= 0)
            {
                Death(true, true, true, true);
                return;
            }
            VirusHealth.Value -= damageValue;
            var virusLevel = VirusTool.GetVirusColorLevel("RegenerativeVirus", VirusGameDataAdapter.GetLevel(), VirusHealth.Value);

            if (virusLevel != CurColorLevel)
            {
                CurColorLevel = virusLevel;
                VirusSprite.Initi(CurColorLevel);
                transform.GetComponent <BubbleEffectMrg>().SetBubbleSprite(CurColorLevel);
            }
            if (isEffect)
            {
                _virusHurtEffect.StartHurtEffect();
            }
            _virusHealthAddEffect.StopHealthEffect(this);
            _totalTime = 0.5f;
            _ishurt    = true;
        }
        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;
            });
        }
Example #14
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 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);
    }