Exemplo n.º 1
0
        /// <summary>
        /// Event handler for an enemy being smashed.
        /// </summary>
        /// <param name="spawner">Spawner the enemy is part of.</param>
        private void NotifySpawnerOfDeath(SpawnerNetwork spawner)
        {
            // Handle the named enemy death.
            if (spawner.Name == "Named_Enemies")
            {
                this.NamedEnemyDeath();
                return;
            }

            // Get the current deaths for the current zone.
            var sectionName   = spawner.Name.Substring(0, spawner.Name.Length - 6);
            var variableName  = "mobsDead" + sectionName;
            var mobDeathCount = this.GetVar <uint>(variableName);

            mobDeathCount += 1;

            // Change the spawners if the reset number was reached.
            if (mobDeathCount >= this.MobDeathResetNumber)
            {
                var zoneInfo = sectionName.Split('_');
                this.SpawnSection(sectionName, this.SectionMultipliers[zoneInfo[2]]);
                mobDeathCount = 0;
            }

            // Store the counter.
            this.SetVar(variableName, mobDeathCount);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates the object script.
 /// </summary>
 /// <param name="gameObject">Game object to control with the script.</param>
 public JailGate(GameObject gameObject) : base(gameObject)
 {
     if (gameObject.TryGetComponent <QuickBuildComponent>(out var quickBuild) && gameObject.Settings.TryGetValue("Wall", out var wallObject) && wallObject is string wall)
     {
         SpawnerNetwork pirateSpawner  = GetSpawnerByName($"Jail0{wall}");
         SpawnerNetwork captainSpawner = GetSpawnerByName($"JailCaptain0{wall}");
         Listen(quickBuild.OnStateChange, (state) =>
         {
             if (state == RebuildState.Completed)
             {
                 pirateSpawner.Deactivate();
                 captainSpawner.Deactivate();
             }
             else if (state == RebuildState.Resetting)
             {
                 pirateSpawner.Reset();
                 pirateSpawner.Activate();
                 captainSpawner.Reset();
                 captainSpawner.Activate();
             }
         });
     }
 }