Exemplo n.º 1
0
        private void Confirm()
        {
            alarm.IsEnabled    = true;
            alarm.ScheduleTime = new TimeSpan(Hours, Minutes, Seconds);

            Message = options[SelectedOption];
            if (Message.GetType() == typeof(SoundMessage))
            {
                Parameter = SoundPath;
            }
            if (Message.GetType() == typeof(TextMessage))
            {
                Parameter = TextMessage;
            }

            alarm.Message           = Message;
            alarm.Message.Parameter = Parameter;
            alarm.Days = Days;

            if (Title == "ADDING")
            {
                alarm.Create();
                AlarmRepository.Content.Add(alarm);
            }

            MessengerInstance.Send(new CloseEditWindowMessage());
        }
Exemplo n.º 2
0
        public static Boss Create()
        {
            var boss = new Boss();

            Instance                = boss;
            boss.BossImage          = new Image(Game1.BossImage);
            BossBloodImage          = new Image(Game1.BossBloodImage);
            BossBloodEntity         = new Entity();
            BossBloodImage.Position = new Vector2(25.0f, 10.0f);
            BossBloodEntity.Add(new Image(Game1.BossBloodBImage));
            BossBloodEntity.Add(BossBloodImage);
            BossBloodEntity.Add(new Image(Game1.BossBloodTImage));
            BossBloodEntity.Position = new Vector2(50.0f, 20.0f);
            Scene1.Instance.Add(BossBloodEntity);
            boss.Add(boss.BossImage);
            boss.BossImage.CenterOrigin();
            boss.Collider = new Circle(80.0f);
            boss.StartShootBulletTimer = Alarm.Create(Alarm.AlarmMode.Oneshot, boss.StartShootBullet, 3.0f, false);
            boss.ShootBulletTimer      = Alarm.Create(Alarm.AlarmMode.Looping, boss.Shoot, 0.3f, true);
            boss.Add(boss.StartShootBulletTimer);
            boss.Add(boss.ShootBulletTimer);
            boss.Add(Alarm.Create(Alarm.AlarmMode.Oneshot, boss.StartSuckBullet, 3.0f, true));
            boss.BulletDepo = new List <Bullet>();
            return(boss);
        }
Exemplo n.º 3
0
 private void doEffect(Action effect)
 {
     if (allowDisable)
     {
         // do the effect only after 0.05s, in case our touch switch gets disabled in the meantime.
         Add(Alarm.Create(Alarm.AlarmMode.Oneshot, effect, 0.05f, true));
     }
     else
     {
         // do the effect right now.
         effect();
     }
 }
Exemplo n.º 4
0
        public static Bomb CreateAt(Vector2 position)
        {
            var bomb = new Bomb();

            bomb.Position  = position;
            bomb.BombImage = new Image(Game1.BombImage);
            bomb.BombImage.CenterOrigin();
            bomb.Add(bomb.BombImage);
            bomb.Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { bomb.Explode(); }, bomb.TimeToExplode, true));
            bomb.Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { bomb.BlinkIndex = 0; bomb.BlinkPeriod = 5; }, bomb.TimeToExplode * 0.7f, true));
            bomb.Collider = new Circle(bomb.ExplodeRadius);
            return(bomb);
        }
Exemplo n.º 5
0
        private static Player Create()
        {
            Player player = new Player();

            player.BulletAlarm = Alarm.Create(Alarm.AlarmMode.Persist, () => { player.Shootable = true; }, 0.1f, false);
            player.Add(player.BulletAlarm);
            player.PlayerFootImage = new Image(Game1.PlayerFootImageArray[0]);
            player.PlayerFootImage.CenterOrigin();
            player.PlayerImage = new Image(Game1.PlayerImage);
            player.PlayerImage.CenterOrigin();
            player.Add(player.PlayerFootImage);
            player.Add(player.PlayerImage);
            player.Collider = new Circle(8.0f);
            player.Position = new Vector2(300.0f, 500.0f);
            return(player);
        }
Exemplo n.º 6
0
 public void Appear()
 {
     Visible = true;
     sprite.Play("appear", false, false);
     Add(Alarm.Create(Alarm.AlarmMode.Oneshot, delegate
     {
         Level level = Scene as Level;
         bool flag   = !CollideCheck <Solid>(Position - Vector2.UnitX);
         if (flag)
         {
             level.Particles.Emit(P_Appear, 16, Position + new Vector2(3f, 16f), new Vector2(2f, 10f), 3.14159274f);
             level.Particles.Emit(P_Appear, 16, Position + new Vector2(29f, 16f), new Vector2(2f, 10f), 0f);
         }
         level.Shake(0.3f);
     }, 0.25f, true));
 }
