コード例 #1
0
 /// <summary>
 /// This was originally a bug, but I decided to make this a feature since it would be frustrating to repeat all the puzzles of the level.
 /// </summary>
 /// <param name="play"></param>
 public void TPPlayer(ref o_plcharacter play)
 {
     play.position.Y = play.spawnpoint.Y - 1;
     play.position.X = play.spawnpoint.X;
     Game1.PlaySound(3);
     play.velocity = Vector2.Zero;
     Game1.game.ResetLevel();
 }
コード例 #2
0
        public void Destroy()
        {
            collisionOffset  = new Vector2(-20, -10);
            isKenematic      = false;
            renderer.animNum = 1;
            renderer.ForceUpdate();
            ForceCollisionBoxUpdate();
            collisionBox.Width  = 50;
            collisionBox.Height = 50;
            o_block[]     blocks = IntersectBoxAll <o_block>(new Vector2(0, 0));
            o_plcharacter play   = IntersectBox <o_plcharacter>(new Vector2(0, 0));

            if (blocks != null)
            {
                if (play != null)
                {
                    if (parent != null)
                    {
                        parent.bomb_ItemToFocusOn = null;
                    }

                    TPPlayer(ref play);

                    //Game1.RemoveObject(play);
                    //Game1.game.ResetLevel();
                    return;
                }
                for (int i = 0; i < blocks.Length; i++)
                {
                    s_object bl   = blocks[i];
                    o_block  blok = bl.GetComponent <o_block>();


                    if (blok.TYPEOFBLOCK == o_block.BLOCK_TYPE.BREAKABLE)
                    {
                        Game1.game.ChangeTile(bl.position, blok.TileNum);
                        Game1.RemoveObject(bl);
                    }
                }
            }
            if (parent != null)
            {
                parent.bomb_ItemToFocusOn = null;
            }
        }
コード例 #3
0
        public override void Update(GameTime gametime)
        {
            if (CheckPoint(new Vector2(0, 0)))
            {
                if (catchDel < 0)
                {
                    Game1.RemoveObject(this);
                }
            }

            o_block block = null;

            block = IntersectBox <o_block>(new Vector2(0, 0));

            if (block != null)
            {
                switch (block.TYPEOFBLOCK)
                {
                case o_block.BLOCK_TYPE.SWITCH:

                    block.ButtonChange();
                    Game1.RemoveObject(this);
                    break;

                case o_block.BLOCK_TYPE.SPIKES:

                    if (itType != ITEM_TY.Bomb)
                    {
                        position = spawnpoint;
                        velocity = Vector2.Zero;
                    }
                    else
                    {
                        bombTimer = 0;
                    }
                    break;
                }
            }

            if (itType == ITEM_TY.Bomb)
            {
                switch (fs)
                {
                case FUSE_STATE.THROWN:
                    if (parent == null)
                    {
                        bombTimer -= (float)gametime.ElapsedGameTime.TotalSeconds;
                        if (bombTimer <= 0)
                        {
                            isKenematic       = false;
                            collisionBox.Size = (new Vector2(20, 20) * 2f).ToPoint();
                            position          = new Vector2(collisionBox.Location.X + 10, collisionBox.Location.Y - 10);
                            ForceCollisionBoxUpdate();
                            bombTimer = 0.5f;
                            fs        = FUSE_STATE.BLOWING_UP;
                        }
                    }
                    else
                    {
                        o_plcharacter play = IntersectBox <o_plcharacter>(new Vector2(0, 0));
                        if (play != null)
                        {
                            if (parent != null)
                            {
                                parent.bomb_ItemToFocusOn = null;
                            }
                            TPPlayer(ref play);
                            return;
                        }
                    }
                    break;

                case FUSE_STATE.BLOWING_UP:

                    bombTimer -= (float)gametime.ElapsedGameTime.TotalSeconds;
                    if (bombTimer >= 0)
                    {
                        Destroy();
                    }
                    else
                    {
                        Game1.PlaySound(7, position);
                        if (parent != null)
                        {
                            parent.bomb_ItemToFocusOn = null;
                        }
                        else
                        {
                            o_item it = Game1.AddObject <o_item>(spawnpoint, "bomb", Game1.textures["bomb"].Item2, Game1.textures["bomb"].Item1);
                            if (it != null)
                            {
                                it.itType     = o_item.ITEM_TY.Bomb;
                                it.spawnpoint = spawnpoint;
                            }
                        }

                        Game1.RemoveObject(this);
                    }
                    break;
                }
            }

            //timer -= (float)gametime.ElapsedGameTime.TotalSeconds;
            if (catchDel > 0)
            {
                catchDel -= (float)gametime.ElapsedGameTime.TotalSeconds;
            }

            o_plcharacter pl = CheckPointEnt <o_plcharacter>(new Vector2(10, 10));

            if (pl != null)
            {
                if (catchDel <= 0 && iscatchable)
                {
                    pl.heldItem  = itType;
                    pl.itemSpawn = spawnpoint;
                    Game1.RemoveObject(this);
                }
            }

            /*
             * if (timer < 0)
             *  Game1.RemoveObject(this);
             *
             * o_movableSolid item = IntersectBox<o_movableSolid>(new Vector2(0, 0));
             * if (item != null)
             * {
             *  item.velocity.X += velocity.X / 10;
             *  velocity = Vector2.Zero;
             * }
             */


            base.Update(gametime);
        }