Beispiel #1
0
        /// <summary>
        /// Wrapper around TCODColor.Interpolate
        /// </summary>
        /// <param name="sourceColor"></param>
        /// <param name="destinationColor"></param>
        /// <param name="coefficient"></param>
        /// <returns></returns>
        public static Color Lerp(Color sourceColor, Color destinationColor, float coefficient)
        {
            TCODColor color = TCODColor.Interpolate(sourceColor.TCODColor,
                                                    destinationColor.TCODColor, coefficient);

            return(new Color(color));
        }
Beispiel #2
0
        public void Render(TCODColor backgroundColor)
        {
            var color = TCODColor.Interpolate(TCODColor.white, backgroundColor, Brightness);

            TCODConsole.root.setForegroundColor(color);
            TCODConsole.root.putChar(X, Y, '*');
        }
Beispiel #3
0
        // Display a line of text
        public void DisplayText(string textToDisplay, int x, int y, TCODColor foregroundColor, TCODColor backgroundColor, int Index)
        {
            // Handle mainmenu colour-swapping
            if (Index == (int)currentMenuOption)
            {
                foregroundColor   = TCODColor.black;
                colourInterpolate = colourInterpolate + colourInterpolateStep;
                if (colourInterpolate >= 0.91)
                {
                    colourInterpolateStep = -0.01;
                }
                else if (colourInterpolate <= 0.11)
                {
                    colourInterpolateStep = 0.01;
                }
                backgroundColor = TCODColor.Interpolate(TCODColor.yellow, TCODColor.red, (float)colourInterpolate);
            }

            rootConsole.setBackgroundColor(backgroundColor);
            rootConsole.setForegroundColor(foregroundColor);

            if (Index != -1)
            {
                System.Text.StringBuilder OffSetString = new System.Text.StringBuilder();
                OffSetString.Append(' ', (36 - textToDisplay.Length) / 2);
                textToDisplay = OffSetString + textToDisplay + OffSetString;
            }
            else
            {
                if (x == -1)
                {
                    x = (consoleWidth - textToDisplay.Length) / 2;
                }
            }

            int offset = 0;

            foreach (char value in textToDisplay)
            {
                if (value == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (value == ']')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (offset == 1 && textToDisplay[0] == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                offset++;
                rootConsole.setCharBackground(x + offset, y, backgroundColor, TCODBackgroundFlag.Set);
                rootConsole.print(x + offset, y, value.ToString());
            }
        }
Beispiel #4
0
        public LightSource(Point Position, int Radius, TCODColor Colour, float Intensity, Map mapData)
        {
            float Distance;
            Point currentLoc       = new Point(0, 0);
            float workingIntensity = 0.0f;

            position  = new Point(Position);
            radius    = Radius;
            colour    = new TCODColor();
            colour    = Colour;
            intensity = Intensity;
            int mapSize = 1 + (Radius * 2);

            lightMap = new TCODMap(300, 200);
            lightMap.clear(false, false);

            //for (int dx = Position.X - Radius; dx <= Position.X + Radius; dx++)
            for (int dx = 0; dx < 300; dx++)
            {
                //for (int dy = Position.Y - Radius; dy <= Position.Y + Radius; dy++)
                for (int dy = 0; dy < 200; dy++)
                {
                    lightMap.setProperties(dx, dy, mapData.Cells[dx, dy].Walkable, mapData.Cells[dx, dy].Walkable);
                }
            }
            lightMap.computeFov(Position.X, Position.Y, Radius, true, TCODFOVTypes.ShadowFov);

            //for (int dx = Position.X - Radius; dx < Position.X + Radius; dx++)
            for (int dx = 0; dx < 300; dx++)
            {
                //for (int dy = Position.Y - Radius; dy <= Position.Y + Radius; dy++)
                for (int dy = 0; dy < 200; dy++)
                {
                    if (lightMap.isInFov(dx, dy))
                    {
                        currentLoc.Set(dx, dy);
                        Distance         = (float)currentLoc.Dist(Position);
                        workingIntensity = Intensity - Distance / 12;
                        if (workingIntensity < 0.0f)
                        {
                            workingIntensity = 0.0f;
                        }
                        mapData.Cells[dx, dy].AmbientLight       = workingIntensity;
                        mapData.Cells[dx, dy].AmbientLightColour = TCODColor.Interpolate(TCODColor.black, Colour, workingIntensity);
                    }
                }
            }
        }
Beispiel #5
0
        public new void Update()
        {
            if (Life < 500)
            {
                Life++;
            }
            switch (Type)
            {
            case Types.BloodDrops:
            case Types.BloodSplatter:
                ForegroundColor = TCODColor.Interpolate(TCODColor.red, new TCODColor(58, 5, 14), Math.Min(1f, (float)Life / 500f));
                break;

            case Types.BloodPool:
                BackgroundColor = TCODColor.Interpolate(TCODColor.red, new TCODColor(58, 5, 14), Math.Min(1f, (float)Life / 500f));
                break;
            }
        }
Beispiel #6
0
        private void GenerateClouds()
        {
            clouds = new List <Cloud>();
            var random = new Random();

            int numberOfClouds = 10 + random.Next(5);

            for (int i = 0; i < numberOfClouds; ++i)
            {
                clouds.Add(new Cloud()
                {
                    X     = random.Next(TCODConsole.root.getWidth()),
                    Y     = 1 + random.Next(TCODConsole.root.getHeight() - 25),                 // -25 to account for buildings
                    Color = TCODColor.Interpolate(
                        TCODColor.white, backgroundColor,
                        0.35f + (float)random.NextDouble() * 0.30f),
                    Speed = (float)random.NextDouble() + 0.5f
                });
            }
        }
Beispiel #7
0
        public static Decal Generate(Prefabs prefab, Point position)
        {
            IEnumerable <Decal> q;

            q = from decal in Area.Current.Decals
                where decal.Position == position
                select decal;
            List <Decal> matches = q.ToList <Decal>();

            if (matches.Count == 1)
            {
                if (prefab == Prefabs.BloodDrops || prefab == Prefabs.BloodSplatter || prefab == Prefabs.BloodPool)
                {
                    matches[0].Density++;
                    matches[0].Life = 0;
                    switch (matches[0].Type)
                    {
                    case Types.BloodDrops:
                        if (matches[0].Density < 3)
                        {
                            return(null);
                        }
                        Area.Current.Decals.Remove(matches[0]);
                        return(Generate(Prefabs.BloodSplatter, position));

                    case Types.BloodSplatter:
                        if (matches[0].Density < 8)
                        {
                            return(null);
                        }
                        Area.Current.Decals.Remove(matches[0]);
                        return(Generate(Prefabs.BloodPool, position));

                    case Types.BloodPool:
                        return(null);
                    }
                }
            }
            if (matches.Count > 1)
            {
                throw new Exception("OMG!");
            }
            Decal d = new Decal();

            switch (prefab)
            {
            case Prefabs.BloodDrops:
                d.Type            = Types.BloodDrops;
                d.DrawMode        = DrawModes.OnlyForegroundColor;
                d.ForegroundColor = TCODColor.Interpolate(TCODColor.red, new TCODColor(58, 5, 14), 0f);
                d.Description     = "There is some blood on the ground here.";
                break;

            case Prefabs.BloodSplatter:
                d.Type            = Types.BloodSplatter;
                d.DrawMode        = DrawModes.Normal;
                d.Symbol          = (char)7;
                d.ForegroundColor = TCODColor.desaturatedCrimson;
                d.Description     = "There is a splatter of blood here.";
                break;

            case Prefabs.BloodPool:
                d.Type            = Types.BloodPool;
                d.DrawMode        = DrawModes.OnlyBackgroundColor;
                d.BackgroundColor = TCODColor.desaturatedCrimson;
                d.Description     = "A pool of blood covers the ground here.";
                break;
            }
            d.Area     = Area.Current;
            d.Position = position;
            Area.Current.Decals.Add(d);
            return(d);
        }
Beispiel #8
0
 public TCODColor GetTCODColor(TCODColor blend)
 {
     return(TCODColor.Interpolate(blend, new TCODColor(red, green, blue), alpha / 255.0f));
 }