Exemplo n.º 7
0
        private void Explode()
        {
            RemoveSelf();
            var bangImage = new Image(Game1.BombBangImageArray[0]);
            var bangIndex = 0;

            bangImage.CenterOrigin();
            var bangEntity = new Entity();

            bangEntity.Position = Position;
            bangEntity.Add(bangImage);
            bangEntity.Add(Alarm.Create(Alarm.AlarmMode.Looping, () => { bangIndex++; if (bangIndex >= 10)
                                                                         {
                                                                             bangEntity.RemoveSelf(); return;
                                                                         }
                                                                         bangImage.Texture = Game1.BombBangImageArray[bangIndex]; }, 0.0833f, true));
            Scene1.Instance.Add(bangEntity);
            var deadBulletList = CollideAll(Game1.DeadBulletTag);

            foreach (Bullet bullet in deadBulletList)
            {
                bullet.RemoveSelf();
            }

            var enemyList = CollideAll(Game1.EnemyTag);

            foreach (Enemy enemy in enemyList)
            {
                enemy.Hit(1000, Vector2.Normalize(enemy.Position - Position) * 10.0f);
            }
            if (Boss.Instance != null)
            {
                if (CollideCheck(Boss.Instance))
                {
                    Boss.Instance.Hit(5000);
                }
            }
        }
Exemplo n.º 8
0
 internal void Touch()
 {
     if (!POW)
     {
         HP--;
         if (HP < 0)
         {
             HP = 0;
         }
         Scene1.Instance.PlayerHPImage.Texture = Game1.PlayerHPImageArray[6 - HP];
         if (HP != 0)
         {
             POW = true;
             PlayerFootImage.Color = Color.Red;
             PlayerImage.Color     = Color.Red;
             Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { POW = false; PlayerFootImage.Color = Color.White; PlayerImage.Color = Color.White; }, 1.0f, true));
         }
         else
         {
             Dead();
         }
     }
 }
Exemplo n.º 9
0
        public override void Begin()
        {
            Instance = this;
            base.Begin();

            Renderer renderer = new EverythingRenderer();
            var      wave     = 1;

            EnemyTimer = Alarm.Create(Alarm.AlarmMode.Persist, () => { GenerateEnemy(wave); wave++; }, 3.0f, false);
            var colorTimer = Alarm.Create(Alarm.AlarmMode.Looping, null, 60, true);

            colorTimer.OnComplete = () => {
                var bulletList = GetEntitiesByTagMask(Game1.DeadBulletTag);
                foreach (Bullet bullet in bulletList)
                {
                    var oldColor = bullet.BulletImage.Color.ToVector3();
                    if (MathHelper.Max(oldColor.X, MathHelper.Max(oldColor.Y, oldColor.Z)) > 0.5f)
                    {
                        var newColor         = oldColor * 0.8f;
                        var progress         = 0.0f;
                        var bulletColorTimer = Alarm.Create(Alarm.AlarmMode.Looping, null, 0.01f, true);
                        bulletColorTimer.OnComplete = () => {
                            if (progress >= 1.0f)
                            {
                                bulletColorTimer.RemoveSelf();
                            }
                            bullet.BulletImage.Color = new Color(Vector3.Lerp(oldColor, newColor, progress));
                            progress += 0.01f;
                        };
                        bullet.Add(bulletColorTimer);
                    }
                }
            };
            Add(new Entity()
            {
                colorTimer
            });

            PlayerHPImage               = new Image(Game1.PlayerHPImageArray[0]);
            PlayerHPImage.Position      = new Vector2(50.0f, 80.0f);
            PlayerBombNumImage          = new Image(Game1.BombNumImageArray[0]);
            PlayerBombNumImage.Position = new Vector2(400.0f, 80.0f);

            Add(renderer);
            Add(new Entity()
            {
                new Image(Game1.BGImage)
            });
            Add(new Entity()
            {
                PlayerHPImage
            });
            Add(new Entity()
            {
                PlayerBombNumImage
            });
            Add(Player.Instance);
            Add(Cursor.Instance);
            Player.Instance.Add(EnemyTimer);

            GenerateEnemy();
        }
