Пример #1
0
        public override void OnUpdate()
        {
            if (!DF.Window.IsFocused)
            {
                return;
            }

            Core.I._SetTick(Core.I.Tick + 1);

            if (DFKeyboard.G.IsKeyDown)
            {
                (Core.I.Entities.MainEntity as EntityPlayer)?.SetGod();
            }

            ControlCamera();
            RenderMap();

            var entities = Core.I.Entities;

            entities.Draw();
            entities.Update();

            hud.Text = shadow.Text = GenerateHUD();

            // プレイヤーの死亡処理
            if (!handlingDying && !Core.I.IsFreezing && ((entities.MainEntity is EntityLiving liv && liv.IsDying) || entities.MainEntity.IsDead))
            {
                CoroutineRunner.Start(HandleDying());
            }

            // ゴールハンドリング
            if (!handlingGoal && !handlingDying && !Core.I.IsFreezing && Core.I.IsGoal)
            {
                CoroutineRunner.Start(HandleGoal());
            }

            if ((eventRuntimeIterator == null) || !eventRuntimeIterator.MoveNext())
            {
                eventRuntimeIterator = EventRuntime.Execute();
            }

            if (EventRuntime.BalloonIsShowing && !Root.Contains(messageBox))
            {
                Root.Add(messageBox);
            }
            if (!EventRuntime.BalloonIsShowing && Root.Contains(messageBox))
            {
                Root.Remove(messageBox);
            }
            message.Text = EventRuntime.MesBuffer;

            messageBox.Location = new Vector(
                Const.Width / 2 - messageBox.Width / 2,
                EventRuntime.MesPos == EventRuntime.UpDown.Up
                                        ? 2
                                        : Const.Height - messageBox.Height - 2
                );

            stage.Location = Core.I.Camera;
        }
