Example #1
0
        public void Start()
        {
            if (SubmarineLiveMixin == null)
            {
                Utilities.Log.Error("ExternalDamageManager has not had the submarine's LiveMixin assigned. Destroying...");
                Destroy(this);
                return;
            }

            if (DamagePoints == null || DamagePoints.childCount == 0)
            {
                Utilities.Log.Error("ExternalDamageManager has no damage points object assigned. Destroying...");
                Destroy(this);
                return;
            }

            if (DamagePointGameObjects == null || DamagePointGameObjects.Count == 0)
            {
                Utilities.Log.Error("ExternalDamageManager has no damage points prefab assigned. Destroying...");
                Destroy(this);
                return;
            }

            damagePoints     = new List <ExternalDamagePoint>();
            freeDamagePoints = new List <ExternalDamagePoint>();
            foreach (Transform potentialDamagePoint in DamagePoints)
            {
                ExternalDamagePoint damagePoint = CreateDamagePoint(potentialDamagePoint);
                damagePoints.Add(damagePoint);
                freeDamagePoints.Add(damagePoint);
                damagePoint.gameObject.SetActive(false);
            }
        }
Example #2
0
        private ExternalDamagePoint CreateDamagePoint(Transform position)
        {
            int        randomPrefab   = Random.Range(0, DamagePointGameObjects.Count - 1);
            int        randomParticle = Random.Range(0, DamagePointParticleEffects.Count - 1);
            GameObject mainGO         = Utils.SpawnZeroedAt(DamagePointGameObjects[randomPrefab], position, false);
            GameObject particles      = Utils.SpawnZeroedAt(DamagePointParticleEffects[randomParticle], mainGO.transform, false);

            mainGO.AddComponent <BoxCollider>();
            ExternalDamagePoint damagePoint = mainGO.AddComponent <ExternalDamagePoint>();

            damagePoint.ExternalDamageManager = this;
            return(damagePoint);
        }
Example #3
0
        public void EnableMultipleDamagePoints(int amount)
        {
            for (int i = 0; i < amount; i++)
            {
                if (freeDamagePoints.Count == 0)
                {
                    return;
                }

                int randomDamagePoint           = Random.Range(0, freeDamagePoints.Count - 1);
                ExternalDamagePoint damagePoint = freeDamagePoints[randomDamagePoint];
                freeDamagePoints.Remove(damagePoint);
                damagePoint.NeedsRepairing();
                SendMessage("ExternalDamagePointCreated", damagePoint, SendMessageOptions.DontRequireReceiver);
            }
        }
Example #4
0
 public void DamagePointRepaired(ExternalDamagePoint damagePoint)
 {
     freeDamagePoints.Add(damagePoint);
     SubmarineLiveMixin.AddHealth(GetUsedDamagePointsCount() == 0 ? SubmarineLiveMixin.maxHealth : GetHealthPerDamagePoint());
     SendMessage("ExternalDamagePointRepaired", damagePoint, SendMessageOptions.DontRequireReceiver);
 }