Exemplo n.º 10
0
        private IEnumerator Cutscene(Level level)
        {
            if (answer)
            {
                ringtone.Position         = payphone.Position;
                player.StateMachine.State = 11;
                player.Dashes             = 1;
                yield return(0.3f);

                ringtone.Play("event:/game/02_old_site/sequence_phone_ring_loop");
                yield return(1.2f);

                if (player.X < payphone.X - 24f || player.X > payphone.X - 4f)
                {
                    yield return(player.DummyWalkTo(payphone.X - 24f));
                }

                yield return(1.5f);

                player.Facing = Facings.Left;
                yield return(1.5f);

                player.Facing = Facings.Right;
                yield return(0.25f);

                yield return(player.DummyWalkTo(payphone.X - 4f));

                yield return(1.5f);

                Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => ringtone.Param("end", 1f), 0.43f, true));
                player.Visible = false;
                Audio.Play("event:/game/02_old_site/sequence_phone_pickup", player.Position);
                yield return(payphone.Sprite.PlayRoutine("pickUp"));

                yield return(1f);
            }
            else
            {
                player.StateMachine.State = 11;
                player.Dashes             = 1;
                yield return(0.3f);

                if (player.X < payphone.X - 24f || player.X > payphone.X - 4f)
                {
                    yield return(player.DummyWalkTo(payphone.X - 24f));
                }

                yield return(1.5f);

                player.Facing = Facings.Left;
                yield return(1.5f);

                player.Facing = Facings.Right;
                yield return(0.25f);

                yield return(player.DummyWalkTo(payphone.X - 4f));

                yield return(0.2f);

                yield return(0.5f);

                player.Visible = false;
                Audio.Play("event:/game/02_old_site/sequence_phone_pickup", player.Position);
                yield return(payphone.Sprite.PlayRoutine("pickUp"));

                yield return(0.25f);

                phoneSfx.Position = player.Position;
                phoneSfx.Play("event:/game/02_old_site/sequence_phone_ringtone_loop");
                yield return(6f);

                phoneSfx.Stop();
            }

            payphone.Sprite.Play("talkPhone");
            yield return(Textbox.Say(dialogEntry));

            yield return(0.3f);

            payphone.Sprite.Visible = false;
            sprite.Visible          = true;
            Audio.Play("event:/game/02_old_site/sequence_phone_pickup", player.Position);
            Position = payphone.Position;
            yield return(sprite.PlayRoutine("putdown"));

            EndCutscene(level);
        }
Exemplo n.º 11
0
        public static Enemy Create(int type = 0)
        {
            var   enemy        = new Enemy();
            float colliderSize = 8.0f;

            enemy.Collider  = new Circle(colliderSize);
            enemy.SlimeType = type;
            if (type == 0)
            {
                //Green
                enemy.AnimTex  = Game1.SlimeWalkImageArray;
                enemy.HP       = 100;
                enemy.JamColor = new Color(55, 148, 110);
                enemy.JamSize  = 1.0f;
                enemy.Collider = new Circle(colliderSize);
            }
            else if (type == 1)
            {
                //Yellow
                enemy.AnimTex  = Game1.SlimeBWalkImageArray;
                enemy.HP       = 200;
                enemy.JamColor = new Color(227, 186, 50);
                enemy.JamSize  = 1.5f;
                enemy.Collider = new Circle(colliderSize * 2.0f);
            }
            else if (type == 2)
            {
                //Purple
                enemy.AnimTex  = Game1.SlimeCWalkImageArray;
                enemy.HP       = 150;
                enemy.JamColor = new Color(179, 70, 139);
                enemy.JamSize  = 2.0f;
                enemy.Collider = new Circle(colliderSize * 2.5f);
            }
            else if (type == 3)
            {
                //Rainbow
                enemy.AnimTex  = Game1.SlimeDWalkImageArray;
                enemy.HP       = 150;
                enemy.JamColor = new Color(227, 186, 50);
                enemy.JamSize  = 2.0f;
                enemy.Collider = new Circle(colliderSize * 2.5f);
            }
            else if (type == 4)
            {
                //Little Purple
                enemy.AnimTex  = Game1.SlimeCCWalkImageArray;
                enemy.HP       = 100;
                enemy.JamColor = new Color(179, 70, 139);
                enemy.JamSize  = 1.0f;
                enemy.Collider = new Circle(colliderSize);
            }
            enemy.EnemyImage = new Image(enemy.AnimTex[0]);
            enemy.EnemyImage.CenterOrigin();
            enemy.Add(enemy.EnemyImage);

            enemy.ShootTimer = Alarm.Create(Alarm.AlarmMode.Looping, enemy.Shoot, 0.1f, false);
            //enemy.Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { enemy.ShootTimer.Start(); }, 3.0f, true));
            enemy.Add(enemy.ShootTimer);
            enemy.Position      = new Vector2(300.0f);
            enemy.ShootVec      = Vector2.UnitX;
            enemy.Tag           = Game1.EnemyTag;
            enemy.WalkAnimIndex = Calc.Random.Range(0, 40);

            return(enemy);
        }
