示例#1
0
        private static bool OnLoadEntity(Level level, LevelData levelData, Vector2 offset, EntityData entityData)
        {
            switch (entityData.Name)
            {
            case "FrostHelper/KeyIce":
                level.Add(new KeyIce(entityData, offset, new EntityID(levelData.Name, entityData.ID), entityData.NodesOffset(offset)));
                return(true);

            /*
             * case "FrostHelper/SpringLeft":
             * level.Add(new CustomSpring(entityData, offset, Spring.Orientations.WallLeft));
             * return true;
             * case "FrostHelper/SpringRight":
             * level.Add(new CustomSpring(entityData, offset, Spring.Orientations.WallRight));
             * return true;
             * case "FrostHelper/SpringFloor":
             * level.Add(new CustomSpring(entityData, offset, Spring.Orientations.Floor));
             * return true;*/
            case "FrostHelper/CustomDreamBlock":
                if (entityData.Bool("old", false))
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    level.Add(new CustomDreamBlock(entityData, offset));
#pragma warning restore CS0618 // Type or member is obsolete
                }
                else
                {
                    level.Add(new CustomDreamBlockV2(entityData, offset));
                }
                return(true);

            default:
                return(false);
            }
        }
示例#2
0
        public void Step(Level level)
        {
            if (Settings.Mode == GhostModuleMode.Off)
            {
                return;
            }

            string target = level.Session.Level;

            Logger.Log("ghost", $"Stepping into {level.Session.Area.GetSID()} {target}");

            Player player = level.Tracker.GetEntity <Player>();

            // Write the ghost, even if we haven't gotten an IL PB.
            // Maybe we left the level prematurely earlier?
            if (GhostRecorder?.Data != null &&
                (Settings.Mode & GhostModuleMode.Record) == GhostModuleMode.Record)
            {
                GhostRecorder.Data.Target = target;
                GhostRecorder.Data.Run    = Run;
                GhostRecorder.Data.Write();
            }

            GhostManager?.RemoveSelf();

            level.Add(GhostManager = new GhostManager(player, level));

            if (GhostRecorder != null)
            {
                GhostRecorder.RemoveSelf();
            }
            level.Add(GhostRecorder = new GhostRecorder(player));
            GhostRecorder.Data      = new GhostData(level.Session);
            GhostRecorder.Data.Name = Settings.Name;
        }
示例#3
0
        private void Harvest(Level level, int x, int y)
        {
            int age = level.GetData(x, y);

            int count = Random.NextInt(2);

            for (int i = 0; i < count; i++)
            {
                level.Add(new ItemEntity(new ResourceItem(Resource.Seeds), x * 16 + Random.NextInt(10) + 3, y * 16 + Random.NextInt(10) + 3));
            }

            count = 0;
            if (age == 50)
            {
                count = Random.NextInt(3) + 2;
            }
            else if (age >= 40)
            {
                count = Random.NextInt(2) + 1;
            }
            for (int i = 0; i < count; i++)
            {
                level.Add(new ItemEntity(new ResourceItem(Resource.Wheat), x * 16 + Random.NextInt(10) + 3, y * 16 + Random.NextInt(10) + 3));
            }

            level.SetTile(x, y, Dirt, 0);
        }
示例#4
0
    void Update()
    {
        if (reloadField)
        {
            if (!reload.Ready)
            {
                if (reload.Time)
                {
                    int r = reload.Row;

                    for (int i = 0; i < parameters.width; i++)
                    {
                        if (reload.Dir == -1)
                        {
                            level.Add(new Key2D(i, r));
                        }
                        else
                        {
                            level.Remove(new Key2D(i, r));
                        }
                    }
                }
            }
            else
            {
                reloadField               = false;
                Game.instance.gameState   = Game.GameState.game;
                Game.instance.initNewGame = false;
                InitLevel();
            }
        }
    }
