Exemple #1
0
 protected virtual void SwitchMode()
 {
     if (!IsRunning)
     {
         IsRunning = true;
         CollisionAIs.Add(Killai);
         Mutekitime = Mutekimax;
         Owner      = null;
         DESound.Play(Sounds.Killed);
         Velocity.X = Parent.MainEntity.Location.X < Location.X ? Speed : -Speed;
         //Location.X += Velocity.X * 8;
         Velocity.Y = 0;
     }
     else
     {
         IsRunning  = false;
         Mutekitime = Mutekimax;
         if (CollisionAIs.Contains(Killai))
         {
             CollisionAIs.Remove(Killai);
         }
         DESound.Play(Sounds.Stepped);
         Velocity.X = 0;
         Velocity.Y = 0;
     }
 }
Exemple #2
0
        public override void Kill()
        {
            var e = new PreEventArgs();

            EntityLiving.PreKill?.Invoke(this, e);
            if (e.IsCanceled)
            {
                return;
            }

            IsDying   = true;
            DyingTick = DyingMax;
            if (IsDying)
            {
                SetKilledAnime();
            }
            if (IsCrushed)
            {
                SetCrushedAnime();
            }
            if (!IsCrushed && !IsFall)
            {
                DESound.Play(KilledSound);
            }
            Velocity = Vector.Zero;
        }
 public override void OnUpdate()
 {
     foreach (EntityLiving el in new List <Entity>(HostEntity.Parent.FindEntitiesByType <EntityLiving>()))
     {
         if (el.MyGroup != EntityGroup.Enemy)
         {
             continue;
         }
         if (el.IsDying)
         {
             continue;
         }
         if (
             new Rectangle((int)HostEntity.Location.X, (int)HostEntity.Location.Y + HostEntity.Size.Height - 1,
                           HostEntity.Size.Width, 1).CheckCollision(new Rectangle((int)el.Location.X, (int)el.Location.Y, el.Size.Width,
                                                                                  el.Size.Height / 4)))
         {
             if (DFKeyboard.Z)
             {
                 HostEntity.Velocity.Y = -3;
             }
             else
             {
                 HostEntity.Velocity.Y = -1f;
             }
             el.Kill(false, true);
             DESound.Play(Sounds.Stepped);
         }
     }
 }
Exemple #4
0
        public override void OnUpdate()
        {
            foreach (var(item, i) in menuItems.Select((item, index) => (item, index)))
            {
                if (selectedIndex == i)
                {
                    item.Color = Color.Yellow;
                    item.Text  = "♪" + item.Text.Substring(1);
                }
                else
                {
                    item.Color = Color.White;
                    item.Text  = " " + item.Text.Substring(1);
                }
            }
            if (!DF.Window.IsFocused)
            {
                return;
            }

            if (DFKeyboard.Up.IsKeyDown)
            {
                selectedIndex--;
            }
            if (DFKeyboard.Down.IsKeyDown)
            {
                selectedIndex++;
            }
            if (selectedIndex < 0)
            {
                selectedIndex = menuItems.Length - 1;
            }
            if (selectedIndex > menuItems.Length - 1)
            {
                selectedIndex = 0;
            }
            if (DFKeyboard.Z.IsKeyDown)
            {
                if (selectedIndex == menuItems.Length - 1)
                {
                    DESound.Play(Sounds.Back);
                    Core.I.BgmStop();
                    DF.Router.ChangeScene <TitleScene>();
                }
                else
                {
                    Core.I.BgmPlay(AudioFileList[selectedIndex]);
                }
            }
            if (DFKeyboard.X.IsKeyDown)
            {
                Core.I.BgmStop(0);
            }
        }
        internal void SetGod()
        {
            var e = new PlayerGodEventArgs(600, true);

            PreGod?.Invoke(this, e);

            if (!e.IsCanceled)
            {
                AteGodItem = true;
                GodTime    = e.Time;

                DESound.Play(Sounds.PowerUp);
                Core.I.BgmPlay("bgm_god.mid");
            }
        }
