public ResultSvc <Entity.Camp> CreateCamp(Entity.Camp camp) { var result = new ResultSvc <Entity.Camp>(camp); try { if (!Camps.Items.Any(x => x.Name == camp.Name.Trim() && x.CampCategoryId == camp.CampCategoryId)) { camp.Name = camp.Name?.Trim(); camp.Description = camp.Description?.Trim(); camp.OrganizationalInformation = camp.OrganizationalInformation?.Trim(); camp.Schedule = camp.Schedule?.Trim(); camp.UserCreatedId = Context.HttpContext.User.GetUserId(); Camps.Add(camp); } else { result.Errors.Add("Tábor se stejnými údaji již existuje!"); } } catch (Exception e) { Logger.LogError(e.Message); } return(result); }
//棋盤初始化 private void ChessBoardInitialize(int num) { //查找棋譜資料裡是否有相應編號 for (int i = 0; i < boardRecordData.m_data.Count; i++) { if (boardRecordData.m_data[i].number == num) { break; //找到相應編號後繼續程序 } if (i == boardRecordData.m_data.Count) { throw new System.Exception("[ERROR]棋譜資料內無相應編號"); } } //棋盤配置 for (int i = 0; i < boardRecordData.m_data[num].boardRecord.Count; i++) { AnimalChessName _chessName = boardRecordData.m_data[num].boardRecord[i].chessName; //取得棋子名稱 Vector2 _pos = boardRecordData.m_data[num].boardRecord[i].pos; //取得棋子位置 Camps _camps = boardRecordData.m_data[num].boardRecord[i].camps; //取得棋子陣營 bool _isKing = boardRecordData.m_data[num].boardRecord[i].isKing; //是否為王 ChessboardManager.Instance.CreateChess(_chessName, ChessboardManager.Instance.cellsBoard[(int)_pos.x, (int)_pos.y], _camps, _isKing); } }
public ActionResult Create(HttpPostedFileBase file, Camps camps) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { var fileName = ""; var randomFile = ""; var uploadDir = "~/Content/Images/CampsImg"; System.IO.Directory.CreateDirectory(Server.MapPath(uploadDir)); fileName = file.FileName; string extension = Path.GetExtension(file.FileName); randomFile = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + extension; var filePath = Path.Combine(Server.MapPath(uploadDir), randomFile); file.SaveAs(filePath); camps.Image = randomFile; camps.CreatedBy = User.Identity.GetUserId(); camps.CreatedOn = DateTime.UtcNow.AddHours(5); db.Camps.Add(camps); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(camps)); }
public CampsResult AddCamps(CampDomain camp) { var campResult = CampsResult.Create(camp); Camps.Add(campResult); return(campResult); }
public ActionResult DeleteConfirmed(long id) { Camps camps = db.Camps.Find(id); db.Camps.Remove(camps); db.SaveChanges(); return(RedirectToAction("Index")); }
//設置棋子於指定位置 //[input] name=棋子名稱 / pos=位置 / player=玩家陣營(True=正面方/False=反面方) / isKing=是否為王 public void CreateChess(AnimalChessName name, CellBehavior cell, Camps player, bool isKing) { GameObject chessGo = Instantiate(chessPrefab, cell.GetComponent <RectTransform>()); //創建指定的棋子物件 ChessBehavior ChessScript = chessGo.GetComponent <ChessBehavior>(); //取得棋子腳本 ChessScript.ChessInitialize(Dict_ChessAttribute[name], player, isKing); //套用棋子屬性設定 cell.chessScript = ChessScript; //將棋子腳本註冊至所在的棋格上 }
//遊戲流程控制 private IEnumerator Cor_MainProcess(bool isAwake, Camps firstPlayer, int boardRecord) { if (isAwake) { yield return(StartCoroutine(Cor_BuildEnvironment())); //遊戲初運行時, 先建置環境 } yield return(StartCoroutine(Cor_GameInitialize(firstPlayer, boardRecord))); //遊戲初始化 StartCoroutine(Cor_GameStart()); //遊戲程序 }
//---------------------------------------------------------------------------------------------------------------------- //呼叫玩家勝利視窗 public void CallWinningWindow(Camps p) { winText.text = p.ToString() + " 獲勝!!"; winnerPanel.SetActive(true); Text bt = resetGameButton.gameObject.GetComponentInChildren <Text>(); bt.text = "重置遊戲"; resetGameButton.onClick.AddListener(GameController.Instance.ResetGame); }
public ActionResult Edit(Camps camps) { if (ModelState.IsValid) { db.Entry(camps).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(camps)); }
/// <summary> /// 初始化卡牌 /// </summary> /// <param name="card">卡牌信息</param> /// <param name="localCamp">卡牌所在阵营</param> public void Init(CardMsg card, Camps localCamp) { this.atk = card.Atk; this.maxHp = card.MaxHp; this.curHp = card.MaxHp; this.def = card.Def; this.speed = card.Speed; this.bornPos = card.BornPos; this.camp = localCamp; }
public IHttpActionResult PostCamps(Camps camps) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } campServices.AddCamp(camps); return(Ok(camps)); // return CreatedAtRoute("DefaultApi", new { id = camps.Id }, camps); }
public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Camps camps = db.Camps.Find(id); if (camps == null) { return(HttpNotFound()); } return(View(camps)); }
public int Add(Camps camp) { var existingCamp = _context.Camps.FirstOrDefault(camps => camps.Title.ToUpper() == camp.Title.ToUpper()); if (existingCamp == null) { return(0); } else { _context.Camps.Add(camp); var result = _context.SaveChanges(); return(result); } }
/// <summary> /// 初始化类。 /// </summary> /// <param name="name">角色姓名。一经输入不变动。</param> /// <param name="camp">角色阵营。一经输入不变动。</param> /// <param name="location">角色出生的地理位置。</param> /// <param name="attribute">角色的自定义属性。</param> public Character(string name, Camps camp, Locations location, params string[] attribute) { CharacterName = name; Camp = camp; Location = location; IsAlive = false; CustomAttribute = new Dictionary <string, string>(); if (attribute != null) { foreach (string att in attribute) { CustomAttribute.Add(att, ""); } } }
//加入打入預備棋 public void AddDropPawnChess(ChessBehavior originChess, Camps changeTo) { GameObject cellGo = Instantiate(ChessboardManager.Instance.cellPrefab, this.transform); CellBehavior cell = cellGo.GetComponent <CellBehavior>(); dropPawnCells.Add(cell); //加入打入預備棋格物件 cell.cTag = CellTag.打入預備格; //設定格子類型 cell.pos = new Vector2(-100, -100); //設定格子位置 AutoLayout(); //自動調整尺寸 ChessboardManager.Instance.Move(originChess, cell, false); //將棋子移動到打入預備格 originChess.ChessInitialize(ChessboardManager.Instance.Dict_ChessAttribute[originChess.GetAttribure.dropPawnChess], changeTo, originChess.isKing); //若棋子被吃掉後會改變型態, 則更新棋子狀態 }
public IHttpActionResult PutCamps(Camps camp) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = campServices.UpdateCamp(camp); if (!result) { return(NotFound()); } return(Ok(camp)); //return StatusCode(HttpStatusCode.NoContent); }
public async Task <IActionResult> PutCamps(long id, Camps model) { var startDate = model.StartDate; var endDate = model.EndDate; var campsCheck = await _context.Camps.FirstOrDefaultAsync(x => x.Id == id); if (model != null) { campsCheck.StartDate = startDate; campsCheck.EndDate = endDate; _context.Update(campsCheck); await _context.SaveChangesAsync(); return(Ok(campsCheck)); } return(BadRequest("Something went wrong, could not update the Database")); }
} //取得棋子屬性 //------------------------------------------------------------------------------------------------------------------- //棋子初始化 public void ChessInitialize(ChessAttribute _attribute, Camps player, bool _isKing) { attribute = _attribute; //設定棋子屬性 //this.name = player.ToString() + " / " + _attribute.chessName.ToString(); //更改遊戲物件名稱 //初始化棋子尺寸 this.GetComponent <RectTransform>().sizeDelta = Vector2.zero; //初始化棋子圖示 animalIcon.sprite = attribute.animalIcon; //依照陣營變換棋子顏色 if (player == Camps.正面方) { frameImage.color = UIManager.Instance.playerColor; } else if (player == Camps.反面方) { frameImage.color = UIManager.Instance.enemyColor; } chessPlayer = player; //設定陣營 isKing = _isKing; //是否為王 //顯示可移動方向在棋子上 directionType = new List <DirectionType>(); //初始化可移動方向陣列 for (int i = 0; i < directionImages.Length; i++) //先關閉全部的可移動方向 { directionImages[i].gameObject.SetActive(false); } for (int i = 0; i < attribute.directionType.Count; i++) //設定可移動方向 { directionType.Add(attribute.directionType[i]); } if (player == Camps.反面方) //棋子為反面方時, 條件性翻轉可移動方向 { //需實施反轉的方向(一對) List <DirectionType[]> exchangeDir = new List <DirectionType[]>(); exchangeDir.Add(new DirectionType[] { DirectionType.左上, DirectionType.左下 }); exchangeDir.Add(new DirectionType[] { DirectionType., DirectionType. });
public IActionResult Camps() { httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Add("X-Api-Key", API_KEY); httpClient.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); string CAMPGROUND_API_PATH = BASE_URL + "/campgrounds?limit=5"; string campsData = ""; Camps camps = null; httpClient.BaseAddress = new Uri(CAMPGROUND_API_PATH); try { HttpResponseMessage response = httpClient.GetAsync(CAMPGROUND_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { campsData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!campsData.Equals("")) { // JsonConvert is part of the NewtonSoft.Json Nuget package camps = JsonConvert.DeserializeObject <Camps>(campsData); } } catch (Exception e) { // This is a useful place to insert a breakpoint and observe the error message Console.WriteLine(e.Message); } return(View(camps)); }
public async Task <ActionResult <Camps> > PostCamps(Camps model) { var startDate = model.StartDate; var endDate = model.EndDate; //var eventsId = model.Events; var name = model.Name; var eventsCheck = await _context.Camps.FirstOrDefaultAsync(x => x.Name == model.Name); if (model != null) { var Camp = new Camps() { Name = name, StartDate = startDate, EndDate = endDate, }; _context.Camps.Add(Camp); await _context.SaveChangesAsync(); return(Ok(Camp)); } return(BadRequest("Something Went wrong. Could not create")); }
public async Task Remove(FirebaseObject <Camp> camp) { Camps.Remove(camp); await CampDataStore.DeleteAsync($"camps/{camp.Key}"); }
/// <summary> /// 判断与目标阵营是否敌对 /// </summary> /// <param name="camp">目标阵营</param> /// <returns>是否敌对</returns> public bool IsHostileTo(Camps camp) { bool hostile = false; switch (camp) { case Camps.Justice: case Camps.Neutrality: if (this.Camp == Camps.Eval) { hostile = true; } break; case Camps.Eval: hostile = true; break; } return hostile; }
public bool AddCamp(Camps camp) { var result = campsRepository.Add(camp); return(result > 0); }
public bool UpdateCamp(Camps camp) { var result = campsRepository.Update(camp); return(result > 0); }
//遊戲初始化 private IEnumerator Cor_GameInitialize(Camps firstPlayer, int boardRecord) { PlayerController.Instance.isWorking = false; //玩家禁止操作 //UI重置 UIManager.Instance.CloseWinningWindow(); //關閉玩家勝利視窗 //遊戲過程參數重置 pcs_eat = false; pcs_levelUp = false; conquerPlayer = Camps.無; winPlayer = Camps.無; //滑鼠事件初始化 ChessboardManager.Instance.stayingCell = null; ChessboardManager.Instance.clickedCell = null; ChessboardManager.Instance.mouseUpCell = null; //清空棋子 CellBehavior[,] _cellsBoard = ChessboardManager.Instance.cellsBoard; //取得棋盤 //Debug.Log("----------------清空棋盤[Start]----------------"); for (int i = 0; i < _cellsBoard.GetLength(1); i++) //高度(Y軸) { for (int j = 0; j < _cellsBoard.GetLength(0); j++) //寬度(X軸) { if (_cellsBoard[j, i].chessScript != null) { //Debug.Log(string.Format("[{0}, {1}] : {2}", j, i, _cellsBoard[j, i].chessScript.gameObject.name)); GameObject go = _cellsBoard[j, i].chessScript.gameObject; _cellsBoard[j, i].chessScript = null; //清除腳本參考 Destroy(go); //清除物件 } } } //Debug.Log("----------------清空棋盤[End]----------------"); //Debug.Log("----------------清空打入預備區[Start]----------------"); DropPawnPanelManager[] dropPawnPanels = new DropPawnPanelManager[2] { ChessboardManager.Instance.dropPawnPanel_player1, ChessboardManager.Instance.dropPawnPanel_player2 }; for (int i = 0; i < dropPawnPanels.Length; i++) { for (int j = 0; j < dropPawnPanels[i].dropPawnCells.Count; j++) { Destroy(dropPawnPanels[i].dropPawnCells[j].chessScript.gameObject); //銷毀棋子 Destroy(dropPawnPanels[i].dropPawnCells[j].gameObject); //銷毀棋格 } dropPawnPanels[i].dropPawnCells = new List <CellBehavior>(); //List初始化 } //Debug.Log("----------------清空打入預備區[End]----------------"); ChessBoardInitialize(boardRecord); //棋盤初始化 nowPlayer = firstPlayer; //設定第一手玩家 yield return(new WaitForEndOfFrame()); PlayerController.Instance.isWorking = true; //玩家可操作 StepEnd = false; //玩家下完棋狀態設為"尚未"(false) }
/// <summary> /// 获取目标索引 /// </summary> /// <param name="speedItemList">在场单位列表(OrderBySpeed)</param> /// <param name="radarType">搜索方式</param> /// <param name="selfCamp">本方阵营</param> /// <param name="selfPos">当前单位的位置</param> /// <returns></returns> public static int GetTargetIndex(List <DataManager.SpeedItem> speedItemList, RadarType radarType, Camps selfCamp, int selfPos) { int posAdjust_Y = -1 * DataBase.cardPos[selfPos].y; DataBase.Pos targetPos = new DataBase.Pos(); for (int i = 0; i < 2; i++) { for (int j = 0; j < 7; j++) { //设置目标的坐标-前排优先 int posX = DataBase.cardPos[selfPos].x + front_first[i, j, 0]; int posY = DataBase.cardPos[selfPos].y + front_first[i, j, 1] + posAdjust_Y; targetPos.set(posX, posY); Console.WriteLine("posX: " + posX + " posY: " + posY); //获取目标索引 for (int s = 0; s < speedItemList.Count; s++) { if (speedItemList[s].card.BornPos == DataBase.GetPosIndex(targetPos)) { if (speedItemList[s].camp != selfCamp) { return(s); } } } } } return(-1); }