示例#5
0
        // Called from LoadLevel, patched via MonoModRules.PatchLevelLoader
        public static bool LoadCustomEntity(EntityData entityData, Level level)
        {
            LevelData levelData = level.Session.LevelData;
            Vector2   offset    = new Vector2(levelData.Bounds.Left, levelData.Bounds.Top);

            // Everest comes with a few core utility entities out of the box.
            if (entityData.Name == "levelFlagTrigger")
            {
                level.Add(new LevelFlagTrigger(entityData, offset));
                return(true);
            }

            if (entityData.Name == "customCoreMessage")
            {
                level.Add(new CustomCoreMessage(entityData, offset));
                return(true);
            }

            if (entityData.Name == "customMemorial")
            {
                level.Add(new CustomMemorial(entityData, offset));
                return(true);
            }

            return(Everest.Events.Level.LoadEntity(level, levelData, offset, entityData));
        }
        public void Hurt(Level level, int x, int y, int dmg)
        {
            int damage = level.GetData(x, y) + dmg;

            level.Add(new SmashParticle(x * 16 + 8, y * 16 + 8));
            level.Add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, Color.Get(-1, 500, 500, 500)));
            if (damage >= 200)
            {
                int count = Random.NextInt(4) + 1;
                for (int i = 0; i < count; i++)
                {
                    level.Add(new ItemEntity(new ResourceItem(Resource.Stone), x * 16 + Random.NextInt(10) + 3, y * 16 + Random.NextInt(10) + 3));
                }
                count = Random.NextInt(2);
                for (int i = 0; i < count; i++)
                {
                    level.Add(new ItemEntity(new ResourceItem(Resource.Coal), x * 16 + Random.NextInt(10) + 3, y * 16 + Random.NextInt(10) + 3));
                }
                level.SetTile(x, y, Dirt, 0);
            }
            else
            {
                level.SetData(x, y, damage);
            }
        }
        private bool LevelOnLoadEntity(Level level, LevelData levelData, Vector2 offset, EntityData entityData)
        {
            if (entityData.Name.StartsWith("AdventureHelper"))
            {
                switch (entityData.Name)
                {
                case "AdventureHelper/BladeTrackSpinnerMultinode":
                    level.Add(new BladeTrackSpinnerMultinode(entityData, offset));
                    return(true);

                case "AdventureHelper/DustTrackSpinnerMultinode":
                    level.Add(new DustTrackSpinnerMultinode(entityData, offset));
                    return(true);

                case "AdventureHelper/ZipMoverNoReturn":
                    level.Add(new ZipMoverNoReturn(entityData, offset));
                    return(true);

                case "AdventureHelper/LinkedZipMover":
                    level.Add(new LinkedZipMover(entityData, offset));
                    return(true);

                case "AdventureHelper/LinkedZipMoverNoReturn":
                    level.Add(new LinkedZipMoverNoReturn(entityData, offset));
                    return(true);

                default:
                    return(false);
                }
            }
            return(false);
        }
示例#8
0
    private void PopulateLevel()
    {
        for (var i = 0; i < 8; i++)
        {
            var x = -1;
            var y = -1;
            while (_level.GetTile(x, y).BumpEffect != TileBumpEffect.None ||
                   _level.GetItem(x, y) != null)
            {
                x = Globals.Random.Next(_level.Width);
                y = Globals.Random.Next(_level.Height);
            }
            _level.Add(_level.Catalog.NewItem(x, y));
        }

        for (var i = 0; i < 28 + _level.Depth * 4; i++)
        {
            var x = -1;
            var y = -1;
            while (_level.GetTile(x, y).BumpEffect != TileBumpEffect.None ||
                   _level.GetAgent(x, y) != null)
            {
                x = Globals.Random.Next(_level.Width);
                y = Globals.Random.Next(_level.Height);
            }
            _level.Add(_level.Catalog.NewEnemy(x, y));
        }
    }
        private IEnumerator GameEndRoutine()
        {
            if (level.Wipe != null)
            {
                Action onComplete = level.Wipe.OnComplete;
                level.Wipe.OnComplete = delegate {
                    level.Add(new PersistentMiniTextbox(GetWinnerText(winnerID), FancyText.Anchors.Middle));
                    onComplete?.Invoke();
                };
            }
            else
            {
                level.Add(new PersistentMiniTextbox(GetWinnerText(winnerID), FancyText.Anchors.Middle));
            }

            yield return(10f);

            level.OnEndOfFrame += delegate {
                Player player = level.Tracker.GetEntity <Player>();
                Leader.StoreStrawberries(player.Leader);
                level.Remove(player);
                level.UnloadLevel();

                level.Session.Level        = MadelinePartyModule.START_ROOM;
                level.Session.RespawnPoint = level.GetSpawnPoint(new Vector2(level.Bounds.Left, level.Bounds.Top));

                level.LoadLevel(Player.IntroTypes.None);

                Leader.RestoreStrawberries(player.Leader);
            };
        }