Exemple #6
0
        public override void OnUpdate()
        {
            if (!_animating)
            {
                switch (_worktype)
                {
                case WorkingType.Normal:
                    Velocity.Y = 0;
                    foreach (var entity in Parent.FindEntitiesByType <EntityPlayer>())
                    {
                        var ep = (EntityPlayer)entity;
                        if (!ep.IsDying && new RectangleF(ep.Location.ToPoint(), ep.Size).CheckCollision(new RectangleF(Location.ToPoint(), Size)))
                        {
                            _animating = true;
                        }
                    }
                    break;

                case WorkingType.FromBlock:
                    _animating = true;
                    DESound.Play(Sounds.GetCoin);
                    Core.I.Coin++;
                    break;
                }
            }

            if (_animating)
            {
                switch (_worktype)
                {
                case WorkingType.Normal:
                    IsDead = true;
                    Parent.Add(Core.I.EntityRegistry.CreateEntity("Coin", Location, Mpts, Map, Parent,
                                                                  DynamicJson.Parse(@"{""WorkingType"": 1}")));
                    break;

                case WorkingType.FromBlock:
                    Velocity.Y *= 0.8f;
                    if (Velocity.Y > -0.1f)
                    {
                        Kill();
                    }
                    break;
                }
            }

            base.OnUpdate();
        }
        /// <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;
        }
 public override void UpdatePhysics(ColliderType top, ColliderType bottom, ColliderType left, ColliderType right)
 {
     base.UpdatePhysics(top, bottom, left, right);
     var(x, y) = (VectorInt)Location;
     for (var i = (int)Collision.Left; i < Collision.Right; i++)
     {
         if (top.IsLandLike() && Map[(x + i) / 16, (y - 1) / 16, 0] == 9)
         {
             Map[(x + i) / 16, (y - 1) / 16, 0] = 0;
             DESound.Play(Sounds.Destroy);
             Particle.BrokenBlock(new Point(x, y), Parent, Mpts);
         }
     }
     if (IsOnLand)
     {
         IsJumping = false;
     }
 }
        public override void OnUpdate()
        {
            if ((_tick > 140) && !IsDying)
            {
                _tick = 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) * 2.2f,
                      y = -(float)Math.Sin(r) * 2.2f;

                Parent.Add(new EntityDocument(Location, Mpts, Map, Parent)
                {
                    Velocity = new Vector(x, y)
                });
            }
            _tick++;

            base.OnUpdate();
        }
        internal void PowerUp(PlayerForm f)
        {
            var e = new PlayerPowerUpEventArgs(f);

            PrePowerUp?.Invoke(this, e);
            f = e.Form;
            if (e.IsCanceled)
            {
                return;
            }

            switch (f)
            {
            case PlayerForm.Fire:
            case PlayerForm.Magic:
            case PlayerForm.Ice:
                DESound.Play(Sounds.GetWeapon);
                Size = new Size(12, 30);
                break;
            }
            Form = f;
        }
        public override void OnUpdate()
        {
            if (CollisionBottom() == ColliderType.Land)
            {
                Life--;
                Location.Y += Velocity.Y = -4.3f;
                DESound.Play(Sounds.Dumping);
            }

            if ((CollisionLeft() == ColliderType.Land) || (CollisionRight() == ColliderType.Land))
            {
                Life--;
                Location.X += Velocity.X *= -1;
                DESound.Play(Sounds.Dumping);
            }

            if (Life < 0)
            {
                Kill();
            }
            base.OnUpdate();
        }
 public override void OnUpdate()
 {
     if (Velocity.Y < 0)
     {
         Velocity.Y += 0.1f;
     }
     else if (MainAi == null)
     {
         MainAi = new AiFlySine(this, 0, 5, 5, 5, 5);
     }
     foreach (var entity in Parent.FindEntitiesByType <EntityPlayer>())
     {
         var ep = (EntityPlayer)entity;
         if (!ep.IsDying && new RectangleF(ep.Location.ToPoint(), ep.Size).CheckCollision(new RectangleF(Location.ToPoint(), Size)))
         {
             ep.Life++;
             DESound.Play(Sounds.LifeUp);
             IsDead = true;
         }
     }
     base.OnUpdate();
 }