Exemplo n.º 12
0
        public override void Update()
        {
            base.Update();

            var vec   = Vector2.Normalize(Cursor.Instance.Position - Position).EightWayNormal();
            int index = 1;

            if (vec == -Vector2.UnitY)
            {
                index = 7;
            }
            if (vec == Vector2.UnitY)
            {
                index = 3;
            }
            if (vec == -Vector2.UnitX)
            {
                index = 5;
            }
            if (vec == Vector2.UnitX)
            {
                index = 1;
            }
            if (vec.X == vec.Y && vec.X < 0)
            {
                index = 6;
            }
            if (vec.X == vec.Y && vec.X > 0)
            {
                index = 2;
            }
            if (vec.X == -vec.Y && vec.X < 0)
            {
                index = 4;
            }
            if (vec.X == -vec.Y && vec.X > 0)
            {
                index = 8;
            }
            index -= 1;
            PlayerImage.Texture = Game1.PlayerImageArray[index];

            var collideItem = CollideAll(Game1.ItemTag);

            if (collideItem.Count > 0)
            {
                foreach (var item in collideItem)
                {
                    if (BombNum < 3)
                    {
                        BombNum++;
                        item.RemoveSelf();
                    }
                    else
                    {
                        break;
                    }
                }
                Scene1.Instance.PlayerBombNumImage.Texture = Game1.BombNumImageArray[3 - BombNum];
            }

            var collideBullet = CollideAll(Game1.EnemyBulletTag);

            if (collideBullet.Count > 0)
            {
                foreach (Bullet bullet in collideBullet)
                {
                    if (!POW)
                    {
                        HP--;
                        if (HP < 0)
                        {
                            HP = 0;
                        }
                        Scene1.Instance.PlayerHPImage.Texture = Game1.PlayerHPImageArray[6 - HP];
                        if (HP != 0)
                        {
                            POW = true;
                            PlayerFootImage.Color   = Color.Red;
                            PlayerFootImage.Color.A = 64;
                            PlayerImage.Color       = Color.Red;
                            PlayerImage.Color.A     = 64;
                            Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => { POW = false; PlayerFootImage.Color = Color.White; PlayerImage.Color = Color.White; }, 1.0f, true));
                        }
                    }
                    bullet.RemoveSelf();
                }
                if (HP <= 0)
                {
                    Dead();
                }
                return;
            }

            var move = new Vector2(0.0f);

            if (MInput.Keyboard.Check(Keys.W))
            {
                move.Y -= 1.0f;
            }
            if (MInput.Keyboard.Check(Keys.A))
            {
                move.X -= 1.0f;
            }
            if (MInput.Keyboard.Check(Keys.S))
            {
                move.Y += 1.0f;
            }
            if (MInput.Keyboard.Check(Keys.D))
            {
                move.X += 1.0f;
            }
            move.Normalize();
            if (float.IsNaN(move.Length()))
            {
                move = Vector2.Zero;
            }
            Player.Instance.Move(move);

            if (MInput.Mouse.CheckLeftButton)
            {
                Player.Instance.Shoot();
            }
            if (MInput.Mouse.PressedRightButton)
            {
                Player.Instance.PlaceBomb();
            }
            Depth = (int)-Position.Y;
        }