示例#10
0
        public static void InstantTeleport(Scene scene, Player player, string room, bool sameRelativePosition, float positionX, float positionY)
        {
            Level level = scene as Level;

            if (level == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(room))
            {
                Vector2 playerRelativeOffset = (new Vector2(positionX, positionY) - player.Position);

                player.Position        = new Vector2(positionX, positionY);
                level.Camera.Position += playerRelativeOffset;
                player.Hair.MoveHairBy(playerRelativeOffset);
            }
            else
            {
                level.OnEndOfFrame += delegate
                {
                    Vector2 levelOffset  = level.LevelOffset;
                    Vector2 playerOffset = player.Position - level.LevelOffset;
                    Vector2 cameraOffset = level.Camera.Position - level.LevelOffset;
                    Facings facing       = player.Facing;

                    level.Remove(player);
                    level.UnloadLevel();
                    level.Session.Level        = room;
                    level.Session.RespawnPoint = level.GetSpawnPoint(new Vector2(level.Bounds.Left, level.Bounds.Top));
                    level.Session.FirstLevel   = false;
                    level.LoadLevel(Player.IntroTypes.Transition);

                    if (sameRelativePosition)
                    {
                        level.Camera.Position = level.LevelOffset + cameraOffset;
                        level.Add(player);
                        player.Position = level.LevelOffset + playerOffset;
                        player.Facing   = facing;
                        player.Hair.MoveHairBy(level.LevelOffset - levelOffset);
                    }
                    else
                    {
                        Vector2 playerRelativeOffset = (new Vector2(positionX, positionY) - level.LevelOffset - playerOffset);

                        level.Camera.Position = level.LevelOffset + cameraOffset + playerRelativeOffset;
                        level.Add(player);
                        player.Position = new Vector2(positionX, positionY);
                        player.Facing   = facing;
                        player.Hair.MoveHairBy(level.LevelOffset - levelOffset + playerRelativeOffset);
                    }

                    if (level.Wipe != null)
                    {
                        level.Wipe.Cancel();
                    }
                };
            }
        }
示例#11
0
        private void CheckButton(Level level)
        {
            if (!SpeedrunToolModule.Enabled)
            {
                return;
            }

            if (Mappings.Save.Pressed())
            {
                Mappings.Save.ConsumePress();
                SaveState(false);
            }
            else if (Mappings.Load.Pressed() && !level.PausedNew() && State == States.None)
            {
                Mappings.Load.ConsumePress();
                if (IsSaved)
                {
                    LoadState(false);
                }
                else if (!level.Frozen)
                {
                    level.Add(new MiniTextbox(DialogIds.DialogNotSaved).IgnoreSaveLoad());
                }
            }
            else if (Mappings.Clear.Pressed() && !level.PausedNew() && State == States.None)
            {
                Mappings.Clear.ConsumePress();
                ClearState(true);
                if (IsNotCollectingHeart(level) && !level.Completed)
                {
                    level.Add(new MiniTextbox(DialogIds.DialogClear).IgnoreSaveLoad());
                }
            }
            else if (Mappings.SwitchAutoLoadState.Pressed() && !level.PausedNew())
            {
                Mappings.SwitchAutoLoadState.ConsumePress();
                Settings.AutoLoadAfterDeath = !Settings.AutoLoadAfterDeath;
                SpeedrunToolModule.Instance.SaveSettings();
            }
            else if (State == States.Waiting && !level.PausedNew() &&
                     (Input.Dash.Pressed ||
                      Input.Grab.Check ||
                      Input.Jump.Check ||
                      Input.Pause.Check ||
                      Input.Talk.Check ||
                      Input.MoveX != 0 ||
                      Input.MoveY != 0 ||
                      Input.Aim.Value != Vector2.Zero ||
                      GetVirtualButton(Mappings.Load).Released ||
                      typeof(Input).GetFieldValue("DemoDash")?.GetPropertyValue("Pressed") as bool? == true ||
                      typeof(Input).GetFieldValue("CrouchDash")?.GetPropertyValue("Pressed") as bool? == true
                     ))
            {
                LoadStateComplete(level);
            }
        }
