Exemple #1
0
    void Callback(object param)
    {
        EachWaveConfig ewc = (EachWaveConfig)param;
        GameObject     go  = null;

        foreach (var item in ewc.enemyTypelist)
        {
            string resourceName = string.Empty;
            go = Instantiate(Resources.Load(item.model)) as GameObject;
            EnemyParent enemyParent = go.GetComponent <EnemyParent>();
            enemyParent.blood                  = item.blood;
            enemyParent.maxAttackDistance      = item.maxAttackDistance;
            enemyParent.walkSpeed              = item.walkSpeed;
            enemyParent.attackRepeatRateTime   = item.attackRepeatRateTime;
            enemyParent.attackValue            = item.attackValue;
            enemyParent.recoverBatteryDataBase = item.recoverBatteryDataBase;

            go.transform.position = ewc.point.position;

            HandleDic(ewc.point, go);

            hasSpawnEnemy.Add(go);
        }
        if (sPointWithdwarningDic.ContainsKey(ewc.point))
        {
            Transform        tt = sPointWithdwarningDic[ewc.point];
            DirectionWarning dw = tt.GetComponent <DirectionWarning>();
            if (dw != null)
            {
                dw.PlayAnim();
            }
        }
    }
Exemple #2
0
    void Start()
    {
        if (enemySpawnPointList != null && enemySpawnPointList.Count > 0)
        {
            EachWaveConfig ewc = new EachWaveConfig();
            ewc.startTime = 2;
            Transform pos = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 6, attackRepeatRateTime = 4, model = "InfantryEnemy", attackValue = 60, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 5;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 5, attackRepeatRateTime = 5, model = "InfantryEnemy", attackValue = 50, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 12;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1250, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 70, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 1;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1200, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 65, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);


            ewc               = new EachWaveConfig();
            ewc.startTime     = 12;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 35, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 6;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1280, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 30, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 5;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1320, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 55, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 8;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 2300, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "BossEnemy", attackValue = 60, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 10;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 2000, maxAttackDistance = 3, walkSpeed = 4, attackRepeatRateTime = 3, model = "BossEnemy", attackValue = 100, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);


            ewc               = new EachWaveConfig();
            ewc.startTime     = 20;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 6, attackRepeatRateTime = 4, model = "InfantryEnemy", attackValue = 60, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 22;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 5, attackRepeatRateTime = 5, model = "InfantryEnemy", attackValue = 50, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 39;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1250, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 70, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 25;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1200, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 65, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 35;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1300, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 35, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 40;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1280, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 30, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 24;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 1320, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "InfantryEnemy", attackValue = 55, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 12;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 2300, maxAttackDistance = 3, walkSpeed = 7, attackRepeatRateTime = 3, model = "BossEnemy", attackValue = 60, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);

            ewc               = new EachWaveConfig();
            ewc.startTime     = 42;
            pos               = enemySpawnPointList[UnityEngine.Random.Range(0, enemySpawnPointList.Count - 1)];
            ewc.point         = pos;
            ewc.enemyTypelist = new List <EnemyParent>()
            {
                new InfantryEnemy()
                {
                    blood = 2000, maxAttackDistance = 3, walkSpeed = 4, attackRepeatRateTime = 3, model = "BossEnemy", attackValue = 100, recoverBatteryDataBase = recoverBatteryDataBase
                }
            };
            eachWaveConfigList.Add(ewc);
        }

        if (eachWaveConfigList != null && eachWaveConfigList.Count > 0)
        {
            SpawnTask st = null;
            foreach (var item in eachWaveConfigList)
            {
                st            = new SpawnTask();
                st.startTime  = item.startTime;
                st.param      = item;
                st.onCallBack = Callback;
                spawnTaskList.Add(st);

                allEnemyCount += item.enemyTypelist.Count;
            }
        }
    }