Exemplo n.º 13
0
 public CustomArrow() : base()
 {
     explodeAlarm = Alarm.Create(Alarm.AlarmMode.Persist, new Action(Explode), 50, false);
 }
        private IEnumerator BoostRoutine(Player player)
        {
            holding    = player;
            travelling = true;
            ++nodeIndex;
            sprite.Visible  = false;
            sprite.Position = Vector2.Zero;
            Collidable      = false;
            var       finalBoost = nodeIndex >= nodes.Length;
            Level     level      = SceneAs <Level>();
            Stopwatch sw         = new Stopwatch();

            sw.Start();
            if (!finalBoost)
            {
                Audio.Play("event:/char/badeline/booster_begin", Position);
            }
            else
            {
                Audio.Play("event:/char/badeline/booster_final", Position);
            }

            if (player.Holding != null)
            {
                player.Drop();
            }

            player.StateMachine.State = 11;
            player.DummyAutoAnimate   = false;
            player.DummyGravity       = false;
            if (player.Inventory.Dashes > 1)
            {
                player.Dashes = 1;
            }
            else
            {
                player.RefillDash();
            }

            player.RefillStamina();
            player.Speed = Vector2.Zero;
            var side = Math.Sign(player.X - X);

            if (side == 0)
            {
                side = -1;
            }

            BadelineDummy badeline = new BadelineDummy(Position);

            Scene.Add(badeline);
            if (side == -1)
            {
                player.Facing = Facings.Right;
            }
            else
            {
                player.Facing = Facings.Left;
            }

            badeline.Sprite.Scale.X = side;
            Vector2 playerFrom   = player.Position;
            Vector2 playerTo     = Position + new Vector2(side * 4, -3f);
            Vector2 badelineFrom = badeline.Position;
            Vector2 badelineTo   = Position + new Vector2(-side * 4, 3f);

            for (var p = 0.0f; (double)p < 1.0; p += Engine.DeltaTime / 0.2f)
            {
                Vector2 target = Vector2.Lerp(playerFrom, playerTo, p);
                if (player.Scene != null)
                {
                    player.MoveToX(target.X);
                }

                if (player.Scene != null)
                {
                    player.MoveToY(target.Y);
                }

                badeline.Position = Vector2.Lerp(badelineFrom, badelineTo, p);
                yield return(null);
            }

            if (finalBoost)
            {
                Vector2 center = new Vector2(Calc.Clamp(player.X - level.Camera.X, 120f, 200f),
                                             Calc.Clamp(player.Y - level.Camera.Y, 60f, 120f));
                Add(new Coroutine(level.ZoomTo(center, 1.5f, 0.18f)));
                Engine.TimeRate = 0.5f;
            }
            else
            {
                Audio.Play("event:/char/badeline/booster_throw", Position);
            }

            badeline.Sprite.Play("boost");
            yield return(0.1f);

            if (!player.Dead)
            {
                player.MoveV(5f);
            }

            yield return(0.1f);

            Add(Alarm.Create(Alarm.AlarmMode.Oneshot, () => {
                if (player.Dashes < player.Inventory.Dashes)
                {
                    ++player.Dashes;
                }

                Scene.Remove(badeline);
                (Scene as Level)?.Displacement.AddBurst(badeline.Position, 0.25f, 8f, 32f, 0.5f);
            }, 0.15f, true));
            (Scene as Level)?.Shake();
            holding = null;
            if (!finalBoost)
            {
                player.BadelineBoostLaunch(CenterX);
                Vector2 from = Position;
                Vector2 to   = nodes[nodeIndex];
                var     time = Vector2.Distance(from, to) / MoveSpeed;
                time             = Math.Min(3f, time);
                stretch.Visible  = true;
                stretch.Rotation = (to - from).Angle();
                Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.SineInOut, time, true);
                tween.OnUpdate = t => {
                    Position        = Vector2.Lerp(from, to, t.Eased);
                    stretch.Scale.X = (float)(1.0 + Calc.YoYo(t.Eased) * 2.0);
                    stretch.Scale.Y = (float)(1.0 - Calc.YoYo(t.Eased) * 0.75);
                    if (t.Eased >= 0.899999976158142 || !Scene.OnInterval(0.03f))
                    {
                        return;
                    }

                    TrailManager.Add(this, Player.TwoDashesHairColor, 0.5f, false);
                    level.ParticlesFG.Emit(BadelineBoost.P_Move, 1, Center, Vector2.One * 4f);
                };
                tween.OnComplete = t => {
                    if (level != null && X >= (double)level.Bounds.Right)
                    {
                        RemoveSelf();
                    }
                    else
                    {
                        travelling      = false;
                        stretch.Visible = false;
                        sprite.Visible  = true;
                        Collidable      = true;
                        Audio.Play("event:/char/badeline/booster_reappear", Position);
                    }
                };
                Add(tween);
                relocateSfx.Play("event:/char/badeline/booster_relocate");
                Input.Rumble(RumbleStrength.Strong, RumbleLength.Medium);
                level.DirectionalShake(-Vector2.UnitY);
                level.Displacement.AddBurst(Center, 0.4f, 8f, 32f, 0.5f);
            }
            else
            {
                Console.WriteLine("TIME: " + sw.ElapsedMilliseconds);
                Engine.FreezeTimer = 0.1f;
                yield return(null);

                Input.Rumble(RumbleStrength.Strong, RumbleLength.Long);
                level.Flash(Color.White * 0.5f, true);
                level.DirectionalShake(Vector2.UnitY, 0.6f);
                level.Displacement.AddBurst(Center, 0.6f, 8f, 64f, 0.5f);
                level.ResetZoom();
                player.StateMachine.State = 18;
                Engine.TimeRate           = 1f;
                Finish();
            }
        }