Exemple #1
0
        public void OnRoomDestroyed(RegisteredRoom room)
        {
            room.Destroyed -= OnRoomDestroyed;

            GameIp   = "";
            GamePort = -1;
            Room     = null;

            GameSpawnTask = null;

            State = Config.PlayAgainEnabled ? Packets.Lobbies.LobbyState.Preparations : Packets.Lobbies.LobbyState.GameOver;
        }
Exemple #2
0
 void Update()
 {
     if (spawnTaskList != null && spawnTaskList.Count > 0)
     {
         SpawnTask st = null;
         for (int i = 0; i < spawnTaskList.Count; i++)
         {
             st = spawnTaskList[i];
             if (st.isStop)
             {
                 spawnTaskList.Remove(st);
             }
             else
             {
                 st.Update(Time.deltaTime);
             }
         }
     }
     if (allEnemyCount != 0)
     {
         if (allEnemyCount == hasSpawnEnemy.Count)
         {
             bool isAllOver = true;
             foreach (var item in hasSpawnEnemy)
             {
                 if (item != null)
                 {
                     EnemyParent enemy = item.GetComponent <EnemyParent>();
                     if (enemy != null)
                     {
                         if (enemy.blood > 0)
                         {
                             isAllOver = false;
                             break;
                         }
                     }
                 }
             }
             if (isAllOver)
             {
                 result.SetActive(true);
             }
         }
     }
 }
Exemple #3
0
        public void SetGameSpawnTask(SpawnTask task)
        {
            if (task == null)
            {
                return;
            }

            if (GameSpawnTask == task)
            {
                return;
            }

            if (GameSpawnTask != null)
            {
                // Unsubscribe from previous game
                GameSpawnTask.StatusChanged -= OnSpawnServerStatusChanged;
                GameSpawnTask.Abort();
            }

            GameSpawnTask = task;

            task.StatusChanged += OnSpawnServerStatusChanged;
        }
Exemple #4
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;
            }
        }
    }