Exemple #13
0
        public override void OnUpdate()
        {
            if (((_nowstatus != 2) && (_nowstatus != 0) && (_tick == 15)) || (_tick == 30))
            {
                if (_nowstatus == 2 && Core.I.CurrentMap != null)
                {
                    DESound.Play(Sounds.ShootArrow);

                    var speed = HostEntity.Direction == Direction.Right ? Core.GetRand(4) + 1 : -Core.GetRand(4) - 1;
                    HostEntity.Parent.Add(Core.I.EntityRegistry.CreateEntity("Arrow",
                                                                             new Vector(HostEntity.Location.X + (HostEntity.Direction == Direction.Left ? 0 : HostEntity.Size.Width),
                                                                                        HostEntity.Location.Y + HostEntity.Size.Height / 2), Core.I.Tiles, Core.I.CurrentMap.Chips, HostEntity.Parent,
                                                                             DynamicJson.Parse("{\"Speed\": " + speed + " }")));
                }
                _tick      = -1;
                _nowstatus = (_nowstatus + 1) % 4;
            }
            if (HostEntity.Parent.MainEntity.Location.X < HostEntity.Location.X)
            {
                HostEntity.SetGraphic(_nowstatus + (HostEntity.Direction == Direction.Right ? 4 : 0));
            }
            _tick++;
        }
 private void ProcessGod()
 {
     if (PowerupTime > 0)
     {
         PowerupTime--;
     }
     if (GodTime > 0)
     {
         GodTime--;
         if ((GodTime == 90) && AteGodItem)
         {
             DESound.Play(Sounds.WarningMuteki);
         }
         if ((GodTime == 0) && AteGodItem)
         {
             AteGodItem = false;
             Core.I.BgmStop();
             if (Core.I.CurrentAreaInfo != null)
             {
                 Core.I.BgmPlay(Core.I.CurrentAreaInfo.Music);
             }
         }
     }
 }
        private void OpenItem(EntityPlayer?player)
        {
            switch (_item)
            {
            case Items.Coin:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("Coin", Location, Mpts, Map, Parent,
                                                              DynamicJson.Parse(@"{""WorkingType"": 1}")));
                break;

            case Items.SoulChocolate:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("SoulChocolate", new Vector(Location.X, Location.Y - 16), Mpts,
                                                              Map, Parent));
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.Grimoire:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("Grimoire", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                              Parent));
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.FireWands:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("FireWands", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                              Parent));
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.PepperOrPillow:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("FireWands", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                              Parent)
                           );
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.IcyPendant:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("IcyPendant", new Vector(Location.X, Location.Y - 6), Mpts, Map,
                                                              Parent)
                           );
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.IceOrPillow:
                //Parent.Add((player.Form == PlayerForm.Mini) ?
                //	Game.I.EntityRegister.CreateEntity("SoulChocolate", new Vector(Location.X, Location.Y - 16), Mpts, Map, Parent) :
                //	Game.I.EntityRegister.CreateEntity("IcyPendant", new Vector(Location.X, Location.Y - 16), Mpts, Map, Parent)
                //	);
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.LeafOrPillow:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("Grimoire", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                              Parent)
                           );
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.Feather:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("Feather", new Vector(Location.X, Location.Y - 16), Mpts, Map,
                                                              Parent));
                DESound.Play(Sounds.ItemSpawn);
                break;

            case Items.FeatherOrCoin:
                if (player != null && player.GodTime != 0)
                {
                    Parent.Add((player.GodTime > 0) && player.AteGodItem
                                                                ? Core.I.EntityRegistry.CreateEntity("Feather", new Vector(Location.X, Location.Y - 16), Mpts, Map, Parent)
                                                                : Core.I.EntityRegistry.CreateEntity("Coin", new Vector(Location.X, Location.Y - 16), Mpts, Map, Parent,
                                                                                                     DynamicJson.Parse(@"{""WorkingType"": 1}"))
                               );
                    DESound.Play(Sounds.ItemSpawn);
                }
                else
                {
                    goto case Items.Coin;
                }
                break;

            case Items.PoisonMushroom:
                Parent.Add(Core.I.EntityRegistry.CreateEntity("PoisonMushroom", new Vector(Location.X, Location.Y - 16), Mpts,
                                                              Map, Parent));
                DESound.Play(Sounds.ItemSpawn);
                break;
            }
            Map[(int)(Location.X / 16), (int)(Location.Y / 16), 0] = 10;
            Kill();
        }
