Ejemplo n.º 1
0
        public void AddLayeredAnimation(string name, int glyph, Color color)
        {
            var newAnim = new Animated(name, 1, 1, font)
            {
                AnimationDuration = 1
            };
            var frame = newAnim.CreateFrame();

            newAnim.CreateFrame();
            frame[0].Glyph      = glyph;
            frame[0].Foreground = color;

            _animEntity.Animations.Add(name, newAnim);
        }
Ejemplo n.º 2
0
        private void DiedEntity(ConsoleEntity entity)
        {
            var         animated = new Animated("default", 1, 1, _adventureFont);
            BasicNoDraw frame    = animated.CreateFrame();

            frame[0].Glyph      = 143;
            frame[0].Foreground = Color.Gainsboro;
            entity.Animation    = animated;
        }
Ejemplo n.º 3
0
        internal void Looted()
        {
            var animated = new Animated("default", 1, 1, font);
            var frame    = animated.CreateFrame();

            frame[0].Glyph      = 143;
            frame[0].Foreground = Color.DarkGray;
            Animation           = animated;
        }
Ejemplo n.º 4
0
        public void Show(Point lineStart, Point lineEnd)
        {
            System.Console.WriteLine($"Line Show[{lineStart},{lineEnd}]");
            if (isHidden)
            {
                isHidden = false;
            }

            Clear();

            Direction dir = Direction.GetCardinalDirection(lineStart.ToCoord(), lineEnd.ToCoord());

            if (dir == Direction.UP)
            {
                System.Console.WriteLine("UP");
                lineStart.X += 1;
            }
            else if (dir == Direction.RIGHT)
            {
                System.Console.WriteLine("RIGHT");
                lineStart.X += 1;
                lineStart.Y += 1;
            }
            else if (dir == Direction.DOWN)
            {
                System.Console.WriteLine("DOWN");
                lineStart.Y += 1;
            }
            else if (dir == Direction.LEFT)
            {
                System.Console.WriteLine("LEFT");
            }

            IEnumerable <Coord> line = Lines.Get(lineStart.ToCoord(), lineEnd.ToCoord(), Lines.Algorithm.DDA);


            int count = 0;

            foreach (Coord p in line)
            {
                Animated anim  = new Animated("default", 1, 1, _map.Font);
                var      frame = anim.CreateFrame();
                frame[0].CopyAppearanceFrom(AppearanceLine);
                frame[0].Glyph = '0' + count;
                Entity e = new Entity(anim);
                _entitities.Add(e);
                e.Position = p.ToPoint();
                _map.EntityManager.Entities.Add(e);
                count++;
            }

            //System.Console.WriteLine( "length: " + line.Count<Coord>() );
            //frame.SetCellAppearance( 0, 0, new Cell( Color.White, Color.Blue ));

            //Animation = anim;
        }
Ejemplo n.º 5
0
        public void Dead()
        {
            //Animation = Animations["dead"];
            //Animation.Restart();

            var animated = new Animated("default", 1, 1, font);
            var frame    = animated.CreateFrame();

            frame[0].Glyph      = 143;
            frame[0].Foreground = Color.Red;
            Animation           = animated;
        }
Ejemplo n.º 6
0
        public EntityConsole()
            : base(80, 23)
        {
            var animation = new Animated("default", 1, 1);
            var frame     = animation.CreateFrame();

            frame.Cells[0].Glyph = 1;

            player                 = new Entity(animation);
            player.Position        = new Point(Width / 2, Height / 2);
            playerPreviousPosition = player.Position;

            // Setup this console to accept keyboard input.
            UseKeyboard = true;
            IsVisible   = false;

            EntityManager manager = new EntityManager();

            manager.Entities.Add(player);

            Children.Add(manager);
        }
Ejemplo n.º 7
0
        public void DrawEntity(AdventureEntity adventureEntity)
        {
            int   glyph;
            Color color;

            switch (adventureEntity)
            {
            case Mogwai _:
                glyph = 1;
                color = Color.DarkOrange;
                break;

            case Monster _:
                glyph = 135;     //64;
                color = Color.SandyBrown;
                break;

            case Chest _:
                glyph = 146;     //64;
                color = Color.Pink;
                break;

            default:
                throw new NotImplementedException();
            }

            // TODO: rotating symbols for multiple mogwais
            var         defaultAnim = new Animated("default", 1, 1, _adventureFont);
            BasicNoDraw frame       = defaultAnim.CreateFrame();

            frame[0].Glyph      = glyph;
            frame[0].Foreground = color;

            Coord pos    = adventureEntity.Coordinate;
            var   entity = new ConsoleEntity(defaultAnim)
            {
                Position = new Point(pos.X, pos.Y),
            };

            // damage animation
            var defAnimated = new Animated("default", 1, 1, _adventureFont);
            var animEntity  = new ConsoleEntity(defAnimated);
            var damageAnim  = new Animated("damage", 1, 1, _adventureFont)
            {
                AnimationDuration = 1
            };
            BasicNoDraw damageFrame = damageAnim.CreateFrame();

            damageAnim.CreateFrame();
            damageFrame[0].Glyph      = 15;
            damageFrame[0].Foreground = Color.Red;
            animEntity.Animations.Add("damage", damageAnim);

            // add animation entity
            entity.Children.Add(animEntity);

            // TODO change this ... to a more appropriate handling
            // do not revive ... dead shapes
            if (adventureEntity is Combatant combatant && combatant.IsDead)
            {
                DiedEntity(entity);
            }

            entity.IsVisible = false;

            _entities.Add(adventureEntity.AdventureEntityId, entity);
            _entityManager.Entities.Add(entity);
        }