예제 #1
0
        FogOfWarShape CreateShape(FogOfWar fow)
        {
            if (shapeType == FogOfWarShapeType.Circle)
            {
                FogOfWarShapeCircle shape = new FogOfWarShapeCircle();
                FillShape(fow, shape);
                shape.innerRadius = innerRadius;
                shape.angle       = angle;
                return(shape);
            }
            else if (shapeType == FogOfWarShapeType.Box)
            {
                FogOfWarShapeBox shape = new FogOfWarShapeBox();
                FillShape(fow, shape);
                return(shape);
            }
            else if (shapeType == FogOfWarShapeType.Texture)
            {
                if (texture == null)
                {
                    return(null);
                }

                FogOfWarShapeTexture shape = new FogOfWarShapeTexture();
                FillShape(fow, shape);
                shape.texture         = texture;
                shape.rotateToForward = rotateToForward;
                return(shape);
            }
            return(null);
        }
예제 #2
0
        protected override void DrawBox(FogOfWarShapeBox shape)
        {
            // convert size to fog space
            float    fogradius = shape.radius * _map.pixelSize;
            DrawInfo info      = new DrawInfo(_map, shape, shape.radius * _map.pixelSize, shape.radius * _map.pixelSize);

            for (int y = info.yMin; y <= info.yMax; ++y)
            {
                for (int x = info.xMin; x <= info.xMax; ++x)
                {
                    // can see pixel
                    Vector2i offset = new Vector2i(x, y) - info.fogEyePos;
                    if (!LineOfSightCanSee(shape, offset.vector2, fogradius))
                    {
                        continue;
                    }

                    if (!LineOfSightCanSeeCell(shape, offset))
                    {
                        continue;
                    }

                    _values[y * _map.resolution.x + x] = 0;
                }
            }
        }
예제 #3
0
 protected abstract void DrawBox(FogOfWarShapeBox shape);