Пример #2
0
        /// <summary>
        /// Tick 毎に呼ばれる Entity の処理イベントです。
        /// </summary>
        /// <param name="ks"></param>
        public override void OnUpdate()
        {
            foreach (EntityPlayer ep in Parent.FindEntitiesByType <EntityPlayer>())
            {
                if (ep.IsDying)
                {
                    continue;
                }


                // プレイヤーと自分の当たり判定があり、上キーが押されたとき、スクリプト実行
                if ((_canExecuteScript = new Rectangle((int)ep.Location.X, (int)ep.Location.Y, ep.Size.Width, ep.Size.Height)
                                         .CheckCollision(new Rectangle((int)Location.X, (int)Location.Y, Size.Width,
                                                                       Size.Height))) && DFKeyboard.Up)
                {
                    try
                    {
                        EventRuntime.AddScript(new EventScript(_myScript));
                    }
                    catch (EventScript.EventScriptException ex)
                    {
                        EventRuntime.AddScript(new EventScript($@"[enstop]
[mesbox:down]
[mes:""エラー!\n{ex.Message.Replace(@"\", @"\\").Replace(@"""", @"\""")}""]
[mesend]
[enstart]"));
                    }
                }
            }
            base.OnUpdate();
        }
Пример #3
0
        /// <summary>
        /// Tick 毎に呼ばれる Entity の処理イベントです。
        /// </summary>
        /// <param name="ks"></param>
        public override void OnUpdate()
        {
            var ep = Parent.MainEntity;

            base.OnUpdate();
            // プレイヤーと自分の当たり判定があったとき、スクリプト実行。
            // ReSharper disable once AssignmentInConditionalExpression
            if (_triggered = new Rectangle((int)ep.Location.X, (int)ep.Location.Y, ep.Size.Width, ep.Size.Height)
                             .CheckCollision(new Rectangle((int)Location.X, (int)Location.Y, Size.Width,
                                                           Size.Height)))
            {
                // 実行済みなら実行しない
                if ((_option == ScriptRepeatingOption.NoRepeat) && _executed)
                {
                    return;
                }
                if ((_option == ScriptRepeatingOption.RepeatWhenMainEntityLeaveAndReenter) && _bTriggered)
                {
                    return;
                }

                EventRuntime.AddScript(new EventScript(_myScript));
                _executed = true;
            }
        }
Пример #4
0
        /// <summary>
        /// この EntityPlayer を殺害します。
        /// </summary>
        public override void Kill()
        {
            if (IsDying)
            {
                return;
            }

            if (IsFall)
            {
                base.Kill();
                Velocity = Vector.Zero;
                Life     = 0;
                return;
            }


            if (MutekiTime > 0)
            {
                return;
            }

            if (Life < 1)
            {
                try
                {
                    EventRuntime.AddScript(new EventScript(_endScript));
                }
                catch (EventScript.EventScriptException ex)
                {
                    EventRuntime.AddScript(new EventScript($@"[enstop]
[mesbox:down]
[mes:""エラー!\n{ex.Message.Replace(@"\", @"\\").Replace(@"""", @"\""")}""]
[mesend]
[enstart]"));
                }

                base.Kill();

                return;
            }

            DESound.Play(Sounds.PowerDown);

            MutekiTime = 180;

            Life -= IsCrushed ? MaxLife / 3 : 1;
        }
Пример #5
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]"));
                    }
                }

                return;
            }
            switch (_nowBehavior)
            {
            case QueenBossBehaviorOption.Waiting1:
                if (Tick == 0)
                {
                    Tick         = 60;
                    _nowBehavior = QueenBossBehaviorOption.ThrowWeaponToLeft;
                    SetGraphic(16);
                }
                break;

            case QueenBossBehaviorOption.ThrowWeaponToLeft:
                if (Tick == 30)
                {
                    DESound.Play(Sounds.ShootArrow);
                    SetGraphic(17);
                    Parent.Add(
                        new EntityCircusBall(Location, Mpts, Map, Parent).SetEntityData(
                            DynamicJson.Parse(DynamicJson.Serialize(new { SpeedX = -2.0f }))));
                }
                if (Tick == 0)
                {
                    _nowBehavior = QueenBossBehaviorOption.MoveToLeft;
                    SetAnime(0, 3, 8);
                    Velocity.X = -1.6f;
                }
                break;

            case QueenBossBehaviorOption.MoveToLeft:
                if ((Location.X <= _left - 16) || (Location.X <= 0) || (CollisionLeft() == ColliderType.Land))
                {
                    Tick         = 60;
                    _nowBehavior = QueenBossBehaviorOption.Waiting2;
                    SetGraphic(6);
                    Velocity.X = 0;
                }
                break;

            case QueenBossBehaviorOption.Waiting2:
                if (Tick == 0)
                {
                    Tick         = 60;
                    _nowBehavior = QueenBossBehaviorOption.ThrowWeaponToRight;
                    SetGraphic(18);
                }
                break;

            case QueenBossBehaviorOption.ThrowWeaponToRight:
                if (Tick == 30)
                {
                    DESound.Play(Sounds.ShootArrow);
                    Parent.Add(
                        new EntityCircusBall(Location, Mpts, Map, Parent).SetEntityData(
                            DynamicJson.Parse(DynamicJson.Serialize(new { SpeedX = 2.0f }))));
                    SetGraphic(19);
                }
                if (Tick == 0)
                {
                    _nowBehavior = QueenBossBehaviorOption.MoveToRight;
                    SetAnime(6, 9, 8);
                    Velocity.X = 1.6f;
                }
                break;

            case QueenBossBehaviorOption.MoveToRight:
                if (((Location.X >= _firstLoc.X) && (Location.X >= Core.I.CurrentMap.Size.X - 1)) ||
                    (CollisionRight() == ColliderType.Land))
                {
                    Tick         = 60;
                    _nowBehavior = QueenBossBehaviorOption.Waiting1;
                    SetGraphic(6);
                    Velocity.X = 0;
                }
                break;
            }

            Tick--;

            if (MutekiTime <= 0)
            {
                return;
            }
            MutekiTime--;
        }
Пример #6
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--;
        }