示例#12
0
 public void OnConnect()
 {
     if (!Settings.IsReconnecting)
     {
         Audio.Play(SFX.ui_main_message_confirm);
         if (currentLevel != null)
         {
             currentMiniTextBox = new MiniTextbox(DialogIds.TextBoxConnected);
             currentLevel.Add(currentMiniTextBox);
         }
     }
 }
        /// <summary>
        ///     Method getting called on the Oui instance when the method just above is called.
        /// </summary>
        ///
        private TextMenuButtonExt buildOpenMenuButton(TextMenu parentMenu, bool inGame)
        {
            if (inGame)
            {
                // this is how it works in-game
                return((TextMenuButtonExt) new TextMenuButtonExt(getButtonName()).Pressed(() => {
                    Level level = Engine.Scene as Level;
                    // close the parent menu
                    parentMenu.RemoveSelf();

                    // create our menu and prepare it
                    TextMenu thisMenu = buildMenu(true);

                    // notify the pause menu that we aren't in the main menu anymore (hides the strawberry tracker)
                    bool comesFromPauseMainMenu = level.PauseMainMenuOpen;
                    level.PauseMainMenuOpen = false;

                    thisMenu.OnESC = thisMenu.OnCancel = () => {
                        // close this menu
                        Audio.Play(SFX.ui_main_button_back);

                        StrawberryToolModule.Instance.SaveSettings();
                        thisMenu.Close();

                        // and open the parent menu back (this should work, right? we only removed it from the scene earlier, but it still exists and is intact)
                        // "what could possibly go wrong?" ~ famous last words
                        level.Add(parentMenu);

                        // restore the pause "main menu" flag to make strawberry tracker appear again if required.
                        level.PauseMainMenuOpen = comesFromPauseMainMenu;
                    };

                    thisMenu.OnPause = () => {
                        // we're unpausing, so close that menu, and save the mod Settings because the Mod Options menu won't do that for us
                        Audio.Play(SFX.ui_main_button_back);

                        StrawberryToolModule.Instance.SaveSettings();
                        thisMenu.Close();

                        level.Paused = false;
                        Engine.FreezeTimer = 0.15f;
                    };

                    // finally, add the menu to the scene
                    level.Add(thisMenu);
                }));
            }

            // this is how it works in the main menu: way more simply than the in-game mess.
            return((TextMenuButtonExt) new TextMenuButtonExt(getButtonName()).Pressed(() => {
                gotoMenu(OuiModOptions.Instance.Overworld);
            }));
        }
示例#14
0
        public void Step(Level level)
        {
            if (!Settings.Enabled)
            {
                return;
            }

            string target = level.Session.Level;

            Logger.Log("ghost", $"Stepping into {level.Session.Area.GetSID()} {target}");

            Player player = level.Tracker.GetEntity <Player>();

            // Write the ghost, even if we haven't gotten an IL PB.
            // Maybe we left the level prematurely earlier?
            if (GhostRecorder?.Data != null)
            {
                GhostRecorder.Data.Target = target;
                GhostRecorder.Data.Write();
            }

            // Remove any dead ghosts (heh)
            for (int i = Ghosts.Count - 1; i > -1; --i)
            {
                Ghost ghost = Ghosts[i];
                if (ghost.Player != player)
                {
                    ghost.RemoveSelf();
                }
            }
            Ghosts.Clear();

            // Read and add all ghosts.
            GhostData.ForAllGhosts(level.Session, (i, ghostData) => {
                Ghost ghost = new Ghost(player, ghostData);
                level.Add(ghost);
                Ghosts.Add(ghost);
                return(true);
            });

            if (GhostRecorder != null)
            {
                GhostRecorder.RemoveSelf();
            }
            level.Add(GhostRecorder = new GhostRecorder(player));
            GhostRecorder.Data      = new GhostData(level.Session);
            GhostRecorder.Data.Name = Settings.Name;
        }
