void CheckCombine(int column, int row, int type, int currentSizeX, int currentSizeY) { int sizeCounterX = 0; int newCurrentSizeY = currentSizeY; int newCurrentSizeX = currentSizeX; int newY = row + currentSizeY; for (int x = column; x < maxColumn; x++) { if (!visitedArray[x, newY] && jellyArray[newY].Column[x] != null) { if (jellyArray[newY].Column[x].type == type) { sizeCounterX++; } else { break; } } else { break; } } if (sizeCounterX >= 2) { newCurrentSizeY++; if (newCurrentSizeX == 0) { newCurrentSizeX = sizeCounterX; } else { if (sizeCounterX < newCurrentSizeX) { newCurrentSizeX = sizeCounterX; } } CheckCombine(column, row, type, newCurrentSizeX, newCurrentSizeY); } else { if (newCurrentSizeX >= 2 && newCurrentSizeY >= 2) { Jelly obj = AddJelly(type, row, column, newCurrentSizeX, newCurrentSizeY, false); for (int x = column; x < (column + newCurrentSizeX); x++) { for (int y = row; y < (row + newCurrentSizeY); y++) { visitedArray[x, y] = true; jellyArray[y].Column[x].DisposeJelly(); jellyArray[y].Column[x] = obj; print("(" + x + "," + y + ") = " + newCurrentSizeX + " x " + newCurrentSizeY); } } } } }
private void SpawnJellyWave(int totalType, int juiceQuota) { controller.JellyTypes_lvl.Clear(); int type = 0; for (int i = 0; i < jellyPrefab.Count; i++) { controller.JellyTypes_lvl.Add((JellyTypes)i); } controller.AssignJuiceQuota(totalType, juiceQuota); for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++) { for (int columnIndex = 0; columnIndex < columnNumber; columnIndex++) { //create crisscross jellies type = ((rowIndex + columnIndex + 1) % totalType == 0) ? 0: type + 1; Jelly obj = AddJelly(type, rowIndex, columnIndex, 1, 1, false); SetJelly(rowIndex, columnIndex, obj); } } }
//Instantiate Jelly to designated position and give size public Jelly AddJelly(int type, int rowIndex, int columnIndex, int width, int height, bool hasPower) { //实例化预置件是对象类型 Jelly obj = Instantiate(jellyPrefab[type]) as Jelly; //设置其父容器为GameController obj.transform.parent = jellyParent.transform; obj.rowIndex = rowIndex; obj.columnIndex = columnIndex; obj.width = width; obj.height = height; obj.type = type; obj.gameController = this; obj.InitializePosition(); obj.ScaleSize(); obj.hasPower = hasPower; if (hasPower) { GameObject glow = Instantiate(glowingJelly); glow.transform.parent = obj.transform; glow.transform.localPosition = Vector3.zero; obj.sr_glow = glow.GetComponent <SpriteRenderer>(); } return(obj); }
public void Dispose() { Jelly.Dispose(); ControlFrame.Dispose(); Jelly = null; ControlFrame = null; WireframeRenderer = null; JellyRenderer = null; ControlFrameRenderer = null; JellyController = null; }
public Jelly AddJelly(int _type, int _column, int _row, bool _hasPower) { type = _type; column = _column; row = _row; myJelly = GameManager.GetInstance.AddJelly(type, row, column, 1, 1, _hasPower) as Jelly; myJelly.sr.enabled = false; if (myJelly.sr_glow) { myJelly.sr_glow.enabled = false; } return(myJelly); }
//生成匹配数组 private void AddMatches(Jelly c) { if (matchesArrayList == null) { //第一次进行创建 matchesArrayList = new ArrayList(); } int index = matchesArrayList.IndexOf(c); //如果当前对象不在匹配数组中,就将之添加进去 if (index == -1) { matchesArrayList.Add(c); } }
void SplashAdjacentJelly(int newX, int newY, bool hasPower, int width, int height, int type) { if (jellyArray[newY].Column[newX] != null) { if (jellyArray[newY].Column[newX].type != type && jellyArray[newY].Column[newX].width == 1 && jellyArray[newY].Column[newX].height == 1) { hasPower = jellyArray[newY].Column[newX].hasPower; width = jellyArray[newY].Column[newX].width; height = jellyArray[newY].Column[newX].height; jellyArray[newY].Column[newX].DisposeJelly(); Jelly obj = AddJelly(type, newY, newX, width, height, hasPower); print("T:" + type + " X:" + newX + " Y:" + newY); SetJelly(newY, newX, obj); } } }
public void ExtractInputAndGenerateResult() { var jelly = new Jelly(5, 3, "E"); var expected = new List <Jelly>() { new Jelly(1, 1, "E") }; string input = "53\r\n11E RFRFRFRF\r\n"; var objInput = new Input(); List <Jelly> lstJelly = objInput.ExtractInputAndGenerateResult(input); var expectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(lstJelly); var actualJson = Newtonsoft.Json.JsonConvert.SerializeObject(lstJelly); //assert Assert.AreEqual(actualJson, expectedJson); }
//调用销毁方法删除糖果 private void RemoveJelly(Jelly c) { AddEffect(c.transform.position); //播放爆炸音效 GetComponent <AudioSource>().PlayOneShot(explosionClip); //移除自己 c.DisposeJelly(); //得到被移除糖果上面的糖果 int columnIndex = c.columnIndex; for (int rowIndex = c.rowIndex + 1; rowIndex < rowNumber; rowIndex++) { Jelly c1 = GetJelly(rowIndex, columnIndex); //往下移一位 c1.rowIndex--; //c1.UpdatePosition(); //c1.ITweenToPosition(); //保存其位置 SetJelly(rowIndex - 1, columnIndex, c1); } }
public void SpawnJuice(int step, JellyTypes type, bool hasPower) { Juice juice = Instantiate(juicePrefab[(int)type]) as Juice; juice.transform.position = controller.transform.position - new Vector3(0, 1, 0); if (hasPower) { GameObject glow = Instantiate(glowingJuice) as GameObject; glow.transform.parent = juice.transform; glow.transform.localPosition = Vector3.zero; } int topRow = FindSpawnJellyPositionY(step); float topRowPosY = 0; if (topRow != -1) { Jelly topJellp = jellyArray[topRow].Column[step]; topRowPosY = topJellp.transform.position.y; } juice.ActivateMovement(topRowPosY, hasPower); jellyArray[topRow + 1].Column[step] = juice.AddJelly((int)type, step, topRow + 1, hasPower); }
public IceCreamBase Addon(int toppings, IceCreamBase icecream) { switch (toppings) { case (int)Toppings.Chocochips: icecream = new Chocochips(icecream); break; case (int)Toppings.Cookies: icecream = new Cookies(icecream); break; case (int)Toppings.Jelly: icecream = new Jelly(icecream); break; case (int)Toppings.Fruits: icecream = new Fruits(icecream); break; case (int)Toppings.Almonnd: icecream = new Almond(icecream); break; case (int)Toppings.Cashew: icecream = new Cashew(icecream); break; case (int)Toppings.Pistachio: icecream = new Pistachio(icecream); break; default: break; } return(icecream); }
private static void SpawnFromString(IRoom room, SpriteBatch spriteBatch, string spawnType, int offsetX, int offsetY, int gridX, int gridY) { int posX = offsetX + gridX * RoomConstants.TileLength; int posY = offsetY + gridY * RoomConstants.TileLength; Point position = new Point(posX, posY); IBlock blockType; INpc npcType; IItem itemType; IBackground backgroundType; switch (spawnType) { //Blocks case RoomConstants.Block: blockType = new Square(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.BrickTile: blockType = new BrickTile(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.GapTile: blockType = new GapTile(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.Fire: position.X += RoomConstants.TileLength / 2; blockType = new Fire(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.LadderTile: backgroundType = new LadderTile(spriteBatch, position); room.AllObjects.Spawn(backgroundType); break; case RoomConstants.Stairs: blockType = new Stairs(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.FishStatue: blockType = new FishStatues(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.DragonStatue: blockType = new DragonStatues(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.BlueGrass: backgroundType = new TileBlueGrass(spriteBatch, position); room.AllObjects.Spawn(backgroundType); break; case RoomConstants.Water: blockType = new TileWater(spriteBatch, position); room.AllObjects.Spawn(blockType); break; case RoomConstants.MovableBlock: blockType = new MovableSquare(spriteBatch, position); ((RoomWithMovableSquare)room).AddMovableSquare((MovableSquare)blockType); room.AllObjects.Spawn(blockType); break; //Npcs case RoomConstants.Aquamentus: position.Y += RoomConstants.TileLength / 2; npcType = new Aquamentus(spriteBatch, position, room.AllObjects); room.AllObjects.Spawn(npcType); break; case RoomConstants.Bat: npcType = new Bat(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.Goriya: npcType = new Goriya(spriteBatch, position, room.AllObjects); room.AllObjects.Spawn(npcType); break; case RoomConstants.Hand: npcType = new Hand(spriteBatch, position, ((RoomWallMaster)room).GetWallMasterRoomToJumpTo()); room.AllObjects.Spawn(npcType); break; case RoomConstants.Jelly: npcType = new Jelly(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.OldMan: position.X += RoomConstants.TileLength / 2; npcType = new OldMan(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.Skeleton: npcType = new Skeleton(spriteBatch, position); room.AllObjects.Spawn(npcType); break; case RoomConstants.SpikeTrap: npcType = new SpikeTrap(spriteBatch, position, room.AllObjects.GetPlayer(0)); room.AllObjects.Spawn(npcType); break; //Items case RoomConstants.Compass: itemType = new CompassItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Heart: position.X += (int)(4 * RoomConstants.SpriteMultiplier); position.Y += (int)(4 * RoomConstants.SpriteMultiplier); itemType = new HeartItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Key: itemType = new KeyItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Map: itemType = new MapItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Triforce: position.X += (int)(12 * RoomConstants.SpriteMultiplier); position.Y += (int)(2 * RoomConstants.SpriteMultiplier); itemType = new TriforceItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.HeartContainer: itemType = new HeartContainerItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; case RoomConstants.Bow: itemType = new BowItem(spriteBatch, position); room.AllObjects.Spawn(itemType); break; default: break; } }
void Update() { if (main == null) { main = this; StartCoroutine(UpdatePotentialsRoutine()); } if (main != this) return; }
private Sandwich(PeanutButter peanutButter, Jelly jelly) { }
public void SetJelly(Jelly j) { jelly = j; }
// 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); }
public static Sandwich Create(PeanutButter peanutButter, Jelly jelly) { Implementation.Do(); return(new Sandwich(peanutButter, jelly)); }
public override void OnInspectorGUI() { m_object.Update(); DrawDefaultInspector(); Jelly _2dxScript = (Jelly)target; Texture2D icon = Resources.Load("2dxfxinspector-anim") as Texture2D; if (icon) { Rect r; float ih = icon.height; float iw = icon.width; float result = ih / iw; float w = Screen.width; result = result * w; r = GUILayoutUtility.GetRect(ih, result); EditorGUI.DrawTextureTransparent(r, icon); } EditorGUILayout.PropertyField(m_object.FindProperty("ActiveUpdate"), new GUIContent("Active Update", "Active Update, for animation / Animator only")); EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call")); if (_2dxScript.ForceMaterial == null) { _2dxScript.ActiveChange = true; } else { if (GUILayout.Button("Remove Shared Material")) { _2dxScript.ForceMaterial = null; _2dxScript.ShaderChange = 1; _2dxScript.ActiveChange = true; _2dxScript.CallUpdate(); } EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property")); } if (_2dxScript.ActiveChange) { EditorGUILayout.BeginVertical("Box"); Texture2D icone = Resources.Load("2dxfx-icon-distortion") as Texture2D; EditorGUILayout.PropertyField(m_object.FindProperty("Heat"), new GUIContent("Jelly Distortion", icone, "Change the distortion of the Jelly FX")); icone = Resources.Load("2dxfx-icon-distortion") as Texture2D; EditorGUILayout.PropertyField(m_object.FindProperty("Inside"), new GUIContent("Jelly Inside", icone, "Change the inside distortion of the Jelly FX")); icone = Resources.Load("2dxfx-icon-time") as Texture2D; EditorGUILayout.PropertyField(m_object.FindProperty("Speed"), new GUIContent("Time Speed", icone, "Change the time speed")); EditorGUILayout.BeginVertical("Box"); icone = Resources.Load("2dxfx-icon-fade") as Texture2D; EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing")); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); } m_object.ApplyModifiedProperties(); }
//根据行列索引得到糖果对象 private Jelly GetJelly(int rowIndex, int columnIndex) { Jelly c = jellyArray[rowIndex].Column[columnIndex]; return(c); }
//根据行列索引设置糖果的位置 private void SetJelly(int _rowIndex, int _columnIndex, Jelly c) { jellyArray[_rowIndex].Column[_columnIndex] = c; }
public bool JellyExplode() { if (jelly == null) { return(false); } GameObject explosion = null; // if (item != null) // { // switch (item.GetCookie(item.type)) // { // case ITEM_TYPE.COOKIE_1: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.BlueCookieExplosion()) as GameObject); // break; // case ITEM_TYPE.COOKIE_2: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.GreenCookieExplosion()) as GameObject); // break; // case ITEM_TYPE.COOKIE_3: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.OrangeCookieExplosion()) as GameObject); // break; // case ITEM_TYPE.COOKIE_4: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.PurpleCookieExplosion()) as GameObject); // break; // case ITEM_TYPE.COOKIE_5: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.RedCookieExplosion()) as GameObject); // break; // case ITEM_TYPE.COOKIE_6: // explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.YellowCookieExplosion()) as GameObject); // break; // } // } // board.CollectJelly(jelly); explosion = CFX_SpawnSystem.GetNextObject(Resources.Load(Configure.Jelly1Effects()) as GameObject); if (explosion != null) { explosion.transform.position = item.transform.position; } AudioManager.instance.CageExplodeAudio(); if (jelly.type == JELLY_TYPE.JELLY_1) { Destroy(jelly.gameObject); jelly = null; if (item != null && item.type == ITEM_TYPE.CHERRY) { return(false); } } else if (jelly.type == JELLY_TYPE.JELLY_2) { var prefab = Resources.Load(Configure.Jelly1()) as GameObject; jelly.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite; jelly.type = JELLY_TYPE.JELLY_1; } else if (jelly.type == JELLY_TYPE.JELLY_3) { var prefab = Resources.Load(Configure.Jelly2()) as GameObject; jelly.gameObject.GetComponent <SpriteRenderer>().sprite = prefab.GetComponent <SpriteRenderer>().sprite; jelly.type = JELLY_TYPE.JELLY_2; } StartCoroutine(item.ResetDestroying()); return(true); }