Ejemplo n.º 1
0
    public void SetAnimation(ref Animated animated, ref Sprite2DSequencePlayer sequencePlayer)
    {
        var animAction = animated.Action;

        // Bump has no animation, so map to idle
        if (animAction == Action.Bump)
        {
            animAction = Action.None;
        }

        var direction = (int)animated.Direction;
        var action    = (int)animAction;
        var id        = animated.Id;

        Entity animation = Entity.Null;

        Entities.WithAll <AnimationSequence>().ForEach((Entity entity, ref AnimationSequence animationSequence) =>
        {
            if (animationSequence.MoveId == action && animationSequence.DirectionId == direction && animationSequence.PlayerId == id)
            {
                animation = entity;
            }
        });
        sequencePlayer.time     = 0f;
        sequencePlayer.sequence = animation;
    }
Ejemplo n.º 2
0
Archivo: Fade.cs Proyecto: stratts/Wisp
        public override void Load()
        {
            rect = new Node();
            rect.AddChild(new Rect(new Point(viewport.X, viewport.Y), Color.Black));
            rect.GetFirstChildByType <Rect>().Opacity = 0;
            rect.GetFirstChildByType <Rect>().Name    = "fadeRect";
            var anim    = new AnimationGroup();
            var fadeIn  = anim.AddAnimation("fadeIn");
            var opacity = fadeIn.AddTrack(AnimationProperty.Opacity);

            opacity.Loop   = false;
            opacity.Length = 0.4f;
            opacity.Ease   = EaseType.Linear;
            opacity.AddFrame(0, 1);
            opacity.AddFrame(0.4f, 0);

            var fadeOut = anim.AddAnimation("fadeOut");

            opacity        = fadeOut.AddTrack(AnimationProperty.Opacity);
            opacity.Loop   = false;
            opacity.Length = 0.4f;
            opacity.Ease   = EaseType.Linear;
            opacity.AddFrame(0, 0);
            opacity.AddFrame(0.4f, 1);

            this.anim = (Animated)rect.AddComponent(new Animated(anim));
            this.anim.CurrentAnimation = "fadeOut";

            AddNode(rect);
            base.Load();
        }
Ejemplo n.º 3
0
        public void SetFrame(IEntity entity, int frame)
        {
            Animated component = entity.Get <Animated>();

            component.CurrentAnimation.CurrentFrame = frame;
            component.CurrentAnimation.CurrentTick  = 0;
        }
Ejemplo n.º 4
0
        public override void Load()
        {
            rect     = new Node();
            rect.Pos = new Vector2(0, 0);
            rect.AddChild(new Rect(new Point(viewport.X, viewport.Y), Color.Black));
            var anim   = new AnimationGroup();
            var fadeIn = anim.AddAnimation("slideIn");
            var posY   = fadeIn.AddTrack(AnimationProperty.PosY);

            posY.Loop   = false;
            posY.Length = 0.5f;
            posY.Ease   = EaseType.CubicEaseIn;
            posY.AddFrame(0, 0);
            posY.AddFrame(0.5f, -viewport.Y);

            var fadeOut = anim.AddAnimation("slideOut");

            posY        = fadeOut.AddTrack(AnimationProperty.PosY);
            posY.Loop   = false;
            posY.Length = 0.5f;
            posY.Ease   = EaseType.CubicEaseOut;
            posY.AddFrame(0, viewport.Y);
            posY.AddFrame(0.5f, 0);

            this.anim = (Animated)rect.AddComponent(new Animated(anim));
            this.anim.CurrentAnimation = "slideOut";

            AddNode(rect);
            base.Load();
        }
Ejemplo n.º 5
0
        private IEntity CreateTestObject()
        {
            var animated  = new Animated();
            var animation = new Animation
            {
                AnimationType = AnimationType.Idle,
                CurrentFrame  = 0,
                CurrentTick   = 0,
                Frames        = new FrameList {
                    AnimationFrame.Idle0, AnimationFrame.Idle1
                },
                FrameTicks = 30,
                Repeat     = true
            };

            var animation2 = new Animation
            {
                AnimationType = AnimationType.Attack,
                CurrentFrame  = 0,
                CurrentTick   = 0,
                Frames        = new FrameList {
                    AnimationFrame.Attack0
                },
                FrameTicks = 30,
                Repeat     = false
            };

            animated.CurrentAnimation = animation;

            var animatedEntity = new Entity(1, "animated entity",
                                            new IEntityComponent[] { animated, animation, animation2 });

            return(animatedEntity);
        }