示例#15
0
        protected override void CreateExplosion(Vec2 pos)
        {
            float x = pos.x;
            float y = pos.y - 2f;

            Level.Add(new Frog(x, y, Rando.Double() < 0.5f));

            int amount = Rando.Int(2, 4);

            for (int i = 0; i < amount; i++)
            {
                float deg = (float)i * 360f / amount + Rando.Float(-10f, 10f);
                float rad = Maths.DegToRad(deg);

                float xDir = (float)Math.Cos(rad);
                float yDir = (float)Math.Sin(rad);

                Frog thing = new Frog(x, y, xDir > 0);
                thing.hSpeed = xDir * 3;
                thing.vSpeed = yDir * yDir * -3 - 2;

                Level.Add(thing);
            }

            for (int i = 0; i < 3; i++)
            {
                Level.Add(SmallSmoke.New(x + Rando.Float(-8f, 8f), y + Rando.Float(-8f, 8f)));
            }
        }
示例#16
0
        public void Blast(BlastHitDir hitDir)
        {
            if (blasted || !isServerForObject)
            {
                return;
            }
#if !DEBUG
            const
#endif
            float bulletSpeed = 3f;
#if !DEBUG
            const
#endif
            float speedVariation = 1f;
#if !DEBUG
            const
#endif
            float accuracy = 0.9f;

            float baseDeg = hitDir switch
            {
                BlastHitDir.HitLeft => 0,
                BlastHitDir.HitTop => 90,
                BlastHitDir.HitRight => 180,
                BlastHitDir.HitBottom => 270,
                BlastHitDir.Random360 => 0,
                _ => throw new Exception(),
            };
            for (int i = 0; i < 10; i++)
            {
                PermafrostLance_ThingBulletChargedSmall b = new(position, GetBulletVecDeg(baseDeg, bulletSpeed, speedVariation, hitDir == BlastHitDir.Random360 ? 0 : accuracy), BulletSafeDuck);
                Level.Add(b);
                Level.Remove(this);
            }
        }
示例#17
0
 public override void ExitHit(Bullet bullet, Vec2 exitPos)
 {
     for (int index = 0; (double)index < 1.0 + (double)this.damageMultiplier / 2.0; ++index)
     {
         Level.Add((Thing) new GlassParticle(exitPos.x, exitPos.y, -bullet.travelDirNormalized));
     }
 }
示例#18
0
 public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
     if ((double)this._hitPoints <= 0.0)
     {
         return(false);
     }
     if (bullet.isLocal && this.owner == null)
     {
         Thing.Fondle((Thing)this, DuckNetwork.localConnection);
     }
     for (int index = 0; (double)index < 1.0 + (double)this.damageMultiplier / 2.0; ++index)
     {
         Level.Add((Thing) new GlassParticle(hitPos.x, hitPos.y, bullet.travelDirNormalized));
     }
     SFX.Play("woodHit");
     if (bullet.isLocal)
     {
         this._hitPoints       -= this.damageMultiplier;
         this.damageMultiplier += 2f;
         if (TeamSelect2.Enabled("EXPLODEYCRATES"))
         {
             if (this.duck != null)
             {
                 this.duck.ThrowItem();
             }
             this.Destroy((DestroyType) new DTShot(bullet));
             Level.Add((Thing) new GrenadeExplosion(this.x, this.y));
         }
         if ((double)this._hitPoints <= 0.0)
         {
             this.Destroy((DestroyType) new DTShot(bullet));
         }
     }
     return(base.Hit(bullet, hitPos));
 }
示例#19
0
        public void CreateExplosion(Vec2 pos)
        {
            if (this._explosionCreated)
            {
                return;
            }
            float x    = pos.x;
            float ypos = pos.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            this._explosionCreated = true;
            SFX.Play("explode");
        }
示例#20
0
 public override void OnPressAction()
 {
     if (this.ammo > 0)
     {
         --this.ammo;
         SFX.Play("netGunFire");
         this._barrelSteam.speed = 1f;
         this._barrelSteam.frame = 0;
         this.ApplyKick();
         Vec2 vec2 = this.Offset(this.barrelOffset);
         if (this.receivingPress)
         {
             return;
         }
         Net net = new Net(vec2.x, vec2.y - 2f, this.duck);
         Level.Add((Thing)net);
         this.Fondle((Thing)net);
         if (this.owner != null)
         {
             net.responsibleProfile = this.owner.responsibleProfile;
         }
         net.clip.Add(this.owner as MaterialThing);
         net.hSpeed = this.barrelVector.x * 10f;
         net.vSpeed = (float)((double)this.barrelVector.y * 7.0 - 1.5);
     }
     else
     {
         this.DoAmmoClick();
     }
 }