Exemple #16
0
        public void UpdateStatus()
        {
            switch (_nowstatus)
            {
            case 0:                     // 構え
                SetGraphic(0);
                foreach (EntityLiving sp in new List <Entity>(Parent.FindEntitiesByType <EntityLiving>()))
                {
                    if ((sp.MyGroup != EntityGroup.Friend) && (sp.MyGroup != EntityGroup.Enemy))
                    {
                        continue;
                    }

                    if (sp.IsDying)
                    {
                        continue;
                    }
                    if (new Rectangle((int)(sp.Location.X + sp.Collision.Left), (int)(sp.Location.Y + sp.Collision.Bottom),
                                      (int)sp.Collision.Width, 3).CheckCollision(
                            new Rectangle((int)(Location.X + Collision.Left), (int)(Location.Y + Collision.Y), (int)Collision.Width,
                                          (int)Collision.Height)))
                    {
                        _nowstatus  = 1;
                        _tick       = -1;
                        sp.Velocity = Vector.Zero;
                    }
                }

                if (_tick > 240)
                {
                    _tick = -1;
                    _nowstatus++;

                    DESound.Play(Sounds.Paku1);
                }
                break;

            case 1:                     // 閉じようとする
                SetGraphic(1);
                foreach (EntityLiving sp in new List <Entity>(Parent.FindEntitiesByType <EntityLiving>()))
                {
                    if ((sp.MyGroup != EntityGroup.Friend) && (sp.MyGroup != EntityGroup.Enemy))
                    {
                        continue;
                    }

                    if (sp.IsDying)
                    {
                        continue;
                    }
                    if (new Rectangle((int)(sp.Location.X + sp.Collision.Left), (int)(sp.Location.Y + sp.Collision.Bottom),
                                      (int)sp.Collision.Width, 3).CheckCollision(
                            new Rectangle((int)(Location.X + Collision.Left), (int)(Location.Y + Collision.Y), (int)Collision.Width,
                                          (int)Collision.Height)))
                    {
                        sp.Velocity = Vector.Zero;
                    }
                }
                if (_tick > 30)
                {
                    _tick = -1;
                    _nowstatus++;
                    DESound.Play(Sounds.Paku2);
                    foreach (EntityLiving sp in new List <Entity>(Parent.FindEntitiesByType <EntityLiving>()))
                    {
                        if ((sp.MyGroup != EntityGroup.Friend) && (sp.MyGroup != EntityGroup.Enemy))
                        {
                            continue;
                        }

                        if (sp.IsDying)
                        {
                            continue;
                        }
                        if ((sp != this) &&
                            new RectangleF(sp.Location.X, sp.Location.Y, sp.Size.Width, sp.Size.Height).CheckCollision(
                                new RectangleF(Location.X, Location.Y, Size.Width, Size.Height)))
                        {
                            sp.Kill();
                            _nowstatus = 2;
                            _tick      = -1;
                        }
                    }
                }
                break;

            case 2:                     // 閉じる
                SetGraphic(2);
                if (_tick > 120)
                {
                    _tick = -1;
                    _nowstatus++;
                }
                break;

            case 3:                     // むずむず
                if ((_tick == 0) || (_tick == 30))
                {
                    DESound.Play(Sounds.Poyo);
                    SetGraphic(3);
                }
                else if ((_tick == 15) || (_tick == 60))
                {
                    DESound.Play(Sounds.Poyo);
                    SetGraphic(4);
                }
                if (_tick > 70)
                {
                    _nowstatus++;
                    _tick = -1;
                }

                break;

            case 4:                     // 開けようとする
                SetGraphic(1);
                if (_tick > 30)
                {
                    _tick      = -1;
                    _nowstatus = 0;
                }
                break;
            }
            _tick++;
        }
        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--;
        }
