public override void OnGround() { if (parent != null) { Game1.PlaySound(7, position); bombTimer = 0.5f; fs = FUSE_STATE.BLOWING_UP; Destroy(); } }
public void Throw(Vector2 dir) { fs = FUSE_STATE.THROWN; catchDel = 0.5f; velocity += dir; if (itType == ITEM_TY.Bomb) { fs = FUSE_STATE.THROWN; bombTimer = 1f; } else { renderer.SetTexture(Game1.textures["ball"].Item2, Game1.textures["ball"].Item1); } }
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); }