示例#21
0
 public override void Update()
 {
     this.timer -= 0.01f;
     if (timer <= 0 && !exploded)
     {
         exploded = true;
         float num1 = this.y - 2f;
         for (int index = 0; index < 20; ++index)
         {
             float      num2       = (float)((double)index * 18.0 - 5.0) + Rando.Float(10f);
             ATShrapnel atShrapnel = new ATShrapnel();
             atShrapnel.range = 60f + Rando.Float(18f);
             Bullet bullet = new Bullet(x + (float)(Math.Cos((double)Maths.DegToRad(num2)) * 6.0), num1 - (float)(Math.Sin((double)Maths.DegToRad(num2)) * 6.0), (AmmoType)atShrapnel, num2, (Thing)null, false, -1f, false, true);
             bullet.firedFrom = (Thing)this;
             Level.Add((Thing)bullet);
         }
         foreach (Window window in Level.CheckCircleAll <Window>(this.position, 40f))
         {
             if (Level.CheckLine <Block>(this.position, window.position, (Thing)window) == null)
             {
                 window.Destroy((DestroyType) new DTImpact((Thing)this));
             }
         }
     }
     if (exploded)
     {
         Level.Remove(this);
         Level.Remove(detonator);
     }
     if (this.owner as Duck != null)
     {
         var duck = (Duck)this.owner;
     }
     base.Update();
 }
示例#22
0
        protected override void Die()
        {
            base.Die();

            int count = Random.Next(3) + 1;

            for (int i = 0; i < count; i++)
            {
                Level.Add(new ItemEntity(new ResourceItem(Resource.Cloth), X + Random.NextInt(11) - 5,
                                         Y + Random.NextInt(11) - 5));
            }

            if (_isBossMob)
            {
                count = Random.Next(3);
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        Level.Add(new ItemEntity(new ResourceItem(Resource.Gem), X + Random.NextInt(11) - 5,
                                                 Y + Random.NextInt(11) - 5));
                    }
                }
            }

            if (Level.Player != null)
            {
                Level.Player.Score += 50 * _lvl;
            }
        }
示例#23
0
 // Token: 0x06002238 RID: 8760
 public override void OnReleaseAction()
 {
     if (this._chargeAnim.currentAnimation == "charge")
     {
         if (this._chargeAnim.frame > 20)
         {
             this._unchargeSound.Volume = 1f;
             this._unchargeSound.Play();
         }
         else
         {
             this._unchargeSoundShort.Volume = 1f;
             this._unchargeSoundShort.Play();
         }
         int index = this._chargeAnim.frame;
         this._chargeAnim.SetAnimation("uncharge");
         this._chargeAnim.frame = 22 - index;
         this._chargeSound.Stop();
         this._chargeSound.Volume = 0f;
         this._chargeSoundShort.Stop();
         this._chargeSoundShort.Volume = 0f;
     }
     if (this._chargeAnim.currentAnimation == "charged")
     {
         Graphics.FlashScreen();
         this._chargeAnim.SetAnimation("drain");
         SFX.Play("laserBlast", 1f, 0f, 0f, false);
         for (int i = 0; i < 4; i++)
         {
             Level.Add(new ElectricalCharge(base.barrelPosition.x, base.barrelPosition.y, (int)this.offDir, this));
         }
     }
 }