Exemple #18
0
 /// <summary>
 /// 水中から出た時に呼ばれます。
 /// </summary>
 public virtual void OnOutOfWater()
 {
     DESound.Play(Sounds.WaterSplash);
 }
Exemple #19
0
 public override void OnStucked()
 {
     DESound.Play(Sounds.StuckArrow);
     base.OnStucked();
 }
        public static IEnumerator Execute()
        {
            if ((CurrentScript == null) && (EventScriptQueue.Count > 0))
            {
                CurrentScript = EventScriptQueue.Dequeue();
            }

            if ((CurrentScript != null) && (CurrentScript.Current != null))
            {
                var args = CurrentScript.Current.Args;
                switch (CurrentScript.Current.Name)
                {
                case "bgm":
                    if (args == null)
                    {
                        Core.I.BgmPlay();
                    }
                    else
                    {
                        Core.I.BgmPlay(args[0]);
                    }
                    break;

                case "bgmstop":

                    int time;
                    if (args == null)
                    {
                        Core.I.BgmStop();
                    }
                    else if (int.TryParse(args[0], out time))
                    {
                        Core.I.BgmStop(time);
                    }
                    break;

                case "se":
                    int id;
                    if (int.TryParse(args[0], out id))
                    {
                        DESound.Play(id);
                    }
                    else
                    {
                        Sounds snd;
                        if (Enum.TryParse(args[0], out snd))
                        {
                            DESound.Play(snd);
                        }
                    }
                    break;

                case "mesbox":
                    BalloonIsShowing = true;
                    goto case "messtart";

                case "messtart":
                    if (args == null)
                    {
                        MesPos = UpDown.Down;
                    }
                    else
                    {
                        switch (args[0])
                        {
                        case "up":
                            MesPos = UpDown.Up;
                            break;

                        case "down":
                            MesPos = UpDown.Down;
                            break;
                        }
                    }
                    MessageIsShowing = true;
                    break;

                case "mes":
                    var mes  = args[0];
                    var tick = 2;
                    if (args.Length >= 2)
                    {
                        tick = int.Parse(args[1]);
                    }

                    // DFKeyboard.Z = false;
                    // DFKeyboard.Z.IsKeyDown = false;
                    foreach (var c in mes)
                    {
                        MesBuffer += c;

                        DESound.Play(Sounds.Speaking);
                        for (var i = 0; i < tick / (DFKeyboard.ShiftLeft ? 2 : 1); i++)
                        {
                            yield return(null);
                        }
                    }
                    IsWaitingResponse = true;
                    while (!DFKeyboard.Z.IsKeyDown)
                    {
                        yield return(null);
                    }
                    DESound.Play(Sounds.Selected);
                    yield return(null);

                    IsWaitingResponse = false;
                    MesBuffer         = "";
                    break;

                case "mescont":
                    mes  = args[0];
                    tick = 1;
                    if (args.Length >= 2)
                    {
                        tick = int.Parse(args[1]);
                    }

                    foreach (var c in mes)
                    {
                        MesBuffer += c;
                        DESound.Play(Sounds.Speaking);
                        for (var i = 0; i < tick / (DFKeyboard.ShiftLeft ? 2 : 1); i++)
                        {
                            yield return(null);
                        }
                    }
                    break;

                case "mesnod":

                    IsWaitingResponse = true;
                    while (!DFKeyboard.Z.IsKeyDown)
                    {
                        yield return(null);
                    }
                    // DFKeyboard.Z.IsKeyDown = false;

                    yield return(null);

                    DESound.Play(Sounds.Selected);
                    IsWaitingResponse = false;

                    MesBuffer = "";
                    break;

                case "mesend":
                    MessageIsShowing = false;
                    BalloonIsShowing = false;
                    break;

                case "enstop":
                    Core.I.IsFreezing = true;
                    break;

                case "enstart":
                    Core.I.IsFreezing = false;
                    break;

                case "wait":
                    for (var i = 0; i < int.Parse(args[0]); i++)
                    {
                        yield return(null);
                    }
                    break;

                case "bgmvol":
                    var ch  = int.Parse(args[0]);
                    var val = byte.Parse(args[1]);
                    if (val > 127)
                    {
                        val = 127;
                    }
                    if (ch < 0)
                    {
                        ch = 0;
                    }
                    if (ch > 15)
                    {
                        ch = 15;
                    }
                    // todo
                    // Seq.Sm.Channels[ch].Volume = val;
                    break;

                case "mpt":
                    if (Core.I.CurrentMap is MapData map)
                    {
                        int.TryParse(args[0], out var x);
                        int.TryParse(args[1], out var y);
                        var z = args[2];
                        if ((z != "表") && (z != "裏"))
                        {
                            break;
                        }
                        if (x < 0)
                        {
                            x = 0;
                        }
                        if (x > map.Size.X - 1)
                        {
                            x = map.Size.X - 1;
                        }
                        if (y < 0)
                        {
                            y = 0;
                        }
                        if (y > map.Size.Y - 1)
                        {
                            y = map.Size.Y - 1;
                        }

                        byte.TryParse(args[3], out var chip);
                        map.Chips[x, y, z == "表" ? 0 : 1] = chip;
                    }

                    break;

                case "teleport":
                case "tp":
                    var e = new PreEventArgs();
                    PreTeleport?.Invoke(e);
                    if (e.IsCanceled)
                    {
                        break;
                    }
                    int level, area;
                    Core.I.IsGoal = false;
                    Core.I.Middle = VectorInt.Zero;
                    switch (args.Length)
                    {
                    case 1:
                        int.TryParse(args[0], out level);
                        Core.I.LoadLevel(level);
                        break;

                    case 2:
                        int.TryParse(args[0], out level);
                        int.TryParse(args[1], out area);
                        Core.I.LoadLevel(level, area);
                        break;
                    }
                    PostTeleport?.Invoke(new EventArgs());
                    break;
                }

                if (CurrentScript.IsEndOfScript)
                {
                    Core.I.IsFreezing = false;
                    MessageIsShowing  = false;
                    BalloonIsShowing  = false;
                    CurrentScript     = null;
                }
                else
                {
                    CurrentScript.ProgramCounter++;
                }
            }
        }
        public void InputControl()
        {
            if (DFKeyboard.Left)
            {
                var e = new PreEventArgs();
                PreMove?.Invoke(this, e);
                if (!e.IsCanceled)
                {
                    Direction   = Direction.Left;
                    Velocity.X -= _spdAddition;
                    if (Velocity.X < -_spdlimit)
                    {
                        Velocity.X = -_spdlimit;
                    }
                }
            }
            else if (DFKeyboard.Right)
            {
                var e = new PreEventArgs();
                PreMove?.Invoke(this, e);
                if (!e.IsCanceled)
                {
                    Direction   = Direction.Right;
                    Velocity.X += _spdAddition;
                    if (Velocity.X > _spdlimit)
                    {
                        Velocity.X = _spdlimit;
                    }
                }
            }
            else
            {
                Velocity.X *= _spddivition;
                if ((Velocity.X < 0.1f) && (Velocity.X > -0.1f))
                {
                    Velocity.X = 0;
                }
            }

            if (DFKeyboard.Z.IsKeyDown)
            {
                if (!IsOnLand && DFKeyboard.Left && (CollisionLeft() == ColliderType.Land))
                {
                    Velocity.X = 3f;
                    Velocity.Y = -4f;
                    DESound.Play(Sounds.Destroy);
                }
                else if (!IsOnLand && DFKeyboard.Right && (CollisionRight() == ColliderType.Land))
                {
                    Velocity.X = -3f;
                    Velocity.Y = -4f;
                    DESound.Play(Sounds.Destroy);
                }
                else
                {
                    if (IsUnderWater)
                    {
                        DESound.Play(Sounds.Swim);
                        Velocity.Y = -2f;
                        IsJumping  = false;
                    }
                    else if (IsOnLand || (_flowtimer < 10))
                    {
                        var e = new PreEventArgs();
                        PreJump?.Invoke(this, e);
                        if (!e.IsCanceled)
                        {
                            if (!IsJumping)
                            {
                                DESound.Play(Sounds.BigJump);
                            }
                            Velocity.Y = -3.6f - Math.Abs(Velocity.X) / 6.5f;
                            IsJumping  = true;
                            Move();
                        }
                    }
                }
            }
            if (IsOnLand)
            {
                _flowtimer = 0;
            }
            else
            {
                _flowtimer++;
            }

            if (!DFKeyboard.Z && IsJumping)
            {
                Velocity.Y += 0.1f;
            }

            if (DFKeyboard.ShiftLeft)
            {
                _spdAddition = 0.4f;
                _spddivition = 0.9f;
                _spdlimit    = 2.7f;
                if (!_lshifted)
                {
                    switch (Form)
                    {
                    case PlayerForm.Fire:
                        DESound.Play(Sounds.ShootFire);
                        Parent.Add(
                            new EntityFireWeapon(Location, Mpts, Map, Parent).SetEntityData(
                                DynamicJson.Parse(@"{""SpeedX"": " +
                                                  (Direction == Direction.Right ? EntityFireWeapon.SpeedX : -EntityFireWeapon.SpeedX) + "}")));
                        break;

                    case PlayerForm.Ice:
                        DESound.Play(Sounds.ShootFire);
                        Parent.Add(
                            new EntityIceWeapon(Location, Mpts, Map, Parent).SetEntityData(
                                DynamicJson.Parse(@"{""SpeedX"": " +
                                                  (Direction == Direction.Right ? EntityIceWeapon.SpeedX : -EntityIceWeapon.SpeedX) + "}")));
                        break;

                    case PlayerForm.Magic:
                        DESound.Play(Sounds.ShootFire);
                        Parent.Add(new EntityMagicWeapon(Location, Mpts, Map, Parent));
                        break;
                    }
                }

                foreach (EntityLiving entity in Parent.FindEntitiesByType <EntityLiving>())
                {
                    var e = entity;
                    if (e.IsDying)
                    {
                        continue;
                    }
                    if ((GodTime > 0) && AteGodItem &&
                        ((e.MyGroup == EntityGroup.Enemy) || (e.MyGroup == EntityGroup.MonsterWeapon)) &&
                        new RectangleF(e.Location.X, e.Location.Y, e.Size.Width, e.Size.Height).CheckCollision(new RectangleF(Location.X,
                                                                                                                              Location.Y, Size.Width, Size.Height)))
                    {
                        e.Kill();
                    }
                }

                foreach (EntityTurcosShell e in Parent.FindEntitiesByType <EntityTurcosShell>())
                {
                    if (e.IsRunning)
                    {
                        if (new RectangleF(Location.ToPoint(), Size).CheckCollision(new RectangleF(e.Location.ToPoint(), e.Size)))
                        {
                            e.Owner = this;
                        }
                    }
                }
                _lshifted = true;
            }
            else
            {
                _lshifted    = false;
                _spdAddition = 0.2f;
                _spddivition = 0.9f;
                _spdlimit    = 1.4f;
            }
        }
        /// <summary>
        /// この EntityPlayer を殺害します。
        /// </summary>
        public override void Kill()
        {
            if (IsDying)
            {
                return;
            }
            if (IsFall)
            {
                base.Kill();

                // イベントで抑制されている可能性があるので確認する
                if (IsDying)
                {
                    Velocity = Vector.Zero;
                    Life     = 0;
                    DESound.Play(Sounds.PlayerMiss);
                }
                return;
            }
            if (Core.I.Time == 0)
            {
                base.Kill();
                if (IsDying)
                {
                    SetGraphic(5);
                }
                return;
            }
            if (GodTime > 0)
            {
                return;
            }

            var e = new PreEventArgs();

            PreDamage?.Invoke(this, e);
            if (!e.IsCanceled)
            {
                DESound.Play(Sounds.PowerDown);
                var e2 = new PlayerGodEventArgs(240, false);
                PreGod?.Invoke(this, e2);
                if (!e2.IsCanceled)
                {
                    GodTime = e2.Time;
                }
                Life--;

                if (Form != PlayerForm.Big)
                {
                    Form = PlayerForm.Big;
                }

                Velocity = Vector.Zero;
            }

            if (Life < 1)
            {
                SetGraphic(5);
                base.Kill();
            }
        }
