Exemple #1
0
        /// <summary>
        ///     Render a lifepack.
        /// </summary>
        /// <param name="lifepack">Lifepack model</param>
        /// <param name="squareSize">Maximum size of the containing square</param>
        /// <returns></returns>
        private static Rectangle RenderLifepack(Lifepack lifepack, int squareSize)
        {
            var rectangle = new Rectangle
            {
                Height = squareSize,
                Width  = squareSize,
                Fill   = new VisualBrush(
                    new PackIconFontAwesome
                {
                    Kind       = PackIconFontAwesomeKind.Medkit,
                    Foreground = new SolidColorBrush(Colors.Red),
                    Effect     = new DropShadowEffect
                    {
                        Color       = Colors.Red,
                        Direction   = 0,
                        Opacity     = 1,
                        ShadowDepth = 0
                    }
                }
                    ),
                Stroke = new SolidColorBrush(Colors.DimGray)
            };

            return(rectangle);
        }
Exemple #2
0
        /// <summary>
        ///     Adds a new lifepack to the world.
        /// </summary>
        /// <param name="oldWorld">Current state of the world. </param>
        /// <param name="message">The LifepackMessage received. </param>
        /// <returns>New world based on both the old world and the LifepackMessage. </returns>
        private static World FromLifepackMessage(World oldWorld, LifepackMessage message)
        {
            var lifepack = new Lifepack(message.Location, message.RemainingTime);

            return(new World(oldWorld.PlayerNumber)
            {
                BrickWalls = oldWorld.BrickWalls,
                StoneWalls = oldWorld.StoneWalls,
                Waters = oldWorld.Waters,
                Tanks = oldWorld.Tanks,
                Coinpacks = oldWorld.Coinpacks,
                Lifepacks = new HashSet <Lifepack>(oldWorld.Lifepacks.Concat(new[] { lifepack }))
            });
        }