public async Task <PlayBook> CreateUpdateTeamPlayBook(PlayBook newPlayBook) { return(await new RestHelper().Post <PlayBook>($"api/PlaybookManagement/CreatePlaybook", newPlayBook)); }
public async Task <ActionResult> SavePlay(string teamId, Models.TeamManagement.Play play) { var viewModel = new TeamViewModel(); play.TeamId = teamId; await viewModel.Load(teamId); if (Request.Form["PlaybookType"] == "Offense") { if (viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]) != null) { play.PlaybookId = viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]).Id; } else { PlayBook newPlaybook = new PlayBook(); newPlaybook.TeamId = teamId; newPlaybook.PlaybookType = new PlaybookTypes { Name = "Offense", FriendlyName = "Offense" }; var playBookResult = await viewModel.CreateUpdateTeamPlayBook(newPlaybook); play.PlaybookId = playBookResult.Id; } } else if (Request.Form["PlaybookType"] == "Defense") { if (viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]) != null) { play.PlaybookId = viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]).Id; } else { PlayBook newPlaybook = new PlayBook(); newPlaybook.TeamId = teamId; newPlaybook.PlaybookType = new PlaybookTypes { Name = "Defense", FriendlyName = "Defense" }; var playResult = await viewModel.CreateUpdateTeamPlayBook(newPlaybook); play.PlaybookId = playResult.Id; } } else if (Request.Form["PlaybookType"] == "Special Team") { if (viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]) != null) { play.PlaybookId = viewModel.Team.Playbooks.FirstOrDefault(x => x.PlaybookType.Name == Request.Form["PlaybookType"] || x.PlaybookType.FriendlyName == Request.Form["PlaybookType"]).Id; } else { PlayBook newPlaybook = new PlayBook(); newPlaybook.TeamId = teamId; newPlaybook.PlaybookType = new PlaybookTypes { Name = "Special Team", FriendlyName = "Special Team" }; var playResult = await viewModel.CreateUpdateTeamPlayBook(newPlaybook); play.PlaybookId = playResult.Id; } } play.RecommendedPlays = Request.Form["RecommendedPlaysHidden"].Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new RecommendedPlay { PlayId = x }).ToList(); play.TeamName = viewModel.Team.Name; play.OffenseFormation.Name = play.OffenseFormation.FriendlyDisplay; play.DefenseFormation = new Models.TeamManagement.DefenseFormation(); play.DefenseFormation.Name = "Defense"; play.DefenseFormation.FriendlyDisplay = "Defense"; play.DefenseFormation.Id = 1; if (ModelState.IsValid) { if (Request.Files.Count > 0) { if (Request.Files.AllKeys.Contains("filepreview")) { var file = Request.Files["filepreview"]; MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); byte[] data = target.ToArray(); if (data.Length > 0) { play.PreviewUrl = await viewModel.UploadPreview(viewModel.Team.Name, "0", file.FileName, data, file.ContentLength, "UploadPreviewFiles", file.ContentType); } } if (Request.Files.AllKeys.Contains("file")) { var file = Request.Files["file"]; MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); byte[] data = target.ToArray(); if (data.Length > 0) { play.SvgUrl = await viewModel.UploadPreview(viewModel.Team.Name, "0", file.FileName, data, file.ContentLength, "uploadedFile", file.ContentType); } } } if (await viewModel.SavePlay(play)) { TempData["ErrorMessage"] = "New play has been added to team"; } else { TempData["ErrorMessage"] = "There is some problem in adding play to team"; } } else { TempData["ErrorMessage"] = "Please review fields"; } ActionResult result; result = RedirectToAction("Library", new { teamId = teamId }); return(await Task.FromResult(result)); }
// Update is called once per frame void Update() { timer += Time.deltaTime * spedUpTime; if (timer >= steps && currentZone < 50) { string actionText = ""; PlayOutput play = PlayBook.ZagaToVol(teams[0]); if (play.hasNext) { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " PASSOU da ZAGA para a VOLANCIA"; play = Play1(play.receiver); if (play.success) { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " PASSOU da VOLANCIA para o MEIO"; play = Play2(teams[0], play.receiver); if (play.success) { actionText += "\n" + play.debugText; if (!play.jump) { play = Play3(play.receiver); if (play.success) { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " passou da ENTRADA DA AREA para DENTRO DA AREA"; play = Play4(play.receiver); actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " finalizou (" + play.playValue + ")"; } else { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " errou passe da ENTRADA DA AREA para DENTRO DA AREA"; } } else { play = Play4(play.receiver); actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " finalizou (" + play.playValue + ")"; } } else { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " errou o passe para a ENTRADA DA AREA"; } } else { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " errou o passe para o MEIO"; } } else { actionText += "\n[" + play.actor.pos + "]" + play.actor.name + " ERROU o passe na ZAGA"; } GameObject newTextObject = new GameObject(); newTextObject.AddComponent <Text>(); newTextObject.GetComponent <Text>().text = actionText; newTextObject.GetComponent <Text>().font = defaultFont; newTextObject.GetComponent <Text>().fontSize = 15; newTextObject.GetComponent <Text>().horizontalOverflow = HorizontalWrapMode.Overflow; newTextObject.GetComponent <Text>().verticalOverflow = VerticalWrapMode.Overflow; newTextObject.GetComponent <RectTransform>().anchorMin = new Vector2(0, 1); newTextObject.GetComponent <RectTransform>().anchorMax = new Vector2(0, 1); newTextObject.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 20f); newTextObject.GetComponent <RectTransform>().position = new Vector2(lastText.position.x, lastText.position.y - 100); // newTextObject.GetComponent<RectTransform>().offsetMin = new Vector2(0,0); //newTextObject.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0); newTextObject.transform.SetParent(viewport.transform); lastText = newTextObject.transform; timer = 0; currentZone++; } }