Exemplo n.º 1
0
        public override Hazard Build(Chunk containingChunk, Space containingSpace)
        {
            // If we cannot guarantee this is a safe place to build, don't
            if (!containingChunk.Contains(_anchorPosition) ||
                containingChunk.GetBlockForPosition(_anchorPosition) == null)
            {
                return(null);
            }

            while (_maxSegments <= MAX_STALAG_SEGMENTS)
            {
                var nextSegmentLocation = Position + (_facingDirection * _maxSegments);
                if (!containingSpace.Contains(nextSegmentLocation) ||
                    !containingChunk.Contains(nextSegmentLocation) ||
                    containingSpace.GetBlockType(nextSegmentLocation) != Blocks.BlockTypes.None)
                {
                    break;
                }
                else
                {
                    _maxSegments++;
                }
            }

            var stalag = HazardLoader.CreateHazard(HazardTypes.Stalag, Position) as StalagHazard;

            stalag.Initialize(_facingDirection, Chance.Range(1, _maxSegments));
            return(stalag);
        }
Exemplo n.º 2
0
        public override Hazard ToObject()
        {
            var stalag = HazardLoader.CreateHazard(HazardTypes.Stalag, _anchorPosition) as StalagHazard;

            stalag.Initialize(_facingDirection, _numSegments);
            return(stalag);
        }