예제 #1
0
		public PortalInfo()
		{
			this.View = new ViewEngineBase(Texture64.SizeConstant, Texture64.SizeConstant);

			this.Frame = new Bitmap(new BitmapData(Texture64.SizeConstant, Texture64.SizeConstant, true, 0x0));

			this.Sprite = new SpriteInfo
			{
				Frames = new[] { this.Frame },
				Range = 0.3
			};

			Color = 0xff;
		}
		public SpriteInfoExtended CreateWalkingDummy(Texture64[] Stand, Texture64[][] Walk, Texture64[] Hit, Texture64[] Death)
		{
			var tt = default(Timer);
			var s = new SpriteInfoExtended();

			Action start =
				delegate
				{
					s.WalkingAnimationRunning = true;

					if (Walk.Length > 0)
						tt = (200).AtInterval(
							t =>
							{
								#region dead people do not walk
								if (s.Health <= 0)
								{
									t.stop();
									return;
								}
								#endregion


								if (!s.AIEnabled)
									return;

								s.Frames = Walk[t.currentCount % Walk.Length];
							}
						);
				};

			Action stop =
				delegate
				{
					s.WalkingAnimationRunning = false;

					if (tt != null)
						tt.stop();

					s.Frames = Stand;
				};


			s.Position = new Point { x = EgoView.ViewPositionX, y = EgoView.ViewPositionY };
			s.Frames = Stand;
			s.Direction = EgoView.ViewDirection;
			s.StartWalkingAnimation = start;
			s.StopWalkingAnimation = stop;
			s.Range = PlayerRadiusMargin;

			s.AddTo(EgoView.Sprites);

			if (Hit != null)
				s.TakeDamage =
					DamageToBeTaken =>
					{
						s.Health -= DamageToBeTaken;

						if (s.Health > 0)
						{
							Assets.Default.Sounds.hit.play();
							 
							#region just show being hurt for a short moment
							s.AIEnabled = false;

							var q = s.Frames;
							s.Frames = Hit;

							300.AtDelayDo(
								delegate
								{
									s.Frames = q;
									s.AIEnabled = true;
								}
							);
							#endregion

						}
						else
						{
							Assets.Default.Sounds.death.play();

							// player wont be blocked by a corpse
							s.Range = 0;

							// animate death
							(1000 / 10).AtInterval(
								ttt =>
								{
									if (Death.Length == ttt.currentCount)
									{
										ttt.stop();
										return;
									}

									s.Frames = new[] { Death[ttt.currentCount] };
								}
							);
						}
							
					};


			return s;
		}
		public SpriteInfoExtended CreateDummy(Texture64 Stand)
		{
			return CreateWalkingDummy(new[] { Stand }, null, null, null);

		}
		public SpriteInfoExtended CreateWalkingDummy(Texture64[] _Stand, Texture64[][] _Walk, Texture64[] Hit, Texture64[] Death, Texture64[] Shooting)
		{
			var Walk = _Walk;
			var Stand = _Stand;

			var tt = default(Timer);
			var s = new SpriteInfoExtended();

			s.Health = GuardMaxHealth;

			int WalkingAnimationFrame = 0;

			Action start =
				delegate
				{
					s.WalkingAnimationRunning = true;

					if (Walk.Length > 0)
						tt = (200).AtInterval(
							t =>
							{
								#region dead people do not walk
								if (s.Health <= 0)
								{
									t.stop();
									return;
								}
								#endregion


								if (!s.AIEnabled)
									return;

								WalkingAnimationFrame = t.currentCount % Walk.Length;

								s.Frames = Walk[WalkingAnimationFrame];
							}
						);
				};

			Action stop =
				delegate
				{
					s.WalkingAnimationRunning = false;

					if (tt != null)
						tt.stop();

					s.Frames = Stand;
				};


			s.Position = new Point { x = EgoView.ViewPositionX, y = EgoView.ViewPositionY };
			s.Frames = Stand;
			s.Direction = EgoView.ViewDirection;
			s.StartWalkingAnimation = start;
			s.StopWalkingAnimation = stop;
			s.Range = PlayerRadiusMargin;

			s.AddTo(EgoView.Sprites);

			Action UpdateCurrentFrame =
				delegate
				{
					if (s.Health <= 0)
						return;
					if (!s.AIEnabled)
						return;

					if (s.WalkingAnimationRunning)
						s.Frames = Walk[WalkingAnimationFrame];
					else
						s.Frames = Stand;
				};

			if (Shooting != null)
			{
				#region prepare
				#region clone

				var WalkShooting = Enumerable.ToArray(
					_Walk.Select(r0 => Enumerable.ToArray(r0))
				);

				var StandShooting = Enumerable.ToArray(
					_Stand
				);

				#endregion

				// 0 .. 8
				Action<int> ApplyShootingFrame =
					ShootingFrameIndex =>
					{
						var k = Shooting.AtModulus(ShootingFrameIndex);

						StandShooting[1] = k;
						StandShooting[2] = k;
						StandShooting[3] = k;

						foreach (var v in WalkShooting)
						{
							v[1] = k;
							v[2] = k;
							v[3] = k;
						}

						UpdateCurrentFrame();
					};
				#endregion

				var PlayShootingAnimationTimer = default(Timer);

				s.PlayShootingAnimation +=
					delegate
					{
						// for a short period of time we need to overwrite
						// stand and walk frames

						Walk = WalkShooting;
						Stand = StandShooting;

						if (PlayShootingAnimationTimer != null)
							PlayShootingAnimationTimer.stop();

						PlayShootingAnimationTimer = FrameRate_ShootingAnimation.Chain(
							() => ApplyShootingFrame(0)
						).Chain(
							() => ApplyShootingFrame(1)
						).Chain(
							() => ApplyShootingFrame(2)
						).Chain(
							() => ApplyShootingFrame(1)
						).Chain(
							() => ApplyShootingFrame(0)
						).Chain(
							delegate
							{
								// revert soon after animation finishes
								Walk = _Walk;
								Stand = _Stand;
								UpdateCurrentFrame();

								PlayShootingAnimationTimer = null;
							}
						).Do();
					};
			}

			if (Hit != null)
				s.TakeDamage +=
					(DamageToBeTaken, DamageOwner) =>
					{
						// we have nothing to do here if we are dead 
						if (s.Health < 0)
							return;

						s.Health -= DamageToBeTaken;

						if (s.Health > 0)
						{
							Assets.Default.Sounds.hit.play();

							#region just show being hurt for a short moment
							s.AIEnabled = false;

							var q = s.Frames;
							s.Frames = Hit;

							300.AtDelayDo(
								delegate
								{
									s.Frames = q;
									s.AIEnabled = true;
								}
							);
							#endregion

							// remove old blood which is too near
							EmitBloodUnderSprite(s);
						}
						else
						{
							if (Sync_GuardKilled != null)
								Sync_GuardKilled(DamageOwner);

							RemoveBloodUnderSprite(s);

							Assets.Default.Sounds.death.play();

							// player wont be blocked by a corpse
							s.Range = 0;

							// animate death
							FrameRate_DeathAnimation.AtInterval(
								ttt =>
								{
									if (Death.Length == ttt.currentCount)
									{
										ttt.stop();
										return;
									}

									s.Frames = new[] { Death[ttt.currentCount] };
								}
							);
						}

						if (s.TakeDamageDone != null)
							s.TakeDamageDone(DamageToBeTaken, DamageOwner);

					};


			return s;
		}
		public SpriteInfoExtended CreateWalkingDummy(Texture64[] Stand, params Texture64[][] Walk)
		{
			var tt = default(Timer);
			var s = default(SpriteInfoExtended);

			Action start =
				delegate
				{
					s.WalkingAnimationRunning = true;

					if (Walk.Length > 0)
						tt = (200).AtInterval(
							t =>
							{
								s.Frames = Walk[t.currentCount % Walk.Length];
							}
						);
				};

			Action stop =
				delegate
				{
					s.WalkingAnimationRunning = false;

					if (tt != null)
						tt.stop();

					s.Frames = Stand;
				};


			s = new SpriteInfoExtended
			{
				Position = new Point { x = EgoView.ViewPositionX, y = EgoView.ViewPositionY },
				Frames = Stand,
				Direction = EgoView.ViewDirection,
				StartWalkingAnimation = start,
				StopWalkingAnimation = stop

			}.AddTo(EgoView.Sprites);



			return s;
		}
        private static int CreateWalkingDummy_Walk(Texture64[][] Walk, SpriteInfoExtended s, int WalkingAnimationFrame, Timer t)
        {
            #region dead people do not walk
            if (s.Health <= 0)
            {
                t.stop();
                return WalkingAnimationFrame;
            }
            #endregion


            if (!s.AIEnabled)
                return WalkingAnimationFrame;

            WalkingAnimationFrame = t.currentCount % Walk.Length;

            s.Frames = Walk[WalkingAnimationFrame];
            return WalkingAnimationFrame;
        }
            public static void Invoke(FlashTreasureHunt that, Texture64[] Hit, Texture64[] Death, SpriteInfoExtended s, double DamageToBeTaken, object DamageOwner)
            {
                // we have nothing to do here if we are dead 
                if (s.Health < 0)
                    return;

                s.Health -= DamageToBeTaken;

                if (s.Health > 0)
                {
                    Assets.Default.Sounds.hit.play();

                    #region just show being hurt for a short moment
                    s.AIEnabled = false;

                    var q = s.Frames;
                    s.Frames = Hit;

                    300.AtDelayDo(
                        delegate
                        {
                            s.Frames = q;
                            s.AIEnabled = true;
                        }
                    );
                    #endregion

                    // remove old blood which is too near
                    that.EmitBloodUnderSprite(s);
                }
                else
                {
                    if (that.Sync_GuardKilled != null)
                        that.Sync_GuardKilled(DamageOwner);

                    that.RemoveBloodUnderSprite(s);

                    Assets.Default.Sounds.death.play();

                    // player wont be blocked by a corpse
                    s.Range = 0;

                    // animate death
                    FrameRate_DeathAnimation.AtInterval(
                        ttt =>
                        {
                            if (Death.Length == ttt.currentCount)
                            {
                                ttt.stop();
                                return;
                            }

                            s.Frames = new[] { Death[ttt.currentCount] };
                        }
                    );
                }

                if (s.TakeDamageDone != null)
                    s.TakeDamageDone(DamageToBeTaken, DamageOwner);
            }
        public SpriteInfoExtended CreateWalkingDummy(Texture64[] _Stand, Texture64[][] _Walk, Texture64[] Hit, Texture64[] Death, Texture64[] Shooting)
        {
            //            1:0072:0051 FlashTreasureHunt.ApplicationSprite create FlashTreasureHunt.ActionScript.FlashTreasureHunt+<>c__DisplayClassb8

            //error at CopyType:
            //         * Illegal one-byte branch at position: 84. Requested branch was: 128.
            //         * FlashTreasureHunt.ActionScript.FlashTreasureHunt+<>c__DisplayClassb8 0200003d

            //         * IllegalBranchAt 00000054

            //         * RequestedBranch 128

            var Walk = _Walk;
            var Stand = _Stand;

            var tt = default(Timer);
            var s = new SpriteInfoExtended();

            s.Health = GuardMaxHealth;

            int WalkingAnimationFrame = 0;

            Action start =
                delegate
                {
                    s.WalkingAnimationRunning = true;

                    if (Walk.Length > 0)
                        tt = (200).AtInterval(
                            t =>
                            {
                                WalkingAnimationFrame = CreateWalkingDummy_Walk(Walk, s, WalkingAnimationFrame, t);
                                return;
                            }
                        );
                };

            Action stop =
                delegate
                {
                    s.WalkingAnimationRunning = false;

                    if (tt != null)
                        tt.stop();

                    s.Frames = Stand;
                };


            s.Position = new Point { x = EgoView.ViewPositionX, y = EgoView.ViewPositionY };
            s.Frames = Stand;
            s.Direction = EgoView.ViewDirection;
            s.StartWalkingAnimation = start;
            s.StopWalkingAnimation = stop;
            s.Range = PlayerRadiusMargin;

            s.AddTo(EgoView.Sprites);

            Action UpdateCurrentFrame =
                delegate
                {
                    if (s.Health <= 0)
                        return;
                    if (!s.AIEnabled)
                        return;

                    if (s.WalkingAnimationRunning)
                        s.Frames = Walk[WalkingAnimationFrame];
                    else
                        s.Frames = Stand;
                };

            if (Shooting != null)
            {
                #region prepare
                #region clone

                var WalkShooting = Enumerable.ToArray(
                    _Walk.Select(r0 => Enumerable.ToArray(r0))
                );

                var StandShooting = Enumerable.ToArray(
                    _Stand
                );

                #endregion

                // 0 .. 8
                Action<int> ApplyShootingFrame =
                    ShootingFrameIndex =>
                    {
                        var k = Shooting.AtModulus(ShootingFrameIndex);

                        StandShooting[1] = k;
                        StandShooting[2] = k;
                        StandShooting[3] = k;

                        foreach (var v in WalkShooting)
                        {
                            v[1] = k;
                            v[2] = k;
                            v[3] = k;
                        }

                        UpdateCurrentFrame();
                    };
                #endregion

                var PlayShootingAnimationTimer = default(Timer);

                s.PlayShootingAnimation +=
                    delegate
                    {
                        // for a short period of time we need to overwrite
                        // stand and walk frames

                        Walk = WalkShooting;
                        Stand = StandShooting;

                        if (PlayShootingAnimationTimer != null)
                            PlayShootingAnimationTimer.stop();

                        PlayShootingAnimationTimer = FrameRate_ShootingAnimation.Chain(
                            () => ApplyShootingFrame(0)
                        ).Chain(
                            () => ApplyShootingFrame(1)
                        ).Chain(
                            () => ApplyShootingFrame(2)
                        ).Chain(
                            () => ApplyShootingFrame(1)
                        ).Chain(
                            () => ApplyShootingFrame(0)
                        ).Chain(
                            delegate
                            {
                                // revert soon after animation finishes
                                Walk = _Walk;
                                Stand = _Stand;
                                UpdateCurrentFrame();

                                PlayShootingAnimationTimer = null;
                            }
                        ).Do();
                    };
            }

            if (Hit != null)
                s.TakeDamage +=
                    (DamageToBeTaken, DamageOwner) =>
                    {
                        CreateWalkingDummy_TakeDamage.Invoke(this, Hit, Death, s, DamageToBeTaken, DamageOwner);
                        return;

                    };


            return s;
        }
예제 #9
0
		public SpriteInfo CreateWalkingDummy(Texture64[] Stand, params Texture64[][] Walk)
		{
			var s = new SpriteInfo
			{
				Position = new Point { x = EgoView.ViewPositionX, y = EgoView.ViewPositionY },
				Frames = Stand,
				Direction = EgoView.ViewDirection
			}.AddTo(EgoView.Sprites);

			if (Walk.Length > 0)
				(200).AtInterval(
					t =>
					{
						s.Frames = Walk[t.currentCount % Walk.Length];
					}
				);

			return s;
		}
예제 #10
0
		public SpriteInfo CreateDummy(Texture64 Stand)
		{
			return CreateWalkingDummy(new[] { Stand });

		}