void Respawn() { Vector2 old_position = transform.position + new Vector3(10, 10); Spawn(hero.SpawnPoint); hero.hp = 1000f; for (int cell_i = 0; cell_i < HeroInventory.Cells.Count; cell_i++) { if (HeroInventory.Cells[cell_i].is_item) { while (HeroInventory.Cells[cell_i].count_item > 0) { drop.GenerateItemDrop(HeroInventory.Cells[cell_i].object_save, old_position); HeroInventory.Cells[cell_i].count_item -= 1; } } } }
void Update() { blocks = Area.blocks; if (transform.name == "BreakPoint1") { return; } if (blocks.Count > 0) { for (int i = 0; i < blocks.Count; i++) { float left = blocks[i].transform.position.x; float right = blocks[i].transform.position.x + 0.64f; if (transform.position.x > left && transform.position.x < right) { float up = blocks[i].transform.position.y; float down = blocks[i].transform.position.y - 0.64f; if (transform.position.y > down && transform.position.y < up) { GameObject block = blocks[i]; Block BlockScript = block.GetComponent <Block>(); switch (block.tag) { case "block": if (BlockScript.hp - 1 <= 0) { block.GetComponent <SpriteRenderer>().material = Standart; if (BlockScript.PlaceBackground) { CreateBlockBackground(block, block.transform.position, BlockScript.ChangeBackgroundColor); } BlockScript.hp = BlockScript.MaxHp; item_m.GenerateItemDrop(block, transform.position); blocks.RemoveAt(i); } else { if (BlockScript.hp == BlockScript.MaxHp) { sounds.PlayHit(block.name); } if (!BlockScript.IsBreaking) { BlockScript.hp -= 1; SetBreakMask(BlockScript.hp, BlockScript.MaxHp, BreakMaterial, block); BlockScript.BreakBlock(0.1f, Standart); } } break; case "bg_block": if (Input.GetKey(KeyCode.LeftShift)) { blocks.RemoveAt(i); Destroy(block); } break; } gameObject.SetActive(false); } else { gameObject.SetActive(false); } } else { gameObject.SetActive(false); } } } }