Exemple #23
0
        public override void OnUpdate()
        {
            if (!IsDying)
            {
                if (!_isTension)
                {
                    if ((Math.Abs(Location.X - Parent.MainEntity.Location.X) < 64) && (Location.Y <= Parent.MainEntity.Location.Y) &&
                        (Parent.MainEntity.Location.Y <= Location.Y + Size.Height))
                    {
                        _isTension = true;
                        _tick      = 0;
                        Velocity.Y = 0.2f;
                    }
                }
                else
                {
                    if (_tick > 180)
                    {
                        _tick = -1;
                    }
                    _tick++;
                    if (_tick == 0)
                    {
                        if (((Math.Abs(Location.X - Parent.MainEntity.Location.X) >= 64) && (Location.Y > Parent.MainEntity.Location.Y)) ||
                            (Parent.MainEntity.Location.Y > Location.Y + Size.Height))
                        {
                            _isTension = false;
                            _tick      = 0;
                            goto nuke;
                        }
                        //SoundUtility.PlaySound(Sounds.Focus);
                        DESound.Play(Sounds.Shutter);
                    }

                    if ((_tick > 30) && (_tick < 60) && (_tick % 4 == 0))
                    {
                        Parent.Add(new EntityCameraRazer(Location, Mpts, Map, Parent));
                        DESound.Play(Sounds.Razer);
                    }

                    if (_tick == 60)
                    {
                        if (((Math.Abs(Location.X - Parent.MainEntity.Location.X) >= 64) && (Location.Y > Parent.MainEntity.Location.Y)) ||
                            (Parent.MainEntity.Location.Y > Location.Y + Size.Height))
                        {
                            _isTension = false;
                            _tick      = 0;
                            goto nuke;
                        }
                    }


                    SetGraphic(0);
                }
            }
nuke:
            if (!_isTension)
            {
                Jump();
            }
            base.OnUpdate();
        }
 public override void Kill()
 {
     DESound.Play(Sounds.BalloonBroken);
     IsDead = true;
 }
Exemple #25
0
 /// <summary>
 /// 水中に入った時に呼ばれます。
 /// </summary>
 public virtual void OnIntoWater()
 {
     DESound.Play(Sounds.WaterSplash);
 }
Exemple #26
0
 public void Initialize()
 {
     ResourceManager.Init();
     DESound.Init();
     Player.Gain = 1;
 }
Exemple #27
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--;
        }