public bool IsDiagonalComplete(CellItem selectedIndex, int playerId, int consecutiveCount) { CellItem topLeft = GetCellForCorner(selectedIndex, Corners.TL); CellItem bottomRight = GetCellForCorner(selectedIndex, Corners.BR);; if (CellsBetweenPoints(topLeft, bottomRight, true) >= consecutiveCount) { if (IsDiagonalComplete_Internal(topLeft, bottomRight, playerId, consecutiveCount)) { return(true); } } CellItem bottomLeft = GetCellForCorner(selectedIndex, Corners.BL); CellItem topRight = GetCellForCorner(selectedIndex, Corners.TR); if (CellsBetweenPoints(bottomLeft, topRight, true) >= consecutiveCount) { if (IsDiagonalComplete_Internal(bottomLeft, topRight, playerId, consecutiveCount)) { return(true); } } return(false); }
public static Grid GetGrid(string representation) { Grid resultGrid = null; var lines = representation.Split('\r'); var enemies = lines[0].Split('|').Select(s => Enum.Parse(typeof(CellColor), s)).Cast <CellColor>(); var weakSpot = int.Parse(lines[1]); var gridLines = lines.Skip(2).ToList(); for (int i = 0; i < gridLines.Count(); i++) { var cellLine = gridLines[i].Split('|'); for (int j = 0; j < cellLine.Count(); j++) { if (resultGrid == null) { resultGrid = new Grid(cellLine.Count(), gridLines.Count()) { WeakSlot = weakSpot }; var ei = 0; foreach (var e in enemies) { resultGrid._enemies[ei] = e; ei++; } } resultGrid[j, i] = CellItem.Parse(cellLine[j].Trim('\r', '\n', ' ')); } } return(resultGrid); }
private CellItem ManageEat(CellItem cell) { var toDrops = new List <Guid>(); foreach (var other in _data.GetAll()) { if (cell.Id != other.Id && cell.Position.DistanceSqrt(other.Position) > other.R * other.R && cell.Position.DistanceSqrt(other.Position) < cell.R * cell.R) { cell.Mass += other.Mass; toDrops.Add(other.Id); } } foreach (var key in toDrops) { _data.DeleteOne(key); } foreach (var key in toDrops) { Drop(key); } return(cell); }
private bool MoveTo(Guid id, Point position) { CellItem cell = _data.GetOne(id); bool has = cell.Id != default(Guid); if (has && position.Length() > 0) { Point direction = position; Point one = direction / direction.Length(); CellItem cellNew = cell; cellNew.Position += one * cell.Speed; if (cellNew.Position.X > Size.X / 2 || cellNew.Position.X < -Size.X / 2) { cellNew.Position.X = cell.Position.X; } if (cellNew.Position.Y > Size.Y / 2 || cellNew.Position.Y < -Size.Y / 2) { cellNew.Position.Y = cell.Position.Y; } cellNew = ManageEat(cellNew); _data.UpdateOneRP(id, cellNew.R, cellNew.Position); } return(has); }
public void SetItem(CellItem _item) { var oldItem = item; item = _item; g.map.Trigger(Channel.Map.SetCellItem, this, oldItem); }
private static void DrawCell(Graphics graph, CellItem cell) { var brush = new SolidBrush(GetCellColor(cell.Tag)); graph.FillRectangle(brush, cell.Position.X * 60, cell.Position.Y * 60, 60, 60); graph.DrawRectangle(new Pen(Color.Black, 1), cell.Position.X * 60, cell.Position.Y * 60, 60, 60); Pen pen = new Pen(Color.Black, 3); switch (cell.Type) { case CellType.Dragon: PointF[] points = new PointF[5]; points[0] = new PointF(cell.Position.X * 60 + 30, cell.Position.Y * 60 + 10); points[1] = new PointF(cell.Position.X * 60 + 50, cell.Position.Y * 60 + 30); points[2] = new PointF(cell.Position.X * 60 + 30, cell.Position.Y * 60 + 50); points[3] = new PointF(cell.Position.X * 60 + 10, cell.Position.Y * 60 + 30); points[4] = new PointF(cell.Position.X * 60 + 30, cell.Position.Y * 60 + 10); graph.DrawLines(pen, points); break; case CellType.Crystal: graph.DrawEllipse(pen, cell.Position.X * 60 + 15, cell.Position.Y * 60 + 15, 30, 30); break; } }
protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { cv.ApplyFilter("Id", Convert.ToInt32(e.Row.DataKey), HyperCatalog.Business.CollectionView.FilterOperand.Equals); TemplatedColumn col = (TemplatedColumn)e.Row.Cells.FromKey("nDelay").Column; CellItem cellItem = (CellItem)col.CellItems[e.Row.Index]; DropDownList ddDelay = (DropDownList)cellItem.FindControl("ddDelay"); for (int i = 0; i < delays.Length; i++) { ddDelay.Items.Add(new ListItem(delays[i], i.ToString())); } HyperCatalog.Business.UserNotification obj = cv.Count == 1 ? (HyperCatalog.Business.UserNotification)cv[0] : null; col = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column; cellItem = (CellItem)col.CellItems[e.Row.Index]; CheckBox cb = (CheckBox)cellItem.FindControl("g_sd"); cb.Checked = obj != null; bool allowInAdv = (bool)e.Row.Cells.FromKey("AllowNotificationInAdvance").Value; if (allowInAdv) { //the user has checked this notification ddDelay.SelectedIndex = obj != null?Convert.ToInt32(obj.Delay) : 0; } else { ddDelay.Items.Clear(); ddDelay.Items.Add(new ListItem("Instant", "-1")); } //allow offset editing only if AllowNotificationInAdvance ddDelay.Enabled = allowInAdv; cv.RemoveFilter(); }
protected void Swap(CellItem item1, int newPosX, int newPosY) { var position1 = item1.Position; var position2 = new CellPosition(newPosX, newPosY); var tmp = item1.Parent[position2]; item1.Parent[position2] = item1; item1.Parent[position1] = tmp; }
/// <summary> /// Find the closest cell to a given point that matches the specified requirements. /// </summary> /// <param name="grid">The grid.</param> /// <param name="start">The start point.</param> /// <param name="match">The function representing the requirements.</param> /// <param name="discard">The function that determines if a cell should be discarded, e.g. blocked cells.</param> /// <returns>The closest match or null if no cell is found.</returns> public Cell ClosestMatch(IGrid grid, Vector3 start, Func <Cell, bool> match, Func <Cell, bool> discard) { var startCell = grid.GetCell(start, true); _set.Add(startCell); var refPos = start; var curCell = startCell; var current = new CellItem { cell = startCell, priority = 0f }; while (true) { if (match(curCell)) { Reset(); return(curCell); } var count = curCell.GetNeighbours(_buffer); for (int i = 0; i < count; i++) { var n = _buffer[i]; if (!_set.Add(n)) { continue; } if (!discard(n)) { var item = new CellItem { cell = n, priority = current.priority + (n.position - refPos).sqrMagnitude }; _queue.Add(item); } } if (_queue.count == 0) { break; } current = _queue.Remove(); curCell = current.cell; refPos = curCell.position; } Reset(); return(null); }
private CellItem CreateNew(Point size, bool small) { var cell = CellItem.CreateRandom(size); if (small) { cell.Mass /= 3; } cell.Id = _data.AddOne(cell); return(cell); }
private bool Push(Guid id) { CellItem cell = _data.GetOne(id); var has = cell.Id != Guid.Empty; if (has) { _cellHub.Clients.All.PushCell(cell); } return(has); }
void RestartGame() { for (int x = 0; x < m_GameGridComponent.GetRowLength(); ++x) { for (int y = 0; y < m_GameGridComponent.GetColLength(); ++y) { CellItem cellItem = m_GameGridComponent.GetGridCell(x, y); GetCellGem(cellItem).Restart(); } } isGameOver = false; }
public IEnumerator ExecuteAi() { yield return(model.awaitSec); CalculateWeightOfCells(); CellItem cell = null; FindHardestCells(out cell); model.gameSceneController.winResult = model.gameBoardView.Controller.CheckForWinInCell(cell.x, cell.y); model.stateMachine.SwitchState(); }
public void ConstructorFromChangedCellTest() { Cell cell = new Cell(); cell.RemoveWall(Direction.North); cell.RemoveWall(Direction.East); CellItem cellItem = new CellItem(cell); Assert.AreEqual(cell.ContainsWall(Direction.North), cellItem.NorthWall); Assert.AreEqual(cell.ContainsWall(Direction.West), cellItem.WestWall); Assert.AreEqual(cell.ContainsWall(Direction.East), cellItem.EastWall); Assert.AreEqual(cell.ContainsWall(Direction.South), cellItem.SouthWall); }
// private bool SetOrder(CellItem item, int type) { int index = item.obj.transform.GetSiblingIndex(); if (type == 1) { if (index < 1) { CellItem lastTemp = allObjs[allGoNums - 1]; lastTemp.obj.transform.SetSiblingIndex(0); allObjs.Remove(lastTemp); allObjs.Insert(0, lastTemp); var lastPosTest = sContent.transform.localPosition; sContent.transform.localPosition += new Vector3(-targetLength - space, 0, 0); if (isPress) { PointerEventData pointerEventData = new PointerEventData(EventSystem); pointerEventData.position = Input.mousePosition; mainContainer.OnBeginDrag(pointerEventData); } //lastPos = sContent.transform.localPosition.x; Debug.LogError(string.Format("CellItem Name: {0},lastPosition:{1},nowPosition: {2}", lastTemp.obj.name, lastPosTest, sContent.transform.localPosition)); return(true); } } else { if (index > allGoNums - 2) { CellItem lastTemp = allObjs[0]; lastTemp.obj.transform.SetSiblingIndex(allGoNums - 1); allObjs.Remove(lastTemp); allObjs.Insert(allGoNums - 1, lastTemp); var lastPosTest = sContent.transform.localPosition; sContent.transform.localPosition += new Vector3(targetLength + space, 0, 0); Debug.LogError("SilbingIndex>>>>>>>>>>>>>>" + lastTemp.obj.transform.GetSiblingIndex()); if (isPress) { Debug.Log("==============="); PointerEventData pointerEventData = new PointerEventData(EventSystem); pointerEventData.position = Input.mousePosition; mainContainer.OnBeginDrag(pointerEventData); } //lastPos = sContent.transform.localPosition.x; Debug.LogError(string.Format("CellItem Name: {0},lastPosition:{1},nowPosition: {2}", lastTemp.obj.name, lastPosTest, sContent.transform.localPosition)); return(true); } } return(false); }
private void FindHardestCells(out CellItem itemAction) { itemAction = null; var gameBoardModel = model.gameBoardModel; int maxWeightMy = 0; int maxWeightEnem = 0; List <CellItem> myHardestItems = FindHardestCellItems(gameBoardModel.weightsCrosses, out maxWeightMy); List <CellItem> enemHardestItems = FindHardestCellItems(gameBoardModel.weightsCrosses, out maxWeightEnem); if (!IsOwnTypeCross()) { var t = myHardestItems; myHardestItems = enemHardestItems; enemHardestItems = t; var t2 = maxWeightMy; maxWeightMy = maxWeightEnem; maxWeightEnem = t2; } if (maxWeightMy != 0 && maxWeightEnem != 0) { var itemToDefend = enemHardestItems[Random.Range(0, enemHardestItems.Count)]; var itemToAttack = myHardestItems[Random.Range(0, myHardestItems.Count)]; int deltaPrefer = (int)(maxWeightEnem * model.deltaPreferPercent); if (maxWeightMy >= maxWeightEnem - deltaPrefer) //Attacking { // Debug.Log("Attacking on: " + itemToAttack.name + ", weight:" + maxWeightCrosses); itemToAttack.ChangeState(IsOwnTypeCross(), GetOwnMaterial()); itemAction = itemToAttack; } else //Defending { // Debug.Log("Defending on: " + itemToDefend.name + ", weight:" + maxWeightCircle); itemToDefend.ChangeState(IsOwnTypeCross(), GetOwnMaterial()); itemAction = itemToDefend; } } else { CellItem item = null; if (item = model.gameBoardView.Controller.IsEmptyPlaceOnBoard()) { item.ChangeState(IsOwnTypeCross(), GetOwnMaterial()); itemAction = item; } } }
protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { //ifcl.ApplyFilter("ContainerId", Convert.ToInt32(e.Row.Cells.FromKey("Id").Text), CollectionView.FilterOperand.Equals); e.Row.Cells.FromKey("ContainerName").Text = "[" + e.Row.Cells.FromKey("Tag").Text + "] - " + e.Row.Cells.FromKey("ContainerName").Text; TemplatedColumn col = (TemplatedColumn)e.Row.Cells.FromKey("ifcType").Column; CellItem cellItem = (CellItem)col.CellItems[e.Row.Index]; DropDownList ddType = (DropDownList)cellItem.FindControl("ddType"); if (e.Row.Cells.FromKey("LookupId") != null && e.Row.Cells.FromKey("LookupId").Text == "-1") { foreach (string t in Enum.GetNames(typeof(InputFormContainerType))) { ddType.Items.Add(new ListItem(t, t)); } } else { string defaultValue = Enum.GetName(typeof(InputFormContainerType), InputFormContainerType.Normal); ddType.Items.Add(new ListItem(defaultValue, defaultValue)); ddType.Enabled = false; } if (txtFilter.Text.Trim() != string.Empty) { Infragistics.WebUI.UltraWebGrid.UltraGridRow r = e.Row; UITools.HiglightGridRowFilter(ref r, txtFilter.Text, true); } //if (ifcl.Count != 0) //{ // InputFormContainer obj = ((InputFormContainer)ifcl[0]); // col = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column; // cellItem = (CellItem)col.CellItems[e.Row.Index]; // CheckBox cb = (CheckBox)cellItem.FindControl("g_sd"); // cb.Checked = true; // cb.Enabled = false; // col = (TemplatedColumn)e.Row.Cells.FromKey("Mandatory").Column; // cellItem = (CellItem)col.CellItems[e.Row.Index]; // cb = (CheckBox)cellItem.FindControl("g_m"); // cb.Checked = obj.Mandatory; // cb.Enabled = false; // ddType.SelectedValue = obj.Type.ToString(); // e.Row.Cells.FromKey("Comment").Text = obj.Comment.ToString(); // e.Row.Cells.FromKey("Comment").AllowEditing = AllowEditing.No; // ddType.Enabled = false; //} //else //{ ddType.SelectedValue = InputFormContainerType.Normal.ToString(); //} //ifcl.RemoveFilter(); }
public void ItemSelected(int id) { CellItem clickSelectedCell = GetCellToPlaceCounter(id); if (clickSelectedCell != null && !isGameOver) { CellItem changedCell = ProcessPlayerMove(clickSelectedCell, id); if (changedCell != null) { EvaluateGameState(changedCell); EndTurn(); } } }
//A deferred start so we can use the components for objects this game has spawned. Maybe we should use messages instead but this will do for now. IEnumerator LateStart() { yield return(new WaitForSeconds(0.1f)); for (int x = 0; x < m_GameGridComponent.GetRowLength(); ++x) { for (int y = 0; y < m_GameGridComponent.GetColLength(); ++y) { CellItem cellItem = m_GameGridComponent.GetGridCell(x, y); int index = m_GameGridComponent.CellCooridnatesToIndex(x, y); cellItem.m_CurrentObject.GetComponent <Gem>().Register(index, this); } } }
protected void uwgModules_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { // Build dataset containing all pane names DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("PaneList"); dt.Columns.Add("Value", Type.GetType("System.Int32")); dt.Columns.Add("Text", Type.GetType("System.String")); dt.Rows.Add(new object[] { 0, "LeftPane" }); dt.Rows.Add(new object[] { 1, "ContentPane" }); dt.Rows.Add(new object[] { 2, "RightPane" }); // Get properties for this row int moduleDefId = (Int16)e.Row.Cells.FromKey(CST_FIELD_WEBPARTID).Value; DataRow drProperties = Configuration.GetModuleProperties(moduleDefId); // Find pane list in current row TemplatedColumn currentTempColPane = (TemplatedColumn)e.Row.Cells.FromKey(CST_FIELD_PANENAME).Column; CellItem currentCellItemPane = (CellItem)currentTempColPane.CellItems[e.Row.Index]; DropDownList currentDDL = (DropDownList)currentCellItemPane.FindControl("ddlPaneList"); // Find module order in current row TemplatedColumn currentTempColOrder = (TemplatedColumn)e.Row.Cells.FromKey(CST_FIELD_SORT).Column; CellItem currentCellItemOrder = (CellItem)currentTempColOrder.CellItems[e.Row.Index]; WebNumericEdit currentWNE = (WebNumericEdit)currentCellItemOrder.FindControl("wneModuleOrder"); // Update data in pane list currentDDL.DataSource = ds; currentDDL.DataTextField = "Text"; currentDDL.DataValueField = "Value"; currentDDL.DataBind(); int selectedPane = 0; if (drProperties != null) { selectedPane = (Int16)drProperties[CST_FIELD_PANEID]; } currentDDL.SelectedIndex = selectedPane; // select pane name // Update data in edit for module order currentWNE.Value = 0; if (drProperties != null) { currentWNE.Value = drProperties[CST_FIELD_SORT].ToString() != string.Empty? Convert.ToInt32(drProperties[CST_FIELD_SORT].ToString()): 0; } // free memory ds.Dispose(); }
public static void LoadImage(Bitmap image, out Grid grid) { try { grid = null; if (image == null) { return; } Grid result_grid = new Grid(Consts.GRID_X_SIZE, Consts.GRID_Y_SIZE); System.Drawing.Imaging.PixelFormat format = image.PixelFormat; for (int i = 0; i < Consts.GRID_X_SIZE; i++) { for (int j = 0; j < Consts.GRID_Y_SIZE; j++) { Rectangle rect = new Rectangle(_gridStart.X + Consts.CELL_SIZE * i, _gridStart.Y + Consts.CELL_SIZE * j, Consts.CELL_SIZE, Consts.CELL_SIZE); var pic = image.Clone(rect, format); var cellType = FindColor(pic); if (cellType.Item1 == CellColor.None) { return; } result_grid[i, j] = new CellItem(cellType.Item2, cellType.Item1); } } var imageGray = new Image <Gray, float>(image); var points = GetTemplatePosition(imageGray, _weakPoint, 0.5); if (points?.Length != 0) { result_grid.WeakSlot = (points[0].X - _gridStart.X) / Consts.CELL_SIZE; ; } var result = DetectEnemies(image); foreach (var cellColor in result) { result_grid._enemies[cellColor.Key] = cellColor.Value; } grid = result_grid; } catch (Exception ex) { Logger.SaveErrorScreen(image); grid = null; } }
private void SetCells() { CellItem item; for (int i = 0; i < allGoNums; i++) { item = new CellItem(); var go = Instantiate(goCell, sContent.transform); go.name = i + 1 + ""; item.obj = go; item.index = i; cellCallback(go, i); //go.SetActive(false); allObjs.Add(item); } }
public bool IsDiagonalComplete_Internal(CellItem startIndex, CellItem endIndex, int playerid, int consecutiveCount) { //ensure diagonal if (Debug.isDebugBuild) { UnityEngine.Assertions.Assert.AreNotEqual(startIndex.CellColumn, endIndex.CellColumn); UnityEngine.Assertions.Assert.AreNotEqual(startIndex.CellRow, endIndex.CellRow); } //pick increment direction and starting values CellItem leftMostIndex = null; CellItem rightMostIndex = null; if (startIndex.CellColumn < endIndex.CellColumn) { leftMostIndex = startIndex; rightMostIndex = endIndex; } else { leftMostIndex = endIndex; rightMostIndex = startIndex; } int persistentColIncrement = leftMostIndex.CellRow; // current Y location moving through iterations int gridIncrement = leftMostIndex.CellRow < rightMostIndex.CellRow ? 1 : -1; int foundPlayeridCount = 0; //moves through the effected columns for (int i = startIndex.CellColumn; i != endIndex.CellColumn; ++i) { //X is the column we are investigating Gem gem = GetGridCell(i, persistentColIncrement).m_CurrentObject.GetComponent <Gem>(); if (gem.GetPlayerId() == playerid) { foundPlayeridCount++; } else if (foundPlayeridCount < consecutiveCount) { foundPlayeridCount = 0; } persistentColIncrement += gridIncrement; } return(foundPlayeridCount >= consecutiveCount); }
void UpdateDataView() { lbError.Visible = false; using (Database dbObj = Utils.GetMainDB()) { using (DataSet ds = dbObj.RunSPReturnDataSet("_User_GetCulturesSorted", "cultures", new SqlParameter("@UserId", userId))) { dbObj.CloseConnection(); if (dbObj.LastError.Length == 0) { if (ds != null) { dg.DataSource = ds.Tables[0]; Utils.InitGridSort(ref dg, false); dg.DataBind(); dg.DisplayLayout.AllowSortingDefault = AllowSorting.No; ds.Dispose(); if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly) { TemplatedColumn colHeader = (TemplatedColumn)dg.Columns.FromKey("Select"); HeaderItem cellItemHeader = colHeader.HeaderItem; CheckBox cbHeader = (CheckBox)cellItemHeader.FindControl("g_ca"); cbHeader.Enabled = false; foreach (UltraGridRow r in dg.Rows) { TemplatedColumn col = (TemplatedColumn)r.Cells.FromKey("Select").Column; CellItem cellItem = (CellItem)col.CellItems[r.Index]; CheckBox cb = (CheckBox)cellItem.FindControl("g_sd"); cb.Enabled = false; } } } } else { lbError.CssClass = "hc_error"; lbError.Text = dbObj.LastError; lbError.Visible = true; } } } }
public static IBehaviour GetBehaviour(CellItem item) { switch (item.Type) { case CellType.None: return(new EmptyBehaviour(item)); case CellType.Regular: return(new RegularBehavior(item)); case CellType.Dragon: return(new DragonBehaviour(item)); case CellType.Crystal: return(new CrystalBehaviour(item)); } return(null); }
void Awake() { if (CenterGrid) { this.transform.position -= new Vector3(MaximumWidth * 0.5f, MaximumHeight * 0.5f, 0); } m_CellCount = CellCountX * CellCountY; this.CellExtends = new Vector2(MaximumWidth / CellCountX, MaximumHeight / CellCountY); //Heap Allocated Array of contiguous memory. It has faster access than say a List<T>, which will be helpful when we want to run m_Cells = new CellItem[CellCountX * CellCountY]; for (int i = 0; i < m_CellCount; ++i) { m_Cells[i] = new CellItem(); } CalculateCells(); }
public void ConstructorTest() { Cell cell = new Cell(); CellItem cellItem = new CellItem(cell) { TopLocation = 0, LeftLocation = 0, Width = 0 }; Assert.AreEqual(cell.ContainsWall(Direction.North), cellItem.NorthWall); Assert.AreEqual(cell.ContainsWall(Direction.West), cellItem.WestWall); Assert.AreEqual(cell.ContainsWall(Direction.East), cellItem.EastWall); Assert.AreEqual(cell.ContainsWall(Direction.South), cellItem.SouthWall); Assert.AreEqual(0, cellItem.TopLocation); Assert.AreEqual(0, cellItem.LeftLocation); Assert.AreEqual(0, cellItem.Width); Assert.IsNull(cellItem.Background); }
// Use this for initialization void Start() { isGameOver = false; if (GameGridObject != null) { m_GameGridComponent = GameGridObject.GetComponent <GameGrid>(); for (int x = 0; x < m_GameGridComponent.GetRowLength(); ++x) //For loop that goes round the number of rows are in the game grid { for (int y = 0; y < m_GameGridComponent.GetColLength(); ++y) { CellItem cellItem = m_GameGridComponent.GetGridCell(x, y); cellItem.m_CurrentObject = CreateGemObject(cellItem.CellPosition); } } StartCoroutine(LateStart()); } }
protected void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { try { cv.ApplyFilter("Id", Convert.ToInt32(e.Row.DataKey), HyperCatalog.Business.CollectionView.FilterOperand.Equals); TemplatedColumn col = (TemplatedColumn)e.Row.Cells.FromKey("Delay").Column; CellItem cellItem = (CellItem)col.CellItems[e.Row.Index]; DropDownList ddDelay = (DropDownList)cellItem.FindControl("ddDelay"); for (int i = 0; i < delays.Length; i++) { ddDelay.Items.Add(new ListItem(delays[i], i.ToString())); } HyperCatalog.Business.UserNotification obj = cv.Count == 1 ? (HyperCatalog.Business.UserNotification)cv[0] : null; col = (TemplatedColumn)e.Row.Cells.FromKey("Select").Column; cellItem = (CellItem)col.CellItems[e.Row.Index]; CheckBox cb = (CheckBox)cellItem.FindControl("g_sd"); cb.Checked = obj != null; bool allowNotif = (bool)e.Row.Cells.FromKey("AllowNotificationInAdvance").Value; bool allowInAdv = (allowNotif && SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS)); if (allowNotif) { ddDelay.SelectedIndex = obj != null?Convert.ToInt32(obj.Delay) : 0; } else { ddDelay.Items.Clear(); ddDelay.Items.Add(new ListItem("Instant", "-1")); } ddDelay.Enabled = allowInAdv; } catch (Exception exc) { e.Row.Cells.FromKey("Delay").Text = exc.ToString(); } finally { cv.RemoveFilter(); } }
void EvaluateGameState(CellItem item) { if (m_GameGridComponent.IsRowComplete(item.CellRow, m_PlayerManager.GetActivePlayersTurn().PlayerId, 4)) { GameOver(); return; } if (m_GameGridComponent.IsColComplete(item.CellColumn, m_PlayerManager.GetActivePlayersTurn().PlayerId, 4)) { GameOver(); return; } if (m_GameGridComponent.IsDiagonalComplete(item, m_PlayerManager.GetActivePlayersTurn().PlayerId, 4)) { GameOver(); return; } }