// adds the neighbors into the list. public void AddToList(Gems g) { if(!neighborGems.Contains(g)) { neighborGems.Add(g); } }
string GetExpNum(int id) { string expNum = ""; if (szSelectCharator.Count == 0) { return(expNum.ToString()); } for (int i = 0; i < szSelectCharator.Count; i++) { switch (id) { case 0: Monster mon = szSelectCharator[i]._boxItem.curData as Monster; expNum += mon.RTData.curExp + "/" + Core.Data.monManager.getMonsterNextLvExp(mon.Star, mon.RTData.curLevel).ToString(); break; case 1: Equipment equip = szSelectCharator[i]._equipment.curData as Equipment; expNum += equip.RtEquip.exp + "/" + Core.Data.EquipManager.GetEquipUpExp(equip.RtEquip.lv, equip.ConfigEquip.star).ToString(); break; case 2: Gems gem = szSelectCharator[i]._gem.curData as Gems; expNum += gem.configData.skillEffect.ToString(); break; } } return(expNum); }
public MailAttachedItem(Item item, byte pos) { Position = pos; AttachID = (int)item.GetGUID().GetCounter(); Item = new ItemInstance(item); Count = item.GetCount(); Charges = item.GetSpellCharges(); MaxDurability = item.GetUInt32Value(ItemFields.MaxDurability); Durability = item.GetUInt32Value(ItemFields.Durability); Unlocked = !item.IsLocked(); for (EnchantmentSlot slot = 0; slot < EnchantmentSlot.MaxInspected; slot++) { if (item.GetEnchantmentId(slot) == 0) { continue; } Enchants.Add(new ItemEnchantData((int)item.GetEnchantmentId(slot), item.GetEnchantmentDuration(slot), (int)item.GetEnchantmentCharges(slot), (byte)slot)); } byte i = 0; foreach (ItemDynamicFieldGems gemData in item.GetGems()) { if (gemData.ItemId != 0) { ItemGemData gem = new ItemGemData(); gem.Slot = i; gem.Item = new ItemInstance(gemData); Gems.Add(gem); } ++i; } }
private void GetGems() { SetupGemsList(); foreach (GemSetting gemSetting in Parent.Machine.Utility.BotSettings.GemSettings) { HudList.HudListRowAccessor row = Gems.AddRow(); using (HudStaticText text = new HudStaticText()) { text.Text = gemSetting.Name; row[0] = text; } using (HudStaticText text = new HudStaticText()) { text.Text = gemSetting.Keyword; row[1] = text; } using (HudStaticText text = new HudStaticText()) { text.Text = gemSetting.Heading.ToString(); row[2] = text; } } }
private void SetupGemsList() { try { HudList.HudListRowAccessor row = Gems.AddRow(); using (HudStaticText text = new HudStaticText()) { text.Text = "Gem"; row[0] = text; } using (HudStaticText text = new HudStaticText()) { text.Text = "Keyword"; row[1] = text; } using (HudStaticText text = new HudStaticText()) { text.Text = "Heading"; row[2] = text; } } catch (Exception ex) { Debug.LogException(ex); } }
public InspectItemData(Item item, byte index) { CreatorGUID = item.GetGuidValue(ItemFields.Creator); Item = new ItemInstance(item); Index = index; Usable = true; // @todo for (EnchantmentSlot enchant = 0; enchant < EnchantmentSlot.Max; ++enchant) { uint enchId = item.GetEnchantmentId(enchant); if (enchId != 0) { Enchants.Add(new InspectEnchantData(enchId, (byte)enchant)); } } byte i = 0; foreach (ItemDynamicFieldGems gemData in item.GetGems()) { if (gemData.ItemId != 0) { ItemGemData gem = new ItemGemData(); gem.Slot = i; gem.Item = new ItemInstance(gemData); Gems.Add(gem); } ++i; } }
string GetDefenceNum(int id) { int defNum = 0; if (szSelectCharator.Count == 0) { return(defNum.ToString()); } for (int i = 0; i < szSelectCharator.Count; i++) { switch (id) { case 0: Monster mon = szSelectCharator[i]._boxItem.curData as Monster; defNum += mon.getDefend; break; case 1: Equipment equip = szSelectCharator[i]._equipment.curData as Equipment; defNum += equip.getDefend; break; case 2: Gems gem = szSelectCharator[i]._gem.curData as Gems; defNum += gem.configData.def; break; } } return(defNum.ToString()); }
/// <summary> /// Used to set previous values for every <see cref="AbstractVariable{T}"/>. Must use the same order and logic as the <see cref="Scan"/> method. /// </summary> public void PreScan() { PlayerID.PreScan(); Username.PreScan(); IsReplay.PreScan(); if (IsReplay.Value) { return; } IsAlive.PreScan(); Time.PreScan(); Kills.PreScan(); Gems.PreScan(); ShotsFired.PreScan(); ShotsHit.PreScan(); if (IsAlive.Value) { EnemiesAlive.PreScan(); } if (!IsAlive.Value) { DeathType.PreScan(); } }
public void SetInfo(Player player) { NameLabel.Text = player.ToString(); NameLabel.BackColor = CloseButton.BackColor = player.Color.StrongColor; int i = 0; foreach (var gem in Gems.GetAllGems()) { ResourceControls().ElementAt(i).Developments = player.GetDevelopmentsOfType(gem); ResourceControls().ElementAt(i).Gems = player.GemsOfType(gem); i++; } PrestigeLabel.Text = ((int)player.Prestige).ToString(); NoblesButton.Text = player.VisitedNobles.Count().ToString(); NoblesButton.FlatAppearance.MouseOverBackColor = player.Color.SoftColor.Darken(10); NoblesButton.Visible = player.VisitedNobles.Any(); NoblesButton.Tag = player.VisitedNobles; ReservesButton.Text = player.ReservedDevelopments.Count().ToString(); ReservesButton.Visible = player.ReservedDevelopments.Any(); GoldCounter.Gems = player.GemsOfType(Gems.Gold); GoldCounter.Visible = player.GemsOfType(Gems.Gold).Any(); TotalGemsButton.Text = $"{player.TotalGems().ToString()}/10"; }
//Calculate percent-chances for each enchantment on the armor //Right now they are all calculated the same way. public void CalculateEnchantmentPercents() { //Iterate through all of the gem types for (int i = 0; i < (int)Gems.NumberOfTypes; i++) { //Specify a target gem that is currently being searched for targetGem = (Gems)i; //Find all instances of the target gem on the armor List <Gems> foundGems = attachedGems.FindAll(FindGem); //Add a key to the dictionary initialized to 0 if an instance //of the gem was found if (foundGems.Count > 0) { armorEnchantments.Add((Enchantments)i, 0); } //Calculate percent-chance for triggering that enchantment based on //number of gems found. Implement diminishing returns for each stacked gem. //1 Gem = 1/2 * baseEnchantmentChance //2 Gems = 1GemChance + (1/3 * baseEnchantmentChance) //3 Gems = 2GemChance + (1/4 * baseEnchantmentChance) //...etc. for (float j = 1; j <= foundGems.Count; j++) { //Update dictionary value armorEnchantments[(Enchantments)i] += baseEnchantmentChance / (j + 1); } } }
void OnTriggerEnter(Collider other) { if (other.tag == "Gems") { Gems gem = other.GetComponent <Gems>(); manager.gems += gem.value; Destroy(other.gameObject); } else if (other.tag == "Finish") { manager.getin++; if (this.tag == "Player") { player.gameObject.SetActive(false); } else if (this.tag == "Player2") { player2.gameObject.SetActive(false); } if (manager.getin == 2) { result.text = "Game Clear!"; manager.getin = 0; manager.GameOver(); } } }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<Gold> $" + Gold); sb.AppendLine("##Gold - " + Gold); var gemsTotal = Gems.Sum(g => g.Quantity); if (gemsTotal > 0) { sb.AppendLine("<Gem> $" + gemsTotal); foreach (var gem in Gems.OrderByDescending(g => g.Name).ThenBy(g => g.Quantity)) { sb.AppendLine($"##{gem.Name} - {gem.Quantity}"); } var cashTotal = Cash.Sum(c => c.Quantity); if (cashTotal > 0) { sb.AppendLine("<Cash> $" + cashTotal); foreach (var cash in Cash.OrderByDescending(g => g.Currency).ThenBy(g => g.Quantity)) { sb.AppendLine($"##{cash.Currency} - {cash.Quantity}"); } } } return(sb.ToString()); }
public override string ToString() { var builder = new StringBuilder(); if (Gold.Any()) { builder.AppendLine($"<Gold> ${GoldAmount}"); builder.AppendLine($"##Gold - {GoldAmount}"); } if (Gems.Any()) { builder.AppendLine($"<Gem> ${GemsAmount}"); foreach (var gem in Gems.OrderByDescending(g => g.Value.Name).ThenBy(g => g.Value.Amount)) { builder.AppendLine($"##{gem.Value.Name} - {gem.Value.Amount}"); } } if (AllCash.Any()) { builder.AppendLine($"<Cash> ${CashAmount}"); foreach (var cash in AllCash.OrderByDescending(c => c.Value.Name).ThenBy(c => c.Value.Amount)) { builder.AppendLine($"##{cash.Value.Name} - {cash.Value.Amount}"); } } return(builder.ToString()); }
void Start() { DontDestroyOnLoad(this); string admobAppID = "ca-app-pub-8440254339399479~9979703006"; string unityAppID = "3580197"; bool testMode = true; MobileAds.Initialize(admobAppID); Advertisement.Initialize(unityAppID, testMode); Button[] allButtons = FindObjectsOfType <Button>(); foreach (Button button in allButtons) { if (button.name == "RewardGems") { rewardButton = button; } } StartCoroutine(ShowBannerWhenReady()); Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER); RequestBanner(); runRewarded = false; gems = FindObjectOfType <Gems>(); }
/// <summary> /// Removes the gems. 卸下宝石 /// </summary> /// <param name="g">The green component.</param> public void removeGems(Gems g) { if (g != null) { g.equipped = false; } }
public override void fullfillByNetwork(BaseResponse response) { if (response != null && response.status != BaseResponse.ERROR) { LoginResponse loginResp = response as LoginResponse; if (loginResp != null && loginResp.data != null) { GemInfo[] gemList = loginResp.data.gems; if (gemList != null) { //clear dirty data BagOfGems.Clear(); Core.Data.AccountMgr.clearBagStatus(ConfigDataType.Gems); GemData gd = null; foreach (GemInfo gi in gemList) { if (gi != null && ConfigData.TryGetValue(gi.num, out gd)) { Gems gm = new Gems(gd); gm.id = gi.id; BagOfGems.Add(gi.id, gm); gm.isNew = Core.Data.AccountMgr.getStatus(gm.id) == BagOfStatus.STATUS_NEW; //加入统计 Core.Data.AccountMgr.analyseBag(ConfigDataType.Gems, gi.id); } } } } } }
public BaseRunescapeGem(Gems gemType) : base(Utility.RandomBool() ? 0x136C : Utility.RandomList(0x1368, 0x1369, 0x136B, 0x136C)) { mGemType = gemType; Stackable = false; mCut = false; }
//打开宝石合成UI void OpenGemHechengUI() { BaseBuildingData tBuildData = Core.Data.BuildingManager.GetBuildFromBagByNum(BaseBuildingData.BUILD_YELIAN).config; if (tBuildData != null) { if (Core.Data.playerManager.Lv < tBuildData.limitLevel) { SQYAlertViewMove.CreateAlertViewMove(string.Format(Core.Data.stringManager.getString(7320), tBuildData.limitLevel.ToString()) + tBuildData.name); return; } } else { SQYAlertViewMove.CreateAlertViewMove("can't find building config "); return; } ComLoading.Open(); Gems gem = m_selBagItem.curData as Gems; FrogingSystem.ForgingRoomUI.OpenUI(() => { //关闭镶嵌宝石界面 FrogingSystem.ForgingRoomUI.Instance.DestoryForgingRoomUI(); DBUIController.mDBUIInstance.SetViewState(RUIType.EMViewState.S_Bag); SQYPetBoxController.mInstance.SetPetBoxType(RUIType.EMBoxType.LOOK_Gem); }); DBUIController.mDBUIInstance.SetViewState(RUIType.EMViewState.H_Bag); FrogingSystem.ForgingRoomUI.Instance.GoToAndSetDia(FrogingSystem.ForgingPage.Forging_Synthetic, gem); }
//全部合成返回 void BackGemGroupCombine() { if (count == CombineTimes) { if (tempId != 0) { Gems resultGem = Core.Data.gemsManager.getGems(tempId); if (resultGem != null) { GetGemSucUI.OpenUI(resultGem.configData, view.TEXT(5064)); } } else { // SQYAlertViewMove.CreateAlertViewMove(view.TEXT(9014)); ClearLastSelected(); } Debug.Log(" lv =" + tempLv + "; defaultNum =" + defaultNum + "; successNum = " + successNum); view.SetCombineGemsResult(tempLv, CombineTimes, successNum); GemMouldNumInBag = Core.Data.itemManager.GetBagItemCount(110064); SelectedMouldNum = 0; view.SetSelectedGemNumMouldNum(SelectedMouldNum, GemMouldNumInBag); DBUIController.mDBUIInstance.RefreshUserInfo(); ClearLastSelected(); CombineTimes = 0; } ComLoading.Close(); }
public void SetDetail(ItemOfReward mreward) { _ItemOfReward = mreward; if (mreward.getCurType() == ConfigDataType.Monster) { Monster data = mreward.toMonster(Core.Data.monManager); ShowMonster(data); } else if (mreward.getCurType() == ConfigDataType.Equip) { Equipment data = mreward.toEquipment(Core.Data.EquipManager, Core.Data.gemsManager); ShowEquip(data); } else if (mreward.getCurType() == ConfigDataType.Gems) { Gems data = mreward.toGem(Core.Data.gemsManager); ShowGem(data); } else if (mreward.getCurType() == ConfigDataType.Frag) { Soul data = mreward.toSoul(Core.Data.soulManager); ShowFrag(data); } else if (mreward.getCurType() == ConfigDataType.Item) { Item item = mreward.toItem(Core.Data.itemManager); ShowItem(item); } else { RED.LogWarning("unknow reward type"); } _Head.MakePixelPerfect(); }
void Awake() { if (instance == null) { instance = this; } }
public static int Hue(Gems gemType) { switch (gemType) { case Gems.Sapphire: return(0x62); case Gems.Emerald: return(0x48); case Gems.Ruby: return(0x25); case Gems.Diamond: return(0x7FE); case Gems.Opal: return(0x903); case Gems.Jade: return(0x243); case Gems.Topaz: return(0x210); case Gems.Dragonstone: return(0x139); } return(0); }
public override string ToString() { StringBuilder bagContents = new StringBuilder(); if (Gold > 0) { bagContents.AppendLine($"<Gold> ${Gold}"); bagContents.AppendLine($"##Gold - {Gold}"); } if (GemsTotal > 0) { bagContents.AppendLine($"<Gem> ${GemsTotal}"); foreach (Gem gem in Gems .OrderByDescending(g => g.Type).ThenBy(g => g.Amount)) { bagContents.AppendLine(gem.ToString()); } } if (CashTotal > 0) { bagContents.AppendLine($"<Cash> ${CashTotal}"); foreach (Currency currency in Cash .OrderByDescending(c => c.Type).ThenBy(c => c.Amount)) { bagContents.AppendLine(currency.ToString()); } } return(bagContents.ToString().TrimEnd()); }
void Start() { curGem = ForgingRoomUI.Instance.SyntheticSystem.Selected_Frist_GemData; targetGemLevel = curGem.configData.level; // getSelectModelNum = ForgingRoomUI.Instance.SyntheticSystem.GetSelectModelNum(); // getModelNumInBag = ForgingRoomUI.Instance.SyntheticSystem.GetModelNumInBag(); }
/// <summary> /// Update the observable collections /// </summary> public void UpdateInventoryCategories() { Treasures.Clear(); Gems.Clear(); ArmorSet.Clear(); Buffs.Clear(); foreach (var gameItemQuantity in _inventory) { if (gameItemQuantity.GameItem is Treasure) { Treasures.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is Gem) { Gems.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is ArmorSet) { ArmorSet.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is Buff) { Buffs.Add(gameItemQuantity); } } }
public override void Dispose() { base.Dispose(); Gems.Clear(); IGems.Clear(); CellsList.Clear(); }
/*从服务器接收返回值,处理宝石合成 * */ public void SyntheticGem(BaseHttpRequest req, BaseResponse response) { if (response != null && response.status != BaseResponse.ERROR) { GemSyntheitcResponse param = response as GemSyntheitcResponse; /*如果没有保底 * */ if (param.data.succ == 1) { /*删除合成掉的宝石 * */ if (BagOfGems.ContainsKey(param.data.delId)) { int num = BagOfGems[param.data.delId].configData.ID; BagOfGems.Remove(param.data.delId); //删除统计 Core.Data.AccountMgr.setStatus(new BagOfStatus(param.data.delId, num, BagOfStatus.STATUS_DELETE)); } /*升级/降级宝石 * */ if (BagOfGems.ContainsKey(param.data.upId)) { GemData gd = null; ConfigData.TryGetValue(param.data.armNum, out gd); Gems gm = new Gems(gd); gm.id = param.data.upId; BagOfGems[param.data.upId] = gm; } } else { if (BagOfGems.ContainsKey(param.data.delId)) { BagOfGems.Remove(param.data.delId); } } Core.Data.playerManager.RTData.curStone += param.data.stone; Core.Data.playerManager.RTData.curCoin += param.data.coin; /*用掉宝石模具 * */ Item it = Core.Data.itemManager.GetBagItem(param.data.fpid); if (it != null) { it.RtData.count -= param.data.nm; /*如果数量为0,直接从背包中删除 * */ if (it.RtData.count <= 0) { Core.Data.itemManager.RemoveBagItem(param.data.fpid); } } } }
private void CheckMarket(Market market, int[] values, int gold) { foreach (var gem in Gems.GetAllGems()) { market.AvaliableOfType(gem).Should().Be(values[gem.Id - 1]); market.AvaliableGold().Should().Be(gold); } }
private void SelectGems() { isSelected = true; spriteRenderer.color = selectedColor; previousSelected = gameObject.GetComponent <Gems>(); audioSource.clip = audioClips[selectGems]; audioSource.enabled = true; }
/*清除最近的选择 * */ public void ClearLastSelected() { LastSelectedHoleButtonName = ""; SelectedGemdata = null; SelectedEqudata = null; view.Lab_Add.enabled = true; view.ClearGemInlayViewPanel(); }
public void GoToAndSetDia(ForgingPage page, Gems gem) { this.GoTo(page); AsyncTask.QueueOnMainThread(() => { SyntheticSystem.SelectGem(gem); }, 0.1f); ComLoading.Close(); }
/// <summary> /// A boolean method meant to figure out whether the gem selected is a neighbor. /// </summary> /// <param name="g"></param> /// <returns></returns> public bool NeighboredGem(Gems g) { // if the neighbors contains this particular gem, then return true. if (neighborGems.Contains(g)) { return true; } return false; }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: { mGemType = (Gems)reader.ReadInt(); mCut = reader.ReadBool(); //Cut gem should be 0x13A6 if (mCut) ItemID = 0x13A6; break; } } }
public static int Hue(Gems gemType) { switch (gemType) { case Gems.Sapphire: return 0x62; case Gems.Emerald: return 0x48; case Gems.Ruby: return 0x25; case Gems.Diamond: return 0x7FE; case Gems.Opal: return 0x903; case Gems.Jade: return 0x243; case Gems.Topaz: return 0x210; case Gems.Dragonstone: return 0x139; } return 0; }
// does the same thing, checking for matches except for the entire board public void checkNearbyMatches(Gems g) { List<Gems> match = new List<Gems>(); matchList(g.typ, g, g.XPos, g.YPos, ref match); rowColumnMatchCheck(g , match); }
// removes the neighbors in the list public void RemoveFromList(Gems g) { neighborGems.Remove(g); }
// recursive function meant to find max match public void matchList(ElementType gemType, Gems g, int XPos, int YPos, ref List<Gems> list) { // if there are any inconsistancies, return if (g == null) { return; } else if (g.typ != gemType) { return; } else if (list.Contains(g)) { return; } // otherwise recursively call matchList and add to list else { list.Add(g); if (XPos == g.XPos || YPos == g.YPos) { foreach (Gems germs in g.neighborGems) { matchList(gemType, germs, XPos, YPos, ref list); } } } }
public object Clone() { Gems clonedItem = new Gems(null, this.Name, this.Description, this.ItemValue); clonedItem.Type = Type; clonedItem.SortingLayer = SortingLayer; clonedItem.Count = Count; return clonedItem; }
public static void addGema1(Gems item) { gemas1.Add(item); }
public static void addGema2(Gems item) { gemas2.Add(item); }
public bool OnDamage(float damagePoints, int index) { HealthPoints -= (damagePoints * DamageCoef); Audio.PlayOneShot(Clips[Random.Range(0, Clips.Length)]); if(HealthPoints <= 0) { Scene._grid[index].isWalkable = true; //Spawn bag: GameObject toInstantiate = MonoBehaviour.Instantiate(HexTileManager.instance.Containers[Random.Range(0, HexTileManager.instance.Containers.Length)], Scene._grid[index].position, Quaternion.identity) as GameObject; toInstantiate.transform.SetParent(Scene._grid[index].TileObject.transform); //Set the hex tile as parent toInstantiate.GetComponent<MonoItem>().spriteRenderer.enabled = true; //Create items: int maxItem = Random.Range(3, 6); Item[] content = new Item[maxItem]; for (int i = 0; i < maxItem; i++) { //Select a random item // [GEMS][POWDER][RAWGEM][RAWCRYSTAL] switch (Random.Range(0, 4)) { //[GEMS] case 0: //Add a gem //Get a random gem switch (CrystalBiome.GemValues[Random.Range(0, CrystalBiome.GemValues.Length)]) { case ItemValues.WhiteGem: content[i] = new Gems(null, Gems.RedGemName, Gems.RedGemDescription, ItemValues.WhiteGem); break; case ItemValues.YellowGem: content[i] = new Gems(null, Gems.YellowGemName, Gems.YellowGemDescription, ItemValues.YellowGem); break; case ItemValues.RedGem: content[i] = new Gems(null, Gems.WhiteGemName, Gems.WhiteGemDescription, ItemValues.RedGem); break; } content[i].Count = Random.Range(2, 6); break; case 1: switch(CrystalPowder.PowderValues[Random.Range(0, CrystalPowder.PowderValues.Length)]) { case ItemValues.PentanitePowder: content[i] = new CrystalPowder(null, ItemValues.PentanitePowder); content[i].Count = Random.Range(4, 11); break; } break; case 2: content[i] = new RawGems(null); content[i].Count = Random.Range(1, 4); break; case 3: switch (CrystalRaw.RawValues[Random.Range(0, CrystalRaw.RawValues.Length)]) { case ItemValues.PentaniteRaw: content[i] = new CrystalRaw(null, ItemValues.PentaniteRaw); content[i].Count = Random.Range(3, 8); break; } break; } } (toInstantiate.GetComponent<MonoItem>().thisItem as ItemContainer).SetContent(content); Scene._grid[index].ItemValue = toInstantiate.GetComponent<MonoItem>().thisItem.ItemValue; return true; } return false; }
/// <summary> /// Takes gem and a list that needs to be fixed. /// Cycles through their x and y, seperating them into rows and columns /// Then if a match is detected over the minimum Match Requirement, then return true /// </summary> /// <param name="g"></param> /// <param name="toFix"></param> public void rowColumnMatchCheck(Gems g, List<Gems>toFix) { List<Gems> row = new List<Gems>(); List<Gems> column = new List<Gems>(); for(int i = 0; i < toFix.Count; i++) { if(g.XPos == toFix[i].XPos) { row.Add(toFix[i]); } if (g.YPos == toFix[i].YPos) { column.Add(toFix[i]); } } if(row.Count >= minimumMatchRequirement) { matchFound = true; for(int i = 0; i < row.Count; i++) { row[i].isMatched = true; } } else if(column.Count >= minimumMatchRequirement) { matchFound = true; for (int i = 0; i < column.Count; i++) { column[i].isMatched = true; } } }
public void SwapGems(Gems source) { // if there is no last gem selected, set it to the source if(last == null) { last = source; } // but, if there is a source, then last gem should be nulled as the player is unselecting it. else if(last == source) { last = null; } // else, figure out if the gem is neighbor else { // if the last gem is a neighbor of the currently selected gem, then allow the swap if (last.NeighboredGem(source) && canSwap) { g1 = last; g2 = source; // the first gem's source position is the last gem selected's position firstGemSourcePosition = last.transform.position; neighborGemSourcePosition = source.transform.position; // the transform is swapped last.transform.position = neighborGemSourcePosition; source.transform.position = firstGemSourcePosition; last.image = source.image; source.image = last.image; source.toggleSelection(); last.toggleSelection(); // for swap control canSwap = false; last = null; matchPossible = true; } else { last = source; //last.toggleSelection(); canSwap = true; } } }