public async Task <IActionResult> Create([Bind("Id,Title,ImagePath,Description,File")] GemstoneCreateViewModel viewModel, IFormFile image) { ModelState.Remove("User"); ModelState.Remove("UserId"); var user = await GetCurrentUserAsync(); if (ModelState.IsValid) { var gemstone = new Gemstone() { Title = viewModel.Title, Description = viewModel.Description, }; if (viewModel.File != null && viewModel.File.Length > 0) { var fileName = Path.GetFileName(viewModel.File.FileName); //getting path of actual file name var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images", fileName); //creating path combining file name w/ www.root\\images directory using (var fileSteam = new FileStream(filePath, FileMode.Create)) //using filestream to get the actual path { await viewModel.File.CopyToAsync(fileSteam); } gemstone.ImagePath = fileName; } gemstone.UserId = user.Id; _context.Add(gemstone); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", viewModel.UserId); return(View(viewModel)); }
private bool switch_flag = false; //是否在交换标志 // Use this for initialization void Start() { gemstonelist = new ArrayList(); matchedgemstonelist = new ArrayList(); audiosource = GetComponent <AudioSource>(); for (int rowindex = 0; rowindex < RowNumber; rowindex++) { ArrayList tmp = new ArrayList(); for (int colindex = 0; colindex < ColNumber; colindex++) { //GameObject gemstone = gemstones [Random.Range (0, gemstones.Length)]; //Gemstone c = Instantiate (gemstones [Random.Range (0, gemstones.Length)]) as Gemstone; Gemstone c = CreateGemstone(rowindex, colindex); tmp.Add(c); //宝石放到列中 } gemstonelist.Add(tmp); //每一列再放到行中 } //消除开始时出现的匹配宝石 if (CheckRow() || CheckCol()) { RemoveMatchedGemstone(); } //如果没有可以匹配的宝石,刷新一下 if (false == FindMatchableGemstone()) { Debug.LogError("Start No matchable gemstone!!! time=" + Time.time); StartCoroutine(RefreshGemstone()); } }
public void Select(Gemstone secondGem) { if (firstGem == null) //第一次鼠标点击宝石,设置第一次点击的宝石 { firstGem = secondGem; firstGem.sr.color = new Color(1, 1, 1, .5f); } else //第二次,交换宝石 { //只让数周围的宝石交换 if (Mathf.Abs(firstGem.rowIndex - secondGem.rowIndex) + Mathf.Abs(firstGem.columnIndex - secondGem.columnIndex) == 1) { Exchange(firstGem, secondGem); if (CheckMaches()) //如果匹配... { RemoveMaches(); } else //若不匹配 ,重新交换回来 { audio.PlayOneShot(swapClip); StartCoroutine(WaitToSwap(firstGem, secondGem)); } } else { audio.PlayOneShot(errorClip); } firstGem.sr.color = Color.white; firstGem = null; //重新更新第一次点击的宝石 } }
void RemoveMatches() //NOTE: HERE can get how many chain the match gets //how many match we get? //Debug.Log("Match NUM: " + matchesGemstone.Count); { Gemstone sample = matchesGemstone [0] as Gemstone; GemstoneType t = sample.gemstoneType; ///// //Modify container!! if (matchesGemstone.Count >= 4) { Debug.Log("REMOVE MATCHES " + matchesGemstone.Count); //Debug.Log (t.ToString()); priorSpawnInfo.Add(t); //Debug.Log ("in the list:" + priorSpawnInfo [0].ToString ()); } for (int i = 0; i < matchesGemstone.Count; i++) { Gemstone c = matchesGemstone[i] as Gemstone; //Debug.Log ("TYPE" + c.gemstoneType); RemoveGemstone(c); } matchesGemstone = new ArrayList(); StartCoroutine(WaitForCheckMatchesAgain()); }
//从二位数组中得到rol col 坐标的宝石 Gemstone GetGem(int row, int col) { ArrayList temp = GemArr[row] as ArrayList; Gemstone gem = temp[col] as Gemstone; return(gem); }
public Gemstone GetGemstone(int rowIndex, int columnIndex) //通过行号和列号,取得所对应位置的宝石 { ArrayList temp = gemstoneList [rowIndex] as ArrayList; Gemstone c = temp [columnIndex] as Gemstone; return(c); }
/// <summary> /// 在gemstone周围按照规则匹配 /// </summary> /// <param name="g">指定gemstone</param> private void Match(Gemstone g) { // 判断非空 if (g == null) { return; } // 判断横排 var rowGemstones = gemstoneList[g.rowIndex]; var tempHorizontal = new List <Gemstone> { g }; // 左边 AppendLess(rowGemstones, tempHorizontal, g.columnIndex); // 右边 AppendMore(rowGemstones, tempHorizontal, g.columnIndex); CheckAndCrush(tempHorizontal); // 判断竖排 var columnGemstones = gemstoneList.Select(t => t[g.columnIndex]).ToList(); var tempVertical = new List <Gemstone> { g }; // 上边 AppendLess(columnGemstones, tempVertical, g.rowIndex); // 右边 AppendMore(columnGemstones, tempVertical, g.rowIndex); CheckAndCrush(tempVertical); }
//選擇到寶石 public void Select(Gemstone c) { if (currentGemstone == null) { currentGemstone = c; currentGemstone.isSelected = true; Debug.Log("選了第1個"); return; } else { if (Mathf.Abs(currentGemstone.rowIndex - c.rowIndex) + Mathf.Abs(currentGemstone.columnIndex - c.columnIndex) == 1) { Debug.Log("選了第2個"); StartCoroutine(ExangeAndMatches(currentGemstone, c)); } else { GetComponent <AudioSource>().PlayOneShot(errorClip); Debug.Log("選了第2個,但超出範圍"); } currentGemstone.isSelected = false; currentGemstone = null; } }
private static void HandleSelectGemUpgrade(GameSession session, PacketReader packet) { long equipUid = packet.ReadLong(); byte slot = packet.ReadByte(); long itemUid = packet.ReadLong(); if (equipUid == 0) // this is a gemstone in the player's inventory { if (!session.Player.Inventory.Items.ContainsKey(itemUid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } session.Send(ItemSocketSystemPacket.SelectGemUpgrade(equipUid, slot, itemUid)); return; } // select gem mounted on a equipment if (!session.Player.Inventory.Items.ContainsKey(equipUid)) { session.Send(ItemSocketSystemPacket.Notice((int)ItemSocketSystemNotice.ItemIsNotInYourInventory)); return; } Gemstone gemstone = session.Player.Inventory.Items[equipUid].Stats.GemSockets[slot].Gemstone; if (gemstone == null) { return; } session.Send(ItemSocketSystemPacket.SelectGemUpgrade(equipUid, slot, itemUid)); }
public Gemstone GetGemstone(int row, int col) { ArrayList tmp = gemstonelist [row] as ArrayList; Gemstone c = tmp [col] as Gemstone; return(c); }
private IEnumerator ClearWithAnimation(Gemstone c) { //播放清除动画 Animator animator = c.GetComponent <Animator>(); if (animator != null) { animator.Play(clear.name); yield return(new WaitForSeconds(clear.length)); int type = c.gemstoneType; ++array[type]; if (type == 0) { scoreText[0].text = (LIFE_LENGTH - array[0]).ToString(); } else { scoreText[type].text = array[type].ToString(); } RemoveGemstone(c); //每删除一个宝石加10分 GameManager.score += 10; } }
private static PacketWriter WriteSockets(this PacketWriter pWriter, ItemStats stats) { pWriter.WriteByte(); pWriter.WriteByte(stats.TotalSockets); for (int i = 0; i < stats.TotalSockets; i++) { if (i >= stats.Gemstones.Count) { pWriter.WriteBool(false); // Locked continue; } pWriter.WriteBool(true); // Unlocked Gemstone gem = stats.Gemstones[i]; pWriter.WriteInt(gem.Id); pWriter.WriteBool(gem.OwnerId != 0); if (gem.OwnerId != 0) { pWriter.WriteLong(gem.OwnerId) .WriteUnicodeString(gem.OwnerName); } pWriter.WriteBool(gem.Unknown != 0); if (gem.Unknown != 0) { pWriter.WriteByte() .WriteLong(gem.Unknown); } } return(pWriter); }
public void Select(Gemstone c) { //Destroy (c.gameObject); //测试,让所点击的物体消失 if (currentGemstone == null) { currentGemstone = c; currentGemstone.isSelected = true; return; } else { if (Mathf.Abs(currentGemstone.rowIndex - c.rowIndex) + Mathf.Abs(currentGemstone.columnIndex - c.columnIndex) == 1) { StartCoroutine(ExangeAndMatches(currentGemstone, c)); } else { GetComponent <AudioSource>().PlayOneShot(errorClip); } currentGemstone.isSelected = false; currentGemstone = null; } }
public void Select(Gemstone c) { //iTween.MoveTo (c.gameObject, iTween.Hash ()); //Debug.Log ("x: " + c.rowIndex + ", y: " + c.columIndex); //Destroy (c.gameObject); if (currentGemstone == null) //select { currentGemstone = c; currentGemstone.isSelected = true; HighLightMoveRelatedGems(c); return; } else //confirm { if (Mathf.Abs(currentGemstone.rowIndex - c.rowIndex) == 0 || Mathf.Abs(currentGemstone.columIndex - c.columIndex) == 0) //check neighbour tiles //ExangeAndMatches(currentGemstone,c); { StartCoroutine(ExangeAndMatches(currentGemstone, c)); } else { this.gameObject.GetComponent <AudioSource>().PlayOneShot(erroeClip); } currentGemstone.isSelected = false; currentGemstone = null; } }
public void Select(Gemstone c) { //Destroy(c.gameObject); if (currentGemstone == null) { currentGemstone = c; currentGemstone.isSelected = true; return; } else { if ((Mathf.Abs(currentGemstone.rowIndex - c.rowIndex) + Mathf.Abs(currentGemstone.columIndex - c.columIndex)) == 1) { StartCoroutine(ExchangeAndMatches(currentGemstone, c)); } else { audio.PlayOneShot(errorClip); } currentGemstone.isSelected = false; currentGemstone = null; } }
public void Exchange(Gemstone c1, Gemstone c2) //寶石交換位置 { GetComponent <AudioSource>().PlayOneShot(swapClip); SetGemstone(c1.rowIndex, c1.columnIndex, c2); SetGemstone(c2.rowIndex, c2.columnIndex, c1); //交换c1,c2的行 int tempRowIndex; tempRowIndex = c1.rowIndex; c1.rowIndex = c2.rowIndex; c2.rowIndex = tempRowIndex; //交换c1,c2的列 int tempColumnIndex; tempColumnIndex = c1.columnIndex; c1.columnIndex = c2.columnIndex; c2.columnIndex = tempColumnIndex; //c1.UpdatePosition (c1.rowIndex, c1.columnIndex); //c2.UpdatePosition (c2.rowIndex, c2.columnIndex); c1.TweenToPostion(c1.rowIndex, c1.columnIndex); c2.TweenToPostion(c2.rowIndex, c2.columnIndex); Debug.Log("交換寶石位置囉~"); }
/// <summary> /// 得到宝石 /// </summary> /// <param name="_rowIndex"></param> /// <param name="_columIndex"></param> /// <returns></returns> public Gemstone GetGemstone(int _rowIndex, int _columIndex) { ArrayList temp = gemstoneList[_rowIndex] as ArrayList; Gemstone g = temp[_columIndex] as Gemstone; return(g); }
public void SetGemstone(int rowIndex, int columnIndex, Gemstone c) { //设备所对应列号和列号位置的宝石 ArrayList temp = gemstoneList[rowIndex] as ArrayList; temp[columnIndex] = c; }
//通過行列,取得寶石 public Gemstone GetGemstone(int rowIndex, int columnIndex) { ArrayList temp = gemstoneList [rowIndex] as ArrayList; Gemstone c = temp [columnIndex] as Gemstone; return(c); }
public void SelectGemstone(Gemstone c) { //Destroy (c.gameObject); if (true == switch_flag) { return; } if (currentgemstone == null) { currentgemstone = c; currentgemstone.IsGemstoneSelected(true); // = true; //currentgemstone.ShakeToPosition(); } else { if (1 == (Mathf.Abs(currentgemstone.RowIndex - c.RowIndex) + Mathf.Abs(currentgemstone.ColIndex - c.ColIndex))) //相邻的 { switch_flag = true; StartCoroutine(ExchangeAndMatcheGemstone(currentgemstone, c)); } else { audiosource.PlayOneShot(ErrorSound); } currentgemstone.IsGemstoneSelected(false); // = false; currentgemstone = null; } }
public Gemstone AddGemstone(int rowIndex, int columIndex, int type) { Gemstone stone = Instantiate(gemstone, transform) as Gemstone;// 生成宝石作为GameController子物体 stone.GetComponent <Gemstone>().CreateGemstoneBg(type); stone.GetComponent <Gemstone>().UpdatePosiImmi(rowIndex, columIndex); return(stone); }
public Gemstone CreateGemstone(int x, int y) { GemstoneSO randomSO = (GemstoneSO)_gemstoneSpawnTable.ChooseRandom(); Gemstone gemStone = new Gemstone(randomSO); gemStone.SetPosition(x, y); return(gemStone); }
//T檢測 bool T_Match(Gemstone c) { //c、第1種T型,腳向左 if (c.rowIndex < rowNum - 1 && c.rowIndex > 0 && c.columnIndex > 1) { if (GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex + 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex - 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex - 1).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex - 2).gemstoneType) { RemoveCross(c); Debug.Log("第1種T型,腳向左"); return(true); } } //c、第2種T型,腳向右 if (c.rowIndex < rowNum - 1 && c.rowIndex > 0 && c.columnIndex < 6) { if (GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex + 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex - 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex + 1).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex + 2).gemstoneType) { RemoveCross(c); Debug.Log("第2種T型,腳向右"); return(true); } } //c、第3種T型,正T if (c.rowIndex > 1 && c.columnIndex > 0 && c.columnIndex < columnNum - 1) { if (GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex - 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex - 2, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex - 1).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex + 1).gemstoneType) { RemoveCross(c); Debug.Log("第3種T型,正T"); return(true); } } //c、第4種T型,腳朝上 if (rowNum - 2 > c.rowIndex && c.columnIndex > 0 && c.columnIndex < columnNum - 1) { if (GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex + 1, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex + 2, c.columnIndex).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex - 1).gemstoneType&& GetGemstone(c.rowIndex, c.columnIndex).gemstoneType == GetGemstone(c.rowIndex, c.columnIndex + 1).gemstoneType) { RemoveCross(c); Debug.Log("第4種T型,腳朝上"); return(true); } } //如果都不是,那就不是T字型配對 return(false); }
public Gemstone AddRegularGemstone(int rowIndex, int columIndex) //生成宝石 { Gemstone c = Instantiate(gemstone) as Gemstone; c.transform.parent = this.transform; //生成宝石为GameController子物体 c.GetComponent <Gemstone>().RandomCreateGemstoneBg(); c.GetComponent <Gemstone>().UpdatePosition(rowIndex, columIndex); return(c); }
public Gemstone CreateGemstone(int rowindex, int colindex) { Gemstone c = Instantiate(gemstone) as Gemstone; c.transform.parent = this.transform; c.GetComponent <Gemstone>().CreateRandomGemstone(); c.GetComponent <Gemstone>().UpdatePosition(rowindex, colindex); return(c); }
//加入寶石 public Gemstone AddGemstone(int rowIndex, int columnIndex) { Gemstone c = Instantiate(gemstone) as Gemstone; c.transform.parent = this.transform; c.GetComponent <Gemstone>().RandomCreateGemstoneBg(); c.GetComponent <Gemstone>().UpdatePosition(rowIndex, columnIndex); return(c); }
/// <summary> /// Socket a gem in this socket. Returns true if socketed, false if the gem was rejected. /// </summary> /// <param name="stone"></param> /// <returns></returns> public bool Socket(Gemstone stone) { if (socketedGems.Contains(stone) || socketedGems.Count >= RequiredGems) { return(false); } this.socketedGems.Add(stone); return(true); }
//換成彩虹寶石 private void RainbowGem(int y, int x) { Gemstone temp = GetGemstone(y, x); temp.name = "RainbowGem"; Debug.Log(temp.name + " X=" + temp.columnIndex + "| Y=" + temp.rowIndex); temp.gemstoneType = 7;//第8種寶石背景是虹 temp.GetComponentInChildren <SpriteRenderer>().sprite = Rainbow_sprite; Debug.Log("換彩虹寶石~"); }
//換成黑寶石 private void BlackGem(int y, int x) { Gemstone temp = GetGemstone(y, x); temp.name = "BlackGem"; Debug.Log(temp.name + " X=" + temp.columnIndex + "| Y=" + temp.rowIndex); temp.gemstoneType = 8;//第9種寶石背景是黑 temp.GetComponentInChildren <SpriteRenderer>().sprite = Black_sprite; Debug.Log("換成黑色寶石~"); }
//删除匹配的寶石 void RemoveMatches() { for (int i = 0; i < matchesGemstone.Count; i++) { Gemstone c = matchesGemstone[i] as Gemstone; RemoveGemstone(c); } matchesGemstone = new ArrayList(); StartCoroutine(WaitForCheckMatchesAgain()); }