상속: AnimationBase
예제 #1
0
 public TimBehavior()
     : base("TimBehavior")
 {
     this.direction = NONE;
     this.anim2D = null;
     this.trans2D = null;
     this.currentState = AnimState.Idle;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnimatedSpriteRenderer" /> class.
 /// </summary>
 /// <param name="layer">Layer type.</param>
 /// <param name="samplerMode">The sampler mode.</param>
 public AnimatedSpriteRenderer(Type layer, AddressMode samplerMode = AddressMode.LinearClamp)
     : base("AnimatedSpriteRenderer" + instances++, layer)
 {
     this.Transform2D = null;
     this.Sprite = null;            
     this.Animation2D = null;
     this.samplerMode = samplerMode;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnimatedSpriteRenderer" /> class.
 /// </summary>
 /// <param name="layer">Layer type.</param>
 public AnimatedSpriteRenderer(Type layer)
     : base("AnimatedSpriteRenderer" + instances++, layer)
 {
     this.Transform2D = null;
     this.Sprite = null;
     this.scale = Vector2.Zero;
     this.position = Vector2.Zero;
     this.origin = Vector2.Zero;
     this.Animation2D = null;
 }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Squid" /> class.
        /// </summary>
        /// <param name="positionY">The position Y.</param>
        public Squid(float positionY)
        {
            this.initialPosY = positionY;
            this.gamePlayPosY = WaveServices.ViewportManager.BottomEdge + 50;

            this.entity = new Entity("SquidEntity")
                            .AddComponent(new Transform2D()
                            {
                                Origin = new Vector2(0.5f, 0f),
                                X = WaveServices.ViewportManager.VirtualWidth / 2,
                                Y = this.gamePlayPosY,
                                DrawOrder = 0.3f,
                            })
                            .AddComponent(new AnimationUI())
                            .AddComponent(new SquidBehavior())
                            .AddComponent(new Sprite(Directories.TexturePath + "squidSpriteSheet.wpk"))
                            .AddComponent(Animation2D.Create<TexturePackerGenericXml>(Directories.TexturePath + "squidSpriteSheet.xml")
                                                .Add("swim", new SpriteSheetAnimationSequence() { First = 1, Length = 30, FramesPerSecond = 30 }))
                            .AddComponent(new PerPixelCollider(Directories.TexturePath + "squidCollider.wpk", 0.5f))
                            .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha));

            // Cached
            this.transform = this.entity.FindComponent<Transform2D>();
            this.animation2D = this.entity.FindComponent<Animation2D>();
            this.direction = -Vector2.UnitY;
            this.animation = this.entity.FindComponent<AnimationUI>();

            // Bubble
            this.entity.AddChild(new Entity("bubblesParticle")
                .AddComponent(new Transform2D()
                {
                    LocalY = 210,
                })
                .AddComponent(ParticleFactory.CreateBubbleParticles())
                .AddComponent(
                    new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk",
                        DefaultLayers.Additive)))
                .AddComponent(new ParticleSystemRenderer2D("bubblesParticle")));

            // Cached
            this.particleSystem = this.entity.FindChild("bubblesParticle").FindComponent<ParticleSystem2D>();

            // Animations
            this.appearAnim = new SingleAnimation(gamePlayPosY, this.initialPosY, TimeSpan.FromSeconds(1.5f), EasingFunctions.Cubic);            
        }
예제 #5
0
        public Mob_Base(int start_grid_x, int start_grid_y, int [,] map, int i)
        {
            HP = 100;
            Alive = true;
            Lives_value = 1;
            Monster_gold = 20;
            Alive = true;

            Last_Grid_X = Last_Grid_Y = -1;

            this.anim2D = null;//new Animation2D();
            this.trans2D = null;

            this.Grid_x = start_grid_x;
            this.Grid_y = start_grid_y;

            var Ast = Static.Functions.Astar(Grid_x, Grid_y,Last_Grid_X ,Last_Grid_Y,map);
            this.F_Grid_x = Ast.Item2;
            this.F_Grid_y = Ast.Item1;
            get_direction();

            Mob = new Entity("Enemy " + i)
                .AddComponent(trans2D = new Transform2D()
                {
                    X = (start_grid_x * Const.BITMAP_SIZE) + Const.OFFSET,
                    Y = (start_grid_y * Const.BITMAP_SIZE) + Const.OFFSET,

                    Origin = new Vector2(0.5f, 0.5f)
                })
                .AddComponent(new Sprite("Content/Monsters/Monster_Beta/Mob.wpk"))
                .AddComponent(Animation2D.Create<TexturePackerGenericXml>("Content/Monsters/Monster_Beta/Mob.xml")
                .Add("Idle", new SpriteSheetAnimationSequence() { First = 1, Length = 1, FramesPerSecond = 30 })
                    .Add("Running", new SpriteSheetAnimationSequence() { First = 1, Length = 4, FramesPerSecond = 5 }))
                .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha));

            anim2D = Mob.FindComponent<Animation2D>();
            anim2D.CurrentAnimation = "Running";
            anim2D.Play(true);
        }
예제 #6
0
        protected override void Initialize()
        {
            base.Initialize();
            
            this.input = WaveServices.Input;

            this.dustAnimation = this.dustEntity.FindComponent<Animation2D>();
            this.dustTransform = this.dustEntity.FindComponent<Transform2D>();
            this.dustEntity.Enabled = false;

            // Set animation mix
            this.skeletalAnimation.SetAnimationMixDuration(IdleAnimation, MoveAnimation, MixDuration);
            this.skeletalAnimation.SetAnimationMixDuration(MoveAnimation, IdleAnimation, MixDuration);

            this.ChangeState();
        }
예제 #7
0
        private void CreateBackground()
        {
            var background = new Entity("Background")
                .AddComponent(new Sprite("Content/BG.wpk"))
                .AddComponent(new SpriteRenderer(DefaultLayers.Opaque))
                .AddComponent(new Transform2D { DrawOrder = 1 });
            this.EntityManager.Add(background);

            var countdownAnimation = new Entity("Countdown")
                .AddComponent(new Transform2D()
                {
                    X = WaveServices.ViewportManager.VirtualWidth - 20,
                    Y = 20,
                    Origin = Vector2.UnitX
                })
                .AddComponent(new Sprite("Content/Countdown.wpk"))
                .AddComponent(Animation2D.Create<TexturePackerGenericXml>("Content/Countdown.xml")
                    .Add("Default", new SpriteSheetAnimationSequence() { First = 1, Length = 5, FramesPerSecond = 1 }))
                .AddComponent(new AnimatedSpriteRenderer());
            this.EntityManager.Add(countdownAnimation);

            this.countdownAnimationComponent = countdownAnimation.FindComponent<Animation2D>();
        }
예제 #8
0
        private void CreateExplosion()
        {
            this.explosion = EntityManager.Find("boom");
            this.explosion.Enabled = false;
            this.explodeAnimation = this.explosion.FindComponent<Animation2D>();

            this.explodeAnimation.AddKeyFrameEvent("boom", 14);

            this.explodeAnimation.OnKeyFrameEvent += this.explodeAnimation_OnKeyFrameEvent;
        }