Ejemplo n.º 6
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.º 7
0
        static void Main(string[] args)
        {
            // New instance of MovieList
            var movieList = new MovieListFunctions();
            ////////////////////////////////////////////////
            ///////////  TEST MOVIES ///////////////////////
            var starWars    = new SciFi("Star Wars");
            var pokemon     = new Animated("Pokemon");
            var it          = new Horror("IT");
            var scream      = new Horror("Scream");
            var incredibles = new Animated("Incredibles");
            var zootopia    = new Animated("Zootopia");
            var serenity    = new SciFi("Serenity");
            var theMatrix   = new SciFi("The Matrix");
            var fightClub   = new Drama("Fight Club");
            var seven       = new Drama("Seven");

            ////////////////////////////////////////////////
            ///////// TEST LIST OF MOVIES /////////////////
            movieList.Add(starWars);
            movieList.Add(pokemon);
            movieList.Add(it);
            movieList.Add(scream);
            movieList.Add(incredibles);
            movieList.Add(zootopia);
            movieList.Add(serenity);
            movieList.Add(theMatrix);
            movieList.Add(fightClub);
            movieList.Add(seven);
            //////////////////////////////////////////////////
            // Sort the movie list alphabetically
            movieList.Sort((a, b) => a.GetTitle().CompareTo(b.GetTitle()));
            bool isRunning = true;

            while (isRunning)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Welcome to the Movie List Application!");
                Console.WriteLine("There are 10 movies in this list.");
                movieList.ListMovieCategories();
                Console.Write("What category are you interested in?");
                var category = Console.ReadLine();
                if (int.TryParse(category, out int validOption) && validOption > 0 && validOption < 5)
                {
                    movieList.MovieCategoryDisplayList(movieList, validOption);
                }
                else
                {
                    Console.WriteLine("Please enter and option from the menu.");
                }
                if (!PlayAgain())
                {
                    Console.WriteLine("Have a nice day!");
                    isRunning = false;
                }
            }
        }
Ejemplo n.º 8
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.º 9
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.º 10
0
 private void StopAnimate()
 {
     proc = false;
     sw.Stop();
     sw.Reset();
     framecounter = -1;
     CompositionTarget.Rendering -= CompositionTarget_Rendering;
     UpdateContent(Score);
     Animated?.Invoke(this, new EventArgs());
 }
Ejemplo n.º 11
0
        public void Default()
        {
            // Arrange
            var enchantment = new Animated();

            // Assert
            Assert.AreEqual("Animated", enchantment.Name.Text);
            Assert.AreEqual(2, enchantment.SpecialAbilityBonus);
            Assert.AreEqual(12, enchantment.CasterLevel);
            Assert.That(enchantment.GetSchools(),
                        Has.Exactly(1).Matches <School>(s => School.Transmutation == s));
        }
        private void ConfigureAnimation()
        {
            if (Animated != Animation.None)
            {
                if (Animated != Animation.Horizontal)
                {
                    ElementClass = $"{ElementClass} {Animated.ToString().ToLowerInvariant()}";
                }

                ElementClass = $"{ElementClass} animated";
            }
        }
Ejemplo n.º 13
0
        //public MogwaiEntity(int glyph, Color color, Font font) : base(1,1)
        public MogwaiEntity(Animated animated) : base(animated)
        {
            _defAnimated = animated;

            // animation entity
            _animEntity = new Entity(new Animated("default", 1, 1, font));

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

            //_animEntity.AnimationStateChanged += AnimationChanged;
        }
Ejemplo n.º 14
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.º 15
0
        public void AddAnimation(string name, int glyph, Color color)
        {
            var newAnim = new Animated(name, 1, 1, font)
            {
                AnimationDuration = 1
            };
            var frame = newAnim.CreateFrame();

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

            Animations.Add(name, newAnim);
        }