示例#24
0
 public override void Update()
 {
     base.Update();
     if (!this.destroyed && !this._stuck)
     {
         if (!this.burning && Level.CheckCircle <SmallFire>(this.position, 8f) != null)
         {
             this.burning = true;
             this.onFire  = true;
             Level.Add((Thing)SmallFire.New(0.0f, 0.0f, 0.0f, 0.0f, stick: ((MaterialThing)this), firedFrom: ((Thing)this)));
             SFX.Play("ignite", Rando.Float(0.9f, 1f), Rando.Float(-0.2f, 0.2f));
         }
         this._sprite.frame = 0;
         this.angleDegrees  = -Maths.PointDirection(Vec2.Zero, new Vec2(this.hSpeed, this.vSpeed));
     }
     if (this._stuck)
     {
         this.vSpeed         = 0.0f;
         this.hSpeed         = 0.0f;
         this.grounded       = true;
         this._sprite.frame  = 1;
         this._stickTime    -= 0.01f;
         this.gravMultiplier = 0.0f;
     }
     if ((double)this._stickTime > 0.0 || this.destroyed)
     {
         return;
     }
     this.Destroy((DestroyType) new DTFade());
 }
        public override void PopShell(float x, float y, int dir)
        {
            PistolShell pistolShell = new PistolShell(x, y);

            pistolShell.hSpeed = (float)dir * (1.5f + Rando.Float(1f));
            Level.Add((Thing)pistolShell);
        }
示例#26
0
        public override bool Hit(Bullet bullet, Vec2 hitPos)
        {
            if (_equippedDuck == null || bullet.owner == duck || !bullet.isLocal)
            {
                return(false);
            }

            var particleEnd =
                hitPos
                + (bullet.travelDirNormalized * bullet.bulletSpeed
                   * 3)
                + new Vec2(Rando.Float(-5f, 5f), Rando.Float(-5f, 5f));

            for (int i2 = 0; i2 < 3; i2++)
            {
                Level.Add(DotParticle.New(
                              hitPos.x + Rando.Float(-2f, 2f),
                              hitPos.y + Rando.Float(-2f, 2f),
                              () => particleEnd,
                              bullet.color.Add(new Color(
                                                   (byte)Rando.Int(-15, 15),
                                                   (byte)Rando.Int(-15, 15),
                                                   (byte)Rando.Int(-15, 15)
                                                   )),
                              0.2f));
            }
            SFX.Play("scimiSurge", 0.8f, Rando.Float(-0.2f, 0.2f));
            return(true);
        }
        public override void Activate(DeathCrate c, bool server = true)
        {
            float x    = c.x;
            float ypos = c.y - 2f;

            Level.Add((Thing) new ExplosionPart(x, ypos));
            int num1 = 6;

            if (Graphics.effectsLevel < 2)
            {
                num1 = 3;
            }
            for (int index = 0; index < num1; ++index)
            {
                float deg  = (float)index * 60f + Rando.Float(-10f, 10f);
                float num2 = Rando.Float(12f, 20f);
                Level.Add((Thing) new ExplosionPart(x + (float)Math.Cos((double)Maths.DegToRad(deg)) * num2, ypos - (float)Math.Sin((double)Maths.DegToRad(deg)) * num2));
            }
            if (server)
            {
                for (int index = 0; index < 10; ++index)
                {
                    Mine  mine = new Mine(c.x, c.y);
                    float num2 = (float)index / 9f;
                    mine.hSpeed = (float)((double)num2 * 40.0 - 20.0) * Rando.Float(0.5f, 1f);
                    mine.vSpeed = Rando.Float(-3f, -11f);
                    mine.PressAction();
                    mine.Arm();
                    Level.Add((Thing)mine);
                }
                Level.Remove((Thing)c);
            }
            Graphics.FlashScreen();
            SFX.Play("explode");
        }
