public override void OnUpdate(Status ks)
		{
			base.OnUpdate(ks);
			//FontUtility.DrawMiniString((int)Location.X - 9 + GameEngine.camera.X, (int)Location.Y + GameEngine.camera.Y, "" + AnimeSpeed, 0xffffff);


			if (!_isBattling)
			{
				// ReSharper disable once AssignmentInConditionalExpression
				if (_isBattling = Location.GetLengthTo(Parent.MainEntity.Location) < _startKyori)
				{
					try
					{
						EventRuntime.AddScript(new EventScript(_startScript));
					}
					catch (EventScript.EventScriptException ex)
					{
						EventRuntime.AddScript(new EventScript($@"[enstop]
[mesbox:down]
[mes:""エラー!\n{ex.Message.Replace(@"\", @"\\").Replace(@"""", @"\""")}""]
[mesend]
[enstart]"));
					}

					Velocity.X = -1.6f;
					InternalGravity = -0.04f;
					SetAnime(0, 3, 5);
				}

				return;
			}

			switch (_nowBehavior)
			{
				case KingBossBehaviorOption.JumpToLeft:
					if ((Location.Y <= _top) || (Location.Y <= 0) || (CollisionTop() == ObjectHitFlag.Hit))
					{
						Velocity.Y = InternalGravity = 0;
						Location.Y = _top;
					}
					if (Tick % 30 == 0)
					{
						SoundUtility.PlaySound(Sounds.ShootArrow);
						var r = Math.Atan2(Location.Y - Parent.MainEntity.Location.Y, Location.X - Parent.MainEntity.Location.X);
						float x = -(float) Math.Cos(r) * 3.4f,
							y = -(float) Math.Sin(r) * 3.4f;

						Parent.Add(new EntityPlayingCard(Location, Mpts, Map, Parent) {Velocity = new Vector(x, y)});
					}
					if ((Location.X <= _left) || (Location.X <= 0) || (CollisionLeft() == ObjectHitFlag.Hit))
					{
						InternalGravity = 0.1f;
						_nowBehavior = KingBossBehaviorOption.Waiting1;
						Tick = -1;
					}
					break;
				case KingBossBehaviorOption.Waiting1:
					if ((Tick < 0) && (CollisionBottom() == ObjectHitFlag.Hit))
						Tick = 120;

					if (Tick == 100)
						SetGraphic(0);
					if (Tick == 80)
						SetGraphic(6);
					if (Tick == 0)
					{
						_nowBehavior = KingBossBehaviorOption.ThrowChocolateToRight;
						Tick = 120;
						Parent.Add(GameEngine.EntityRegister.CreateEntity("Bunyo", new PointF(Location.X, Location.Y - 16), Mpts, Map,
							Parent));

						SoundUtility.PlaySound(Sounds.ItemSpawn);
					}

					break;
				case KingBossBehaviorOption.ThrowChocolateToRight:
					if (Tick <= 0)
					{
						_nowBehavior = KingBossBehaviorOption.JumpToRight;

						Velocity.X = 1.6f;
						InternalGravity = -0.04f;
						SetAnime(6, 9, 5);
					}
					break;
				case KingBossBehaviorOption.JumpToRight:

					if ((Location.Y <= _top) || (Location.Y <= 0) || (CollisionTop() == ObjectHitFlag.Hit))
						Velocity.Y = InternalGravity = 0;
					if (Tick % 30 == 0)
					{
						SoundUtility.PlaySound(Sounds.ShootArrow);
						var r = Math.Atan2(Location.Y - Parent.MainEntity.Location.Y, Location.X - Parent.MainEntity.Location.X);
						float x = -(float) Math.Cos(r) * 3.4f,
							y = -(float) Math.Sin(r) * 3.4f;

						Parent.Add(new EntityPlayingCard(Location, Mpts, Map, Parent) {Velocity = new Vector(x, y)});
					}
					if (((Location.X >= _firstLoc.X) && (Location.X >= GameEngine.Map.Width - 1)) ||
						(CollisionRight() == ObjectHitFlag.Hit))
					{
						InternalGravity = 0.1f;
						Velocity.X = 0;
						_nowBehavior = KingBossBehaviorOption.Waiting2;
						Tick = -1;
					}
					break;
				case KingBossBehaviorOption.Waiting2:
					if ((Tick < 0) && (CollisionBottom() == ObjectHitFlag.Hit))
						Tick = 120;

					if (Tick == 100)
						SetGraphic(6);
					if (Tick == 80)
						SetGraphic(0);
					if (Tick == 0)
					{
						_nowBehavior = KingBossBehaviorOption.ThrowChocolateToLeft;
						Parent.Add(GameEngine.EntityRegister.CreateEntity("SoulChocolate", new PointF(Location.X, Location.Y - 16), Mpts,
							Map, Parent));
						Tick = 120;

						SoundUtility.PlaySound(Sounds.ItemSpawn);
					}

					break;
				case KingBossBehaviorOption.ThrowChocolateToLeft:
					if (Tick <= 0)
					{
						_nowBehavior = KingBossBehaviorOption.JumpToLeft;


						Velocity.X = -1.6f;
						InternalGravity = -0.04f;
						SetAnime(0, 3, 5);
					}
					break;
			}

			Tick--;

			if (MutekiTime <= 0) return;
			MutekiTime--;
		}
示例#2
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            //FontUtility.DrawMiniString((int)Location.X - 9 + GameEngine.camera.X, (int)Location.Y + GameEngine.camera.Y, "" + AnimeSpeed, 0xffffff);


            if (!_isBattling)
            {
                // ReSharper disable once AssignmentInConditionalExpression
                if (_isBattling = Location.Distance(Parent.MainEntity.Location) < _startKyori)
                {
                    try
                    {
                        EventRuntime.AddScript(new EventScript(_startScript));
                    }
                    catch (EventScript.EventScriptException ex)
                    {
                        EventRuntime.AddScript(new EventScript($@"[enstop]
[mesbox:down]
[mes:""エラー!\n{ex.Message.Replace(@"\", @"\\").Replace(@"""", @"\""")}""]
[mesend]
[enstart]"));
                    }

                    Velocity.X      = -1.6f;
                    InternalGravity = -0.04f;
                    SetAnime(0, 3, 5);
                }

                return;
            }

            switch (_nowBehavior)
            {
            case KingBossBehaviorOption.JumpToLeft:
                if ((Location.Y <= _top) || (Location.Y <= 0) || (CollisionTop() == ColliderType.Land))
                {
                    Velocity.Y = InternalGravity = 0;
                    Location.Y = _top;
                }
                if (Tick % 30 == 0)
                {
                    DESound.Play(Sounds.ShootArrow);
                    var   r = Math.Atan2(Location.Y - Parent.MainEntity.Location.Y, Location.X - Parent.MainEntity.Location.X);
                    float x = -(float)Math.Cos(r) * 3.4f,
                          y = -(float)Math.Sin(r) * 3.4f;

                    Parent.Add(new EntityPlayingCard(Location, Mpts, Map, Parent)
                    {
                        Velocity = new Vector(x, y)
                    });
                }
                if ((Location.X <= _left) || (Location.X <= 0) || (CollisionLeft() == ColliderType.Land))
                {
                    InternalGravity = 0.1f;
                    _nowBehavior    = KingBossBehaviorOption.Waiting1;
                    Tick            = -1;
                }
                break;

            case KingBossBehaviorOption.Waiting1:
                if ((Tick < 0) && (CollisionBottom() == ColliderType.Land))
                {
                    Tick = 120;
                }

                if (Tick == 100)
                {
                    SetGraphic(0);
                }
                if (Tick == 80)
                {
                    SetGraphic(6);
                }
                if (Tick == 0)
                {
                    _nowBehavior = KingBossBehaviorOption.ThrowChocolateToRight;
                    Tick         = 120;
                    Parent.Add(Core.I.EntityRegistry.CreateEntity("Bunyo", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                                  Parent));

                    DESound.Play(Sounds.ItemSpawn);
                }

                break;

            case KingBossBehaviorOption.ThrowChocolateToRight:
                if (Tick <= 0)
                {
                    _nowBehavior = KingBossBehaviorOption.JumpToRight;

                    Velocity.X      = 1.6f;
                    InternalGravity = -0.04f;
                    SetAnime(6, 9, 5);
                }
                break;

            case KingBossBehaviorOption.JumpToRight:

                if ((Location.Y <= _top) || (Location.Y <= 0) || (CollisionTop() == ColliderType.Land))
                {
                    Velocity.Y = InternalGravity = 0;
                }
                if (Tick % 30 == 0)
                {
                    DESound.Play(Sounds.ShootArrow);
                    var   r = Math.Atan2(Location.Y - Parent.MainEntity.Location.Y, Location.X - Parent.MainEntity.Location.X);
                    float x = -(float)Math.Cos(r) * 3.4f,
                          y = -(float)Math.Sin(r) * 3.4f;

                    Parent.Add(new EntityPlayingCard(Location, Mpts, Map, Parent)
                    {
                        Velocity = new Vector(x, y)
                    });
                }
                if (((Location.X >= _firstLoc.X) && (Location.X >= Core.I.CurrentMap.Size.X - 1)) ||
                    (CollisionRight() == ColliderType.Land))
                {
                    InternalGravity = 0.1f;
                    Velocity.X      = 0;
                    _nowBehavior    = KingBossBehaviorOption.Waiting2;
                    Tick            = -1;
                }
                break;

            case KingBossBehaviorOption.Waiting2:
                if ((Tick < 0) && (CollisionBottom() == ColliderType.Land))
                {
                    Tick = 120;
                }

                if (Tick == 100)
                {
                    SetGraphic(6);
                }
                if (Tick == 80)
                {
                    SetGraphic(0);
                }
                if (Tick == 0)
                {
                    _nowBehavior = KingBossBehaviorOption.ThrowChocolateToLeft;
                    Parent.Add(Core.I.EntityRegistry.CreateEntity("SoulChocolate", new Vector(Location.X, Location.Y - 16), Mpts,
                                                                  Map, Parent));
                    Tick = 120;

                    DESound.Play(Sounds.ItemSpawn);
                }

                break;

            case KingBossBehaviorOption.ThrowChocolateToLeft:
                if (Tick <= 0)
                {
                    _nowBehavior = KingBossBehaviorOption.JumpToLeft;


                    Velocity.X      = -1.6f;
                    InternalGravity = -0.04f;
                    SetAnime(0, 3, 5);
                }
                break;
            }

            Tick--;

            if (MutekiTime <= 0)
            {
                return;
            }
            MutekiTime--;
        }