Ejemplo n.º 16
0
        public void SetAnimation(IEntity entity, AnimationType animationType)
        {
            Animated  component = entity.Get <Animated>();
            Animation animation = GetComponentAnimation(entity, animationType);

            if (animation != null)
            {
                animation.CurrentFrame = 0;
                animation.CurrentTick  = 0;

                component.CurrentAnimation = animation;
            }
        }
Ejemplo n.º 17
0
 private void SetLaserDirection()
 {
     if (target == null)
     {
         Animated animated = GetComponent <Animated>();
         laserDirection.x = animated.CachedX;
         laserDirection.z = animated.CachedZ;
     }
     else
     {
         laserDirection = (target.transform.position - transform.position).normalized;
     }
 }
Ejemplo n.º 18
0
        public void SetUp()
        {
            _stopwatch = Substitute.For <IStopwatch>();
            _stopwatch.ElapsedMilliseconds.ReturnsForAnyArgs(0);
            _random = Substitute.For <IRandom>();

            _animationSystem = new AnimationSystem(_stopwatch, _random);
            _animationSystem.Initialise();

            _testObject        = CreateTestObject();
            _animatedComponent = _testObject.Get <Animated>();

            _animationSystem.AddEntity(_testObject);
        }
Ejemplo n.º 19
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(this);
     }
     movableComponent  = GetComponent <Movable>();
     animatedComponent = GetComponent <Animated>();
     attackerComponent = GetComponent <Attacker>();
     GetComponent <Attackable>().MaxHP     = 10000.0f;
     GetComponent <Attackable>().currentHp = 10000.0f;
 }
Ejemplo n.º 20
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.º 21
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);
        }
Ejemplo n.º 22
0
 public override void WriteJson(JsonWriter writer, Animated value, JsonSerializer serializer)
 {
     serializer.Serialize(writer, (AnimatedSurfaceSerialized)value);
 }
Ejemplo n.º 23
0
 public override Animated ReadJson(JsonReader reader, Type objectType, Animated existingValue, bool hasExistingValue,
                                   JsonSerializer serializer)
 {
     return(serializer.Deserialize <AnimatedSurfaceSerialized>(reader));
 }
Ejemplo n.º 24
0
 OglAnimator AnimatedWalkForward(double SpeedInUnitsPerMilliSec)
 {
     return(Animated.WalkForward(SpeedInUnitsPerMilliSec));
 }
Ejemplo n.º 25
0
 public Snake(Animated anim) : base(anim)
 {
     Tail = new List <Entity>();
     SnakeBoard.EntityManager.Entities.Add(this);
 }
Ejemplo n.º 26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            hash ^= unlockConditions_.GetHashCode();
            if (AssetScriptName.Length != 0)
            {
                hash ^= AssetScriptName.GetHashCode();
            }
            if (Icon.Length != 0)
            {
                hash ^= Icon.GetHashCode();
            }
            if (AssetType != 0)
            {
                hash ^= AssetType.GetHashCode();
            }
            if (LensType != 0)
            {
                hash ^= LensType.GetHashCode();
            }
            if (Visible != false)
            {
                hash ^= Visible.GetHashCode();
            }
            if (MediaSupportedType != 0)
            {
                hash ^= MediaSupportedType.GetHashCode();
            }
            if (Animated != false)
            {
                hash ^= Animated.GetHashCode();
            }
            if (StorePackId.Length != 0)
            {
                hash ^= StorePackId.GetHashCode();
            }
            if (OrderId != 0)
            {
                hash ^= OrderId.GetHashCode();
            }
            if (IsFullBodyLens != false)
            {
                hash ^= IsFullBodyLens.GetHashCode();
            }
            if (IsEmptyAsset != false)
            {
                hash ^= IsEmptyAsset.GetHashCode();
            }
            if (ShowBadge != false)
            {
                hash ^= ShowBadge.GetHashCode();
            }
            if (visibilityConditions_ != null)
            {
                hash ^= VisibilityConditions.GetHashCode();
            }
            if (StockAssetName.Length != 0)
            {
                hash ^= StockAssetName.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 27
0
 public Unit(Animated anim, bool isPlayer) : base(anim)
 {
     PlayerControlled = isPlayer;
 }