Example #1
0
        private void DestroySegment(StalagSegment segment)
        {
            while (_stalagSegments.Peek() != segment)
            {
                DropSegment(_stalagSegments.Peek());
            }

            _stalagSegments.Pop();
            Destroy(segment.gameObject);

            RemoveSegment(segment);
        }
Example #2
0
        private void DropSegment(StalagSegment segment)
        {
            while (_stalagSegments.Peek() != segment)
            {
                DropSegment(_stalagSegments.Peek());
            }

            _stalagSegments.Pop();
            segment.Crumble();

            RemoveSegment(segment);
        }
Example #3
0
        private void RemoveSegment(StalagSegment segment)
        {
            segment.OnHit -= OnSegmentHit;

            if (_stalagSegments.Count == 0)
            {
                OnHazardDestroyed.Raise(this);
                Destroy(this);
            }
            else
            {
                OnHazardChanged.Raise(this);
            }
        }
Example #4
0
        private bool ApplyHitToSegment(StalagSegment segment, int damage, int force)
        {
            var isSegmentGone = false;

            segment.Health    -= damage;
            segment.Stability -= force;

            if (segment.Health <= 0)
            {
                DestroySegment(segment);
                isSegmentGone = true;
            }
            else if (segment.Stability <= 0)
            {
                DropSegment(segment);
                isSegmentGone = true;
            }

            return(isSegmentGone);
        }
Example #5
0
 private void InitializeSegment(StalagSegment segment, int numberFromTip)
 {
     segment.OnHit += OnSegmentHit;
     segment.Initialize(HEALTH_PER_STALAG_SEGMENT * numberFromTip, STABILITY_PER_STALAG_SEGMENT * numberFromTip);
     _stalagSegments.Push(segment);
 }