private void Update() { if (!usingAbility) { if (OVRInput.GetDown(handTrigger)) // When first pressing hand trigger { if (collectedTicTacs.Count < collectLocalPositions.Count) // Collecting { updateCollectArea = true; collectArea.SetActive(true); } else // Activating ability { abilityHandlerScript.ActivateAbility(collectedTicTacs); usingAbility = true; } } else if (OVRInput.GetUp(handTrigger)) // When letting go of hand trigger { if (collectedTicTacs.Count < collectLocalPositions.Count) // Collecting { Collider[] hitColliders = Physics.OverlapSphere(collectArea.transform.position, collectArea.transform.localScale.x / 2.0f, 1 << LayerMask.NameToLayer("TicTac")); for (int i = 0; i < hitColliders.Length && collectedTicTacCount < collectLocalPositions.Count; i++) { hitColliders[i].gameObject.layer = LayerMask.NameToLayer("Default"); Vector3 collectLocalPosition = collectLocalPositions.Dequeue(); collectLocalPositions.Enqueue(collectLocalPosition); TicTac ticTacScript = hitColliders[i].transform.parent.gameObject.GetComponent <TicTac>(); ticTacScript.StartCollectCoroutine(gameObject, containerOpeningTransform, collectSpeed, containerTransform, collectLocalPosition); collectedTicTacCount++; } collectArea.SetActive(false); updateCollectArea = false; } } if (OVRInput.GetDown(indexTrigger)) // When first pressing index trigger { if (collectedTicTacs.Count < collectLocalPositions.Count) // Collecting { collectArea.transform.localScale = collectArea.transform.localScale == smallCollectAreaLocalScale ? largeCollectAreaLocalScale : smallCollectAreaLocalScale; } else // Activating ability { abilityHandlerScript.ActivateAbility(collectedTicTacs); usingAbility = true; } } if (updateCollectArea) { RaycastHit raycastHit; if (Physics.Raycast(containerOpeningTransform.position, containerOpeningTransform.up, out raycastHit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Field"))) { collectArea.transform.position = raycastHit.point; } } } }
public int DeterminePlay(TicTac yourTicTac, Board board) { if (board.MakePlay(yourTicTac, 1)) { return(1); } else if (board.MakePlay(yourTicTac, 9)) { return(9); } else if (board.IsCenterSquareAvailable) { return(board.CenterSquare.Position.Id); } else if (board.MakePlay(yourTicTac, 3)) { return(3); } else if (board.MakePlay(yourTicTac, 4)) { return(4); } else if (board.MakePlay(yourTicTac, 8)) { return(8); } else { return(board.RandomSquare.Position.Id); } }
/* Takes in a tic tac's path route and instance ID, and updates the correct path. Will move tic tacs forward from queues * depending on where the removed tic tac was previously on the path. */ public void TicTacRemoved(SE.PathRoute removedPathRoute, SE.PathDistance removedPathDistance, int removedInstanceID) { Path removedPath = (removedPathRoute == SE.PathRoute.Melee) ? meleePath : rangedPath; TicTac removedScript = removedPath.scriptDict[removedInstanceID]; if (removedPathDistance == SE.PathDistance.Close && removedPath.scriptDict.Count > pathLimits[0]) { TicTac firstMidScript = removedPath.GetFirstScript(SE.PathDistance.Mid); // Move first mid script up to close distance firstMidScript.CurrPathDistance = SE.PathDistance.Close; firstMidScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[0]) + removedPath.centers[0], 0.0f); if (removedPath.scriptDict.Count > pathLimits[1]) { TicTac firstFarScript = removedPath.GetFirstScript(SE.PathDistance.Far); // Move first far script up to mid distance firstFarScript.CurrPathDistance = SE.PathDistance.Mid; firstFarScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[1]) + removedPath.centers[1], 0.0f); } } else if (removedPathDistance == SE.PathDistance.Mid && removedPath.scriptDict.Count > pathLimits[1]) // Removed tic tac was far { TicTac firstFarScript = removedPath.GetFirstScript(SE.PathDistance.Far); // Move first far script up to mid distance firstFarScript.CurrPathDistance = SE.PathDistance.Mid; firstFarScript.StartAdvanceCoroutine((Random.insideUnitSphere * removedPath.radii[1]) + removedPath.centers[1], 0.0f); } removedPath.scriptDict.Remove(removedInstanceID); }
// Use this for initialization void Start() { mainGame = new TicTac(m_Player); for (int i = 1; i < 10; i++) { m_BoardImages[i - 1] = _Board.FindChild(i.ToString()).GetComponent <Image>(); m_BoardImages[i - 1].sprite = _Empty; } }
public void ConvertToArrayLocationTestHigh() { TicTac t = new TicTac(); int[] expected = new int[] { 2, 2 }; int[] actual = t.ConvertToArrayLocation("9"); CollectionAssert.AreEqual(expected, actual); }
public int DeterminePlay(TicTac yourTicTac, Board board) { var winningSquares = new List <List <Square> > { board.LeftToRightDiag, board.RightToLeftDiag, board.Col(1), board.Col(2), board.Col(3), board.Row(1), board.Row(2), board.Row(3) }; foreach (var squares in winningSquares) { var secretSauce = IsWinning(squares, yourTicTac); if (secretSauce.IsWinning) { return(secretSauce.WinningSquare.Position.Id); } } foreach (var squares in winningSquares) { var secretSauce = IsWinning(squares, IsOpponentWinning(yourTicTac)); if (secretSauce.IsWinning) { return(secretSauce.WinningSquare.Position.Id); } } if (!board.CenterSquare.HasTicOrTac()) { return(board.CenterSquare.Position.Id); } foreach (var squares in board.CornerSquares) { if (!squares.HasTicOrTac()) { return(squares.Position.Id); } } foreach (var squares in board.MiddleSquares) { if (!squares.HasTicOrTac()) { return(squares.Position.Id); } } return(board.RandomSquare.Position.Id); }
public void ConvertToArrayLocationTestOutOfBounds() { //What should happen when the user enters an invalid number (out of bounds of the map)? TicTac t = new TicTac(); int[] expected = new int[] { 2, 2 }; int[] actual = t.ConvertToArrayLocation("15"); CollectionAssert.AreEqual(expected, actual); }
public void ConvertToArrayLocationTestNonInt() { //This test is here to show you invalid input is not handled TicTac t = new TicTac(); int[] expected = new int[] { 2, 2 }; int[] actual = t.ConvertToArrayLocation("a"); CollectionAssert.AreEqual(expected, actual); }
private Dictionary <SE.Flavor, GameObject> ticTacPrefabDict; // Dictionary of tic tac prefabs, with their types as keys /* Takes in an tic tac flavor and a spawn amount, and spawns that many tic tacs of that flavor. Will only spawn up to the * far path limit. */ public void SpawnEnemies(SE.Flavor flavor, int spawnAmount) { if (!ticTacPrefabDict.ContainsKey(flavor)) { Debug.LogWarning("Tic Tac with flavor " + flavor + " doesn't exist."); return; } SE.PathRoute pathRoute = ticTacPrefabDict[flavor].GetComponent <TicTac>().PathRoute; Path path = (pathRoute == SE.PathRoute.Melee) ? meleePath : rangedPath; for (int i = 0; i < spawnAmount && pathLimits[2] - path.scriptDict.Count > 0; i++) { Vector3 spawnPosition = spawnPositions.Dequeue(); // Get spawn position float heightOffset = ticTacPrefabDict[flavor].transform.GetChild(0).localScale.y + (transform.position.y - (transform.localScale.y / 2.0f)); // Used to spawn object above field spawnPosition = V3E.SetY(spawnPosition, heightOffset); spawnPositions.Enqueue(spawnPosition); GameObject ticTac = Instantiate(ticTacPrefabDict[flavor], spawnPosition, Quaternion.identity); // Instantiate TicTac ticTacScript = ticTac.GetComponent <TicTac>(); ticTacScript.InitializeVariables(gameObject, collector); float delayTime = delayTimes.Dequeue(); // Get delay time delayTimes.Enqueue(delayTime); if (path.scriptDict.Count < pathLimits[0]) // Set path distance and start moving towards a new path position { ticTacScript.CurrPathDistance = SE.PathDistance.Close; ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[0]) + path.centers[0]), delayTime); path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript); } else if (path.scriptDict.Count < pathLimits[1]) { ticTacScript.CurrPathDistance = SE.PathDistance.Mid; ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[1]) + path.centers[1]), delayTime); path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript); } else // farPathLimit { ticTacScript.CurrPathDistance = SE.PathDistance.Far; ticTacScript.StartAdvanceCoroutine(((Random.insideUnitSphere * path.radii[2]) + path.centers[2]), delayTime); path.scriptDict.Add(ticTac.GetInstanceID(), ticTacScript); } } }
public void NewGame() { _LoadSaveMenu.SetActive(false); _EndGameMenu.SetActive(false); m_IsGameover = false; m_BoardState = new int[9] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; mainGame = new TicTac(m_Player); m_IsXTurn = true; for (int i = 1; i < 10; i++) { m_BoardImages[i - 1].sprite = _Empty; } Debug.Log("You are player " + m_Player); if (m_Player == -1) { StartCoroutine(WaitForCPU()); } }
public bool MakeMove(int positionId, TicTac move) { var isValidMove = false; foreach (var square in Squares) { if (square.Position.Id != positionId) { continue; } if (!square.isChecked()) { square.TicTac = move; isValidMove = true; _moveCount = _moveCount + 1; break; } } return(isValidMove); }
private TicTac ticTacScript; // Caching the tic tac script private void Awake() { ticTacScript = transform.parent.GetComponent <TicTac>(); }
public bool Load(int slot) { _EndGameMenu.SetActive(false); _LoadSaveMenu.SetActive(false); string loaded = ""; switch (slot) { case 1: if (PlayerPrefs.HasKey("TicTac1")) { loaded = PlayerPrefs.GetString("TicTac1"); } else { return(false); } break; case 2: if (PlayerPrefs.HasKey("TicTac2")) { loaded = PlayerPrefs.GetString("TicTac2"); } else { return(false); } break; case 3: if (PlayerPrefs.HasKey("TicTac3")) { loaded = PlayerPrefs.GetString("TicTac3"); } else { return(false); } break; } m_BoardState = loaded.Split(';').Select(n => System.Convert.ToInt32(n)).ToArray(); int turncount = 0; for (int i = 0; i < 9; i++) { if (m_BoardState[i] == 0) { m_BoardImages[i].sprite = _Empty; } else if (m_BoardState[i] == 1) { m_BoardImages[i].sprite = _X; turncount++; } else { m_BoardImages[i].sprite = _O; turncount++; } } if (turncount % 2 == 0) { m_IsXTurn = true; } else { m_IsXTurn = false; } mainGame = new TicTac(m_Player, m_BoardState); m_IsGameover = false; return(true); }
protected void btnTicTacImport_Click(object sender, EventArgs e) { //var plist = new List<TicTacEntity>(); // NEED 1 (first) List <string> import_successList = new List <string>(); if (txtImportDate.Text != "" && txtImportDate.Text != null) { if (FileUpload1.HasFile) { if (Path.GetExtension(FileUpload1.FileName) == ".xlsx") { #region "Multi Sheet or Sheet by Sheet Import" (third thinking => ) using (ExcelPackage ex_package = new ExcelPackage(FileUpload1.FileContent)) { int ws_count = ex_package.Workbook.Worksheets.Count(); // if (ws_count == 1) //for (int i = 1; i <= ws_count; i++) 'Edited for (int i = 1; i <= ws_count; i++) { //var probes_list = new List<TicTacEntity>(); var sheet_name = ex_package.Workbook.Worksheets[i].Name; var center = ddlCenterName.SelectedValue.ToString(); #region "For Tic Tac" if (sheet_name.ToString().Trim() == "TIC TAC usage") //sheet_name == "Probes" { var tictacs = new TicTac().FindByImportedDateAndCenter(GeneralUtility.ConvertSystemDateStringFormat(txtImportDate.Text.Trim()), center); if (tictacs.Count() == 0) { var tictacs_list = new List <TicTacEntity>(); ExcelWorksheet tictac_workSheet = ex_package.Workbook.Worksheets[i]; // probes_workSheet.DeleteRow(1); if (tictac_workSheet.Dimension != null) { TicTacs_BindBusiness(tictacs_list, tictac_workSheet, center); #region Save Tic Tacs TicTac itemBusiness = new TicTac(); using (TransactionScope Scope = new TransactionScope()) { try { //probes_list.RemoveAt(0); foreach (var v in tictacs_list) { itemBusiness.Entity = v; itemBusiness.Save(); } Scope.Complete(); import_successList.Add("Tic Tacs Import Successfully!\n"); MessageBox.MessageShow(this.GetType(), "Tic Tacs Import Successfully!.", ClientScript); } catch (Exception ex) { Response.Redirect("error.aspx"); throw ex; } } #endregion } } else { MessageBox.MessageShow(this.GetType(), "This Excel File has already been Imported!", ClientScript); } } #endregion } } #endregion } } } else { MessageBox.MessageShow(this.GetType(), "Please Choose Import Date!.", ClientScript); } }
void CreateTicTacCapsule() { TicTac tt = Instantiate(TicTacPrefab, transform.position, Quaternion.identity).GetComponent <TicTac>(); tt.hive = this; }
private TicTacSecretSauce IsWinning(IEnumerable <Square> squares, TicTac valueToCheck) { var output = new TicTacSecretSauce { IsWinning = false }; if (squares.Count() != 3) { return(output); } var square1 = squares[0]; var square2 = squares[1]; var square3 = squares[2]; if (square1.HasTicOrTac() && square2.HasTicOrTac() && square3.HasTicOrTac()) { return(output); } var emptyCount = 0; if (!square1.HasTicOrTac()) { emptyCount++; } if (!square2.HasTicOrTac()) { emptyCount++; } if (!square3.HasTicOrTac()) { emptyCount++; } if (emptyCount != 1) { return(output); } if (square1.TicTac == valueToCheck && square2.TicTac == valueToCheck && !square3.HasTicOrTac()) { output.IsWinning = true; output.WinningSquare = square3; return(output); } if (square2.TicTac == valueToCheck && square3.TicTac == valueToCheck && !square1.HasTicOrTac()) { output.IsWinning = true; output.WinningSquare = square1; return(output); } if (square1.TicTac == valueToCheck && square3.TicTac == valueToCheck && !square2.HasTicOrTac()) { output.IsWinning = true; output.WinningSquare = square2; return(output); } return(output); }
private TicTac IsOpponentWinning(TicTac myTic) { return(myTic == TicTac.X ? TicTac.O : TicTac.X); }
protected void btnExport_Click(object sender, EventArgs e) { fromDate = GeneralUtility.ConvertSystemDateStringFormat(txtFromDate.Text); toDate = GeneralUtility.ConvertSystemDateStringFormat(txtToDate.Text); string fromYear = fromDate.Substring(0, 4); string fromMonth = fromDate.Substring(4, 2); string toYear = toDate.Substring(0, 4); string toMonth = toDate.Substring(4, 2); if (fromYear == toYear && fromMonth == toMonth) { Month1 = fromYear + fromMonth; Month2 = string.Empty; FromDate2 = string.Empty; ToDate2 = string.Empty; } else { //string comparedate = new AccuracyPercentage().FindMonthAndYear(fromDate); //string comparemonth = comparedate.Substring(3, 2); //string compareyear = comparedate.Substring(6, 4); string comparedate = new AccuracyPercentage().FindMonthAndYear(fromDate); DateTime fromtime = DateTime.Parse(comparedate); var date = GeneralUtility.ConvertSystemDateStringFormat(fromtime); string comparemonth = date.Substring(4, 2); string compareyear = date.Substring(0, 4); if (compareyear != toYear || comparemonth != toMonth) { MessageBox.MessageShow(this.GetType(), "Please Check FromDate and ToDate!.", ClientScript); return; } Month1 = fromYear + fromMonth; Month2 = compareyear + comparemonth; FromDate2 = Month2 + "01"; ToDate2 = toDate; toDate = new AccuracyPercentage().FindLastDayOfMonth(fromDate); } //(branchcode, Month1, 7500, 96, fromDate, toDate, Month2, FromDate2, ToDate2); var branchcode = string.Empty; if (ddlCenterName.SelectedItem.Value != "All") { branchcode = ddlCenterName.SelectedValue.ToString(); } #region "For TicTac" var tictacslist = new TicTac { Criteria = new PPP_Project.Criteria.ImportJobsCriteria { CenterName = branchcode, FromDate = fromDate, ToDate = toDate, Month1 = Month1, Month2 = Month2, FromDate2 = FromDate2, ToDate2 = ToDate2, } }.FindByCriteriaDenominatorForTicTacs(); DataTable attTbl = new DataTable(); attTbl.Clear(); attTbl.Columns.Clear(); var result = (from dd in tictacslist orderby dd.Center select dd).ToList(); // Convert to DataTable. DataTable table = ConvertToDataTable(result); DataTable finalProbesdt = SupressEmptyColumnsForDenominator(table); var yrm = GeneralUtility.ConvertSystemDateStringFormat(txtFromDate.Text.Trim()); int yr = Convert.ToInt32(yrm.Substring(0, 4).ToString()); int mth = Convert.ToInt32(yrm.Substring(4, 2).ToString()); DateTime date1 = new DateTime(yr, mth, 1); var mm = date1.ToString("MMMM"); var yy = date1.ToString("yy"); if (result.Count().Equals(0)) { MessageBox.MessageShow(GetType(), "No Export Data.!", ClientScript); } else { var fileName = "tictacslist_" + mm + "'" + yy + ".xlsx"; int count = 0; Response.Clear(); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; //Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("Probes_List_Export.xlsx", System.Text.Encoding.UTF8)); this.Response.AddHeader( "content-disposition", string.Format("attachment; filename={0}", fileName)); ExcelPackage pkg = new ExcelPackage(); using (pkg) { ExcelWorksheet ws = pkg.Workbook.Worksheets.Add("Probes"); ws.Cells["A1"].LoadFromDataTable(finalProbesdt, true); #region "No need region" using (ExcelRange rng = ws.Cells[1, 1, 1, finalProbesdt.Columns.Count]) { rng.Style.Font.Bold = true; //Set Pattern for the background to Solid rng.Style.Fill.PatternType = ExcelFillStyle.Solid; //Set color to dark blue rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189)); // rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(122,160,205)); rng.Style.Font.Color.SetColor(System.Drawing.Color.White); } #endregion if (result.Count() > 0) { count = result.Count() + 2; } pkg.Workbook.Worksheets.FirstOrDefault().DefaultColWidth = 20; pkg.Workbook.Worksheets.FirstOrDefault().Row(1).Height = 25; var modelTable = pkg.Workbook.Worksheets.FirstOrDefault().Cells[ws.Dimension.Start.Row, 1, ws.Dimension.Start.Row + table.Rows.Count, table.Columns.Count]; //+ (count - 1) var border = modelTable.Style.Border.Top.Style = modelTable.Style.Border.Left.Style = modelTable.Style.Border.Right.Style = modelTable.Style.Border.Bottom.Style = ExcelBorderStyle.Thin; pkg.Workbook.Properties.Title = "Attempts"; this.Response.BinaryWrite(pkg.GetAsByteArray()); this.Response.End(); } } #endregion // End Probes }