public void Crush(int2 coord) { Slot s = Slot.GetSlot(coord); FieldAssistant.main.BlockCrush(coord, false, true); FieldAssistant.main.JellyCrush(coord); if (s) { Jam.JamIt(s, chip.jamType); } if (s && s.chip) { Chip c = s.chip; c.SetScore(0.3f); c.jamType = chip.jamType; c.DestroyChip(); } }
public static bool Crush(int2 coord, string jamType = "") { Slot s = Slot.GetSlot(coord); FieldAssistant.main.BlockCrush(coord, false, true); FieldAssistant.main.JellyCrush(coord); if (s) { Jam.JamIt(s, jamType); } if (s && s.chip) { Chip c = s.chip; c.SetScore(0.3f); c.jamType = jamType; c.DestroyChip(); AnimationAssistant.main.Explode(s.transform.position, 3, 20); } return(coord.IsItHit(0, 0, LevelProfile.main.width - 1, LevelProfile.main.height - 1)); }
IEnumerator DestroyChipRoutine() { if (jamType == "") { jamType = Jam.GetType(slot); } Jam.JamIt(slot, jamType); yield return(StartCoroutine(logic.Destroying())); if (!destroying) { yield break; } if (IsColored()) { SessionAssistant.main.countOfEachTargetCount[id]--; } Destroy(gameObject); }
// Field generator public IEnumerator CreateField() { RemoveField(); // Removing old field field = new Field(LevelProfile.main.GetClone()); Slot.folder = new GameObject().transform; Slot.folder.name = "Slots"; Slot.all.Clear(); Vector3 fieldDimensions = new Vector3(field.width - 1, field.height - 1, 0) * ProjectParameters.main.slot_offset; foreach (SlotSettings settings in field.slots.Values) { yield return(0); Slot slot; #region Creating a new empty slot Vector3 position = new Vector3(settings.position.x, settings.position.y, 0) * ProjectParameters.main.slot_offset - fieldDimensions / 2; GameObject obj = ContentAssistant.main.GetItem("SlotEmpty", position); obj.name = "Slot_" + settings.position.x + "x" + settings.position.y; obj.transform.SetParent(Slot.folder); slot = obj.GetComponent <Slot>(); slot.coord = settings.position; Slot.all.Add(slot.coord, slot); #endregion #region Creating a generator if (settings.generator) { slot.gameObject.AddComponent <SlotGenerator>(); } #endregion #region Creating a teleport if (settings.teleport != int2.Null) { slot.slotTeleport.target_postion = settings.teleport; } else { Destroy(slot.slotTeleport); } #endregion #region Setting gravity direction slot.slotGravity.gravityDirection = settings.gravity; #endregion #region Setting sugar target (by slot tag) if (LevelProfile.main.target == FieldTarget.SugarDrop && settings.tags.Contains("SugarDrop")) { slot.sugarDropSlot = true; GameObject sd = ContentAssistant.main.GetItem("SugarDrop", position); sd.name = "SugarDrop"; sd.transform.parent = slot.transform; sd.transform.localPosition = Vector3.zero; sd.transform.Rotate(0, 0, Utils.SideToAngle(settings.gravity) + 90); } #endregion #region Creating a block if (settings.block_type != "") { GameObject b_obj = ContentAssistant.main.GetItem(settings.block_type); b_obj.transform.SetParent(slot.transform); b_obj.transform.localPosition = Vector3.zero; b_obj.name = settings.block_type + "_" + settings.position.x + "x" + settings.position.y; IBlock block = b_obj.GetComponent <IBlock>(); slot.block = block; block.slot = slot; block.level = settings.block_level; block.Initialize(); } #endregion #region Create a jelly if (LevelProfile.main.target == FieldTarget.Jelly && settings.jelly_level > 0) { GameObject j_obj; switch (settings.jelly_level) { case 1: j_obj = ContentAssistant.main.GetItem("SingleLayerJelly"); break; case 2: default: j_obj = ContentAssistant.main.GetItem("Jelly"); break; } j_obj.transform.SetParent(slot.transform); j_obj.transform.localPosition = Vector3.zero; j_obj.name = "Jelly_" + settings.position.x + "x" + settings.position.y; Jelly jelly = j_obj.GetComponent <Jelly>(); slot.jelly = jelly; } #endregion #region Create a jam if (LevelProfile.main.target == FieldTarget.Jam) { Jam.JamIt(slot, settings.jam); } #endregion #region Create a chip if (!string.IsNullOrEmpty(settings.chip) && (slot.block == null || slot.block.CanItContainChip())) { SessionAssistant.ChipInfo chipInfo = SessionAssistant.main.chipInfos.Find(x => x.name == settings.chip); if (chipInfo != null) { string key = chipInfo.contentName + (chipInfo.color ? Chip.chipTypes[Mathf.Clamp(settings.color_id, 0, Chip.colors.Length - 1)] : ""); GameObject c_obj = ContentAssistant.main.GetItem(key); c_obj.transform.SetParent(slot.transform); c_obj.transform.localPosition = Vector3.zero; c_obj.name = key; slot.chip = c_obj.GetComponent <Chip>(); } } #endregion } Slot.Initialize(); foreach (int2 coord in field.wall_vertical) { yield return(0); #region Create a vertical wall Slot slot = Slot.GetSlot(coord); if (slot) { slot.SetWall(Side.Left); slot = slot[Side.Left]; if (slot) { slot.SetWall(Side.Right); } } #endregion } foreach (int2 coord in field.wall_horizontal) { yield return(0); #region Create a horizontal wall Slot slot = Slot.GetSlot(coord); if (slot) { slot.SetWall(Side.Bottom); slot = slot[Side.Bottom]; if (slot) { slot.SetWall(Side.Top); } } #endregion } List <Pair <int2> > walls = new List <Pair <int2> >(); foreach (Slot slot in Slot.all.Values) { foreach (Side side in Utils.straightSides) { if (slot[side] != null) { continue; } Pair <int2> pair = new Pair <int2>(slot.coord, slot.coord + Utils.SideOffset(side)); if (walls.Contains(pair)) { continue; } yield return(0); #region Create a wall object Vector3 position = new Vector3(Utils.SideOffsetX(side), Utils.SideOffsetY(side), 0) * 0.353f; GameObject w_obj = ContentAssistant.main.GetItem("Wall"); w_obj.transform.SetParent(slot.transform); w_obj.transform.localPosition = position; w_obj.name = "Wall_" + side; if (Utils.SideOffsetY(side) != 0) { w_obj.transform.Rotate(0, 0, 90); } walls.Add(pair); #endregion } } SlotGravity.Reshading(); yield return(0); SUBoosterButton.Generate(Slot.folder); // 広告用に位置をずらしてます Slot.folder.transform.localPosition = new Vector3(0.0f, 0.45f, 0.0f); }