示例#28
0
        protected override bool LoadFromDatabase(DataRow row)
        {
            SkillID     = row.Field <int>("skillID");
            Index       = (ESkill)SkillID;
            Name        = row.Field <string>("name");
            Description = row.Field <string>("description");
            Hit         = row.Field <short>("hit");
            Inf         = (ESkillInf)row.Field <int>("inf");
            Inf2        = (ESkillInf2)row.Field <int>("inf2");
            CastCancel  = row.Field <bool>("castCancel");
            CastDefRate = row.Field <int>("castDefRate");
            Nk          = (ESkillNk)row.Field <short>("nk");
            SkillType   = (EBattleFlag)row.Field <short>("type");

            // Load level
            DataTable table = Core.Database.Query("SELECT * FROM dbskill_level WHERE skillID = {0} ORDER BY level ASC", SkillID);

            if (table != null && table.Rows.Count > 0)
            {
                SkillLevel level;
                foreach (DataRow levelRow in table.Rows)
                {
                    level = SkillLevel.Load(levelRow);
                    if (level == null)
                    {
                        ServerConsole.ErrorLine("Failed to load skill level #" + levelRow.Field <int>("skillID") + " lv " + levelRow.Field <int>("level"));
                        continue;
                    }

                    Level.Add(level);
                }
            }

            return(true);
        }
        public override void Initialize()
        {
            Layer.HUD.camera.x   = Page.camOffset;
            this.backgroundColor = new Color(8, 12, 13);
            this._font           = new BitmapFont("biosFont", 8);
            HUD.AddCornerControl(HUDCorner.BottomLeft, "SELECT@SELECT@");
            HUD.AddCornerControl(HUDCorner.BottomRight, "@QUACK@BACK");
            CategoryGrid categoryGrid = new CategoryGrid(12f, 20f, (List <Card>)null, (IPageListener)this);

            Level.Add((Thing)categoryGrid);
            if (this._cards.Count > 4)
            {
                this._cards.Insert(4, (Card) new LevelInfo(false, "Upload Thing"));
            }
            StripInfo infos = new StripInfo(false);

            infos.cards.AddRange((IEnumerable <Card>) this._cards);
            infos.header       = "Your Things";
            infos.cardsVisible = 4;
            categoryGrid.AddStrip(infos);
            categoryGrid.AddStrip(new StripInfo(false)
            {
                cards =
                {
                    (Card) new LevelInfo(false, "Not a thing.")
                },
                header       = "Browse Things",
                cardsVisible = 4
            });
            this._strip = (Thing)categoryGrid;
            base.Initialize();
        }
示例#30
0
 public override void Update()
 {
     base.Update();
     this._life        = 1f;
     this.angleDegrees = this._spinAngle;
     if ((bool)this._sparkTimer)
     {
         Level.Add((Thing)Spark.New(this.x, this.y - 2f, new Vec2(Rando.Float(-1f, 1f), -0.5f), 0.1f));
     }
     if (!(bool)this._explodeTimer)
     {
         return;
     }
     SFX.Play("littleGun", Rando.Float(0.8f, 1f), Rando.Float(-0.5f, 0.5f));
     for (int index = 0; index < 8; ++index)
     {
         float      num        = (float)((double)index * 45.0 - 5.0) + Rando.Float(10f);
         ATShrapnel atShrapnel = new ATShrapnel();
         atShrapnel.range = 8f + Rando.Float(3f);
         Level.Add((Thing) new Bullet(this.x + (float)(Math.Cos((double)Maths.DegToRad(num)) * 6.0), this.y - (float)(Math.Sin((double)Maths.DegToRad(num)) * 6.0), (AmmoType)atShrapnel, num)
         {
             firedFrom = (Thing)this
         });
     }
     Level.Add((Thing)SmallSmoke.New(this.x, this.y));
     if ((double)Rando.Float(1f) < 0.100000001490116)
     {
         Level.Add((Thing)SmallFire.New(this.x, this.y, 0.0f, 0.0f, firedFrom: ((Thing)this)));
     }
     Level.Remove((Thing)this);
 }
    private void DrawEndless(int part,GameTime gameTime, SpriteBatch spriteBatch)
    {
        level = new Level();
        level.player = new Player(new Vector3(200, 200f, 200));

        GameObjectGrid grid = new GameObjectGrid(20,20,"grid");

        for (int i = 0; i < grid.Rows; i++)
        {
            grid.Add(new WallTile("01"), 0, i);
            grid.Add(new WallTile("01"), 2, i);
            grid.Add(new PathTile("01"), 1, i);
        }

        for (int x = 0; x < grid.Objects.GetLength(0); x++)
        {
            for (int y = 0; y < grid.Objects.GetLength(1); y++)
            {
                if (grid.Objects[x, y] != null)
                {
                    grid.Objects[x, y].Position -= new Vector3(0, 0, GameObjectGrid.CellWidth * part / 60);
                    if (grid.Objects[x, y] is WallTile)
                    {
                        grid.Objects[x, y].Position += new Vector3(0, 200, 0);
                    }
                }
            }
        }

        level.Add(grid);

        level.Parent = this;

        foreach (GameObject obj in level.Objects)
        {
            obj.Parent = level;
        }
    }