// COLLISION DETECT ========================================================= public List <KeyValuePair <ITouchible, DirectType> > CheckCollision(int objectId, Bounds selfBounds) { List <KeyValuePair <ITouchible, DirectType> > collideList = new List <KeyValuePair <ITouchible, DirectType> >(); for (int i = 0; i < objectsList.Count; i++) { if (objectId != objectsList[i].GetObjectId()) { Bounds otherBounds = objectsList[i].GetObjectBounds(); if (CheckIntersection(selfBounds, otherBounds)) { DirectType dir = GetDirectIntersection(selfBounds, otherBounds); collideList.Add(new KeyValuePair <ITouchible, DirectType>(objectsList[i], dir)); } } } for (int i = 0; i < cubesList.Count; i++) { if (objectId != cubesList[i].GetObjectId()) { Bounds otherBounds = cubesList[i].GetObjectBounds(); if (CheckIntersection(selfBounds, otherBounds)) { DirectType dir = GetDirectIntersection(selfBounds, otherBounds); collideList.Add(new KeyValuePair <ITouchible, DirectType>(cubesList[i], dir)); } } } return(collideList); }
private void PlayerCollide(DirectType direct) { if (direct == DirectType.LEFT || direct == DirectType.RIGHT) { angle = MirrorByX(angle); } else { angle = MirrorByZ(angle); if (SharedData.Instance.isLeft) { if (angle < 0) { angle -= GetRandomAngle(2, 5); } else { angle -= GetRandomAngle(2, 5); } } if (SharedData.Instance.isRight) { if (angle < 0) { angle += GetRandomAngle(2, 5); } else { angle += GetRandomAngle(2, 5); } } } gameController.PlaySound("ballCollidePlayer"); }
public void Restart() { state = StateType.Start; direct = DirectType.Right; data.Score = 0; transform.position = startPosition; rigidbody.isKinematic = true; }
public virtual void InitData(PlayerBase owner, DirectType direct) { if (owner == null) { Debug.LogError("源头是空的!"); return; } OwnerPlayer = owner; directValue = direct; camp = OwnerPlayer.CurCamp; }
private void CubeCollide(DirectType direct) { if (direct == DirectType.LEFT || direct == DirectType.RIGHT) { angle = MirrorByX(angle); } else if (direct == DirectType.UP || direct == DirectType.DOWN) { angle = MirrorByZ(angle); } else { angle = MirrorByX(angle); angle = MirrorByZ(angle); } }
private void BoardCollide(DirectType direct) { if (direct == DirectType.LEFT || direct == DirectType.RIGHT) { angle = MirrorByX(angle); } else if (direct == DirectType.UP || direct == DirectType.DOWN) { angle = MirrorByZ(angle); } else { angle = MirrorByX(angle); angle = MirrorByZ(angle); } gameController.PlaySound("ballCollideBorder"); }
/// <summary> /// 获得3x3索引 当前元素为正中心 /// </summary> /// <param name="index">当前元素索引</param> /// <param name="width">二维数据宽度</param> /// <param name="height">二维数据高度</param> /// <param name="type">顺时针或者逆时针</param> protected Int32[] getFilterWindow3x3(Int32 index, Int32 width, Int32 height, DirectType type) { Int32 row = index / width; Int32 col = index % width; Int32[] set = new Int32[9]; Int32 rm1 = (row - 1) >= 0 ? (row - 1) : row; Int32 rp1 = (row + 1) < height ? (row + 1) : row; Int32 cm1 = (col - 1) >= 0 ? (col - 1) : col; Int32 cp1 = (col + 1) < width ? (col + 1) : col; switch (type) { case DirectType.Clock: set[0] = index; set[1] = rm1 * width + col; set[2] = rm1 * width + cp1; set[3] = row * width + cp1; set[4] = rp1 * width + cp1; set[5] = rp1 * width + col; set[6] = rp1 * width + cm1; set[7] = row * width + cm1; set[8] = rm1 * width + cm1; break; case DirectType.UntiClock: set[0] = index; set[1] = rm1 * width + col; set[2] = rm1 * width + cm1; set[3] = row * width + cm1; set[4] = rp1 * width + cm1; set[5] = rp1 * width + col; set[6] = rp1 * width + cp1; set[7] = row * width + cp1; set[8] = rm1 * width + cp1; break; } return(set); }
protected void btnSubmit_Click(object sender, EventArgs e) { try { if (hid.Value == "Update") { DirectType exp = null; bool rst = false; exp = LookUpBLL.GetDirectType(Convert.ToInt32(txtID.Text)); if (exp != null) { exp.Name = txtDept.Text.ToUpper(); // exp.GLCode = txtcode.Text; if (chkActive.Checked) { exp.isActive = true; } else { exp.isActive = false; } rst = LookUpBLL.UpdateDirectType(exp); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { bool result = false; DirectType exp = new DirectType(); exp.Name = txtDept.Text.ToUpper(); // exp.GLCode = txtcode.Text; if (chkActive.Checked) { exp.isActive = true; } else { exp.isActive = false; } result = LookUpBLL.AddDirectType(exp); if (result) { BindGrid(); txtDept.Text = ""; //txtcode.Text = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }
protected Int32[] getFilterWindow5x5(Int32 index, Int32 width, Int32 height, DirectType type) { Int32 row = index / width; Int32 col = index % width; Int32[] set = new Int32[25]; switch (type) { case DirectType.Clock: set[0] = index; #region 内圈 set[1] = System.Math.Abs(row - 1) % height * width + col; set[2] = System.Math.Abs(row - 1) % height * width + (col + 1) % width; set[3] = row * width + (col + 1) % width; set[4] = (row + 1) % height * width + (col + 1) % width; set[5] = (row + 1) % height * width + col; set[6] = (row + 1) % height * width + System.Math.Abs(col - 1) % width; set[7] = row * width + System.Math.Abs(col - 1) % width; set[8] = System.Math.Abs(row - 1) % height * width + System.Math.Abs(col - 1) % width; #endregion #region 外圈 set[9] = System.Math.Abs(row - 2) % height * width + col; set[10] = System.Math.Abs(row - 2) % height * width + (col + 1) % width; set[11] = System.Math.Abs(row - 2) % height * width + (col + 2) % width; set[12] = System.Math.Abs(row - 1) % height * width + (col + 2) % width; set[13] = row * width + (col + 2) % width; set[14] = (row + 1) % height * width + (col + 2) % width; set[15] = (row + 2) % height * width + (col + 2) % width; set[16] = (row + 2) % height * width + (col + 1) % width; set[17] = (row + 2) % height * width + col; set[18] = (row + 2) % height * width + System.Math.Abs(col - 1) % width; set[19] = (row + 2) % height * width + System.Math.Abs(col - 2) % width; set[20] = (row + 1) % height * width + System.Math.Abs(col - 2) % width; set[21] = row * width + System.Math.Abs(col - 2) % width; set[22] = System.Math.Abs(row - 1) % height * width + System.Math.Abs(col - 2) % width; set[23] = System.Math.Abs(row - 2) % height * width + System.Math.Abs(col - 2) % width; set[24] = System.Math.Abs(row - 2) % height * width + System.Math.Abs(col - 1) % width; #endregion break; case DirectType.UntiClock: set[0] = index; #region 圈内 set[1] = System.Math.Abs(row - 1) % height * width + col; set[2] = System.Math.Abs(row - 1) % height * width + System.Math.Abs(col - 1) % width; set[3] = row * width + System.Math.Abs(col - 1) % width; set[4] = (row + 1) % height * width + System.Math.Abs(col - 1) % width; set[5] = (row + 1) % height * width + col; set[6] = (row + 1) % height * width + (col + 1) % width; set[7] = row * width + (col + 1) % width; set[8] = System.Math.Abs(row - 1) % height * width + (col + 1) % width; #endregion #region 圈外 set[9] = System.Math.Abs(row - 2) % height * width + col; set[10] = System.Math.Abs(row - 2) % height * width + System.Math.Abs(col - 1) % width; set[11] = System.Math.Abs(row - 2) % height * width + System.Math.Abs(col - 2) % width; set[12] = System.Math.Abs(row - 1) % height * width + System.Math.Abs(col - 2) % width; set[13] = row * width + System.Math.Abs(col - 2) % width; set[14] = (row + 1) % height * width + System.Math.Abs(col - 2) % width; set[15] = (row + 2) % height * width + System.Math.Abs(col - 2) % width; set[16] = (row + 2) % height * width + System.Math.Abs(col - 1) % width; set[17] = (row + 2) % height * width + col; set[18] = (row + 2) % height * width + (col + 1) % width; set[19] = (row + 2) % height * width + (col + 2) % width; set[20] = (row + 1) % height * width + (col + 2) % width; set[21] = row * width + (col + 2) % width; set[22] = System.Math.Abs(row - 1) % height * width + (col + 2) % width; set[23] = System.Math.Abs(row - 2) % height * width + (col + 2) % width; set[24] = System.Math.Abs(row - 2) % height * width + (col + 1) % width; #endregion break; } return(set); }
/// <summary> /// 获取3x3窗体 /// 统一正上方为突入外围点(即当前点索引为0, 正上方点索引为1) /// </summary> /// <param name="data">二维数据</param> /// <param name="x">当前点横坐标</param> /// <param name="y">当前点纵坐标</param> /// <param name="width">数据宽度</param> /// <param name="height">数据高度</param> /// <param name="overstepColor">超出边界的点的填充值</param> /// <param name="type">窗口索引的方向</param> protected Byte[] getFilterWindow3x3(ref Byte[] data, Int32 x, Int32 y, Int32 width, Int32 height, Byte overstepColor, DirectType type) { Byte[] set = new Byte[9]; Int32 index = y * width + x; switch (type) { case DirectType.Clock: set[0] = data[index]; set[1] = (y > 0) ? data[(y - 1) * width + x] : overstepColor; set[2] = (y > 0) ? ((x < (width - 1)) ? data[(y - 1) * width + x + 1] : overstepColor) : overstepColor; set[3] = (x < (width - 1)) ? data[y * width + x + 1] : overstepColor; set[4] = (y < (height - 1) ? (x < (width - 1) ? data[(y + 1) * width + x + 1] : overstepColor) : overstepColor); set[5] = (y < (height - 1)) ? data[(y + 1) * width + x] : overstepColor; set[6] = (y < (height - 1)) ? ((x > 0) ? data[(y + 1) * width + x - 1] : overstepColor) : overstepColor; set[7] = (x > 0) ? data[y * width + x - 1] : overstepColor; set[8] = (y > 0) ? ((x > 0) ? data[(y - 1) * width + x - 1] : overstepColor) : overstepColor; break; case DirectType.UntiClock: set[0] = data[index]; set[1] = (y > 0) ? data[(y - 1) * width + x] : overstepColor; set[2] = (y > 0) ? ((x > 0) ? data[(y - 1) * width + x - 1] : overstepColor) : overstepColor; set[3] = (x > 0) ? data[y * width + x - 1] : overstepColor; set[4] = (y < (height - 1)) ? ((x > 0) ? data[(y + 1) * width + x - 1] : overstepColor) : overstepColor; set[5] = (y < (height - 1)) ? data[(y + 1) * width + x] : overstepColor; set[6] = (y < (height - 1) ? (x < (width - 1) ? data[(y + 1) * width + x + 1] : overstepColor) : overstepColor); set[7] = (x < (width - 1)) ? data[y * width + x + 1] : overstepColor; set[8] = (y > 0) ? ((x < (width - 1)) ? data[(y - 1) * width + x + 1] : overstepColor) : overstepColor; break; } return(set); }
/// <summary> /// 获得3x3索引 当前元素为正中心 只获取存在的邻域索引 /// </summary> /// <param name="index"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="type"></param> /// <returns></returns> protected Int32[] getExistFilterWindow3x3(Int32 index, Int32 width, Int32 height, DirectType type) { System.Collections.Generic.List <Int32> list = new System.Collections.Generic.List <int>(); Int32 row = index / width; Int32 col = index % width; list.Add(index); switch (type) { case DirectType.Clock: if (row > 0) { list.Add((row - 1) * width + col); } if (row > 0 && col < width - 1) { list.Add((row - 1) * width + col + 1); } if (col < width - 1) { list.Add(row * width + col + 1); } if (row < height - 1 && col < width - 1) { list.Add((row + 1) * width + col + 1); } if (row < height - 1) { list.Add((row + 1) * width + col); } if (row < height - 1 && col > 0) { list.Add((row + 1) * width + col - 1); } if (col > 0) { list.Add(row * width + col - 1); } if (row > 0 && col > 0) { list.Add((row - 1) * width + col - 1); } break; case DirectType.UntiClock: if (row > 0) { list.Add((row - 1) * width + col); } if (row > 0 && col > 0) { list.Add((row - 1) * width + col - 1); } if (col > 0) { list.Add(row * width + col - 1); } if (row < height - 1 && col > 0) { list.Add((row + 1) * width + col - 1); } if (row < height - 1) { list.Add((row + 1) * width + col); } if (row < height - 1 && col < width - 1) { list.Add((row + 1) * width + col + 1); } if (col < width - 1) { list.Add(row * width + col + 1); } if (row > 0 && col < width) { list.Add((row - 1) * width + col + 1); } break; } return(list.ToArray()); }
private int curSmallCount = 0;//当前回合数 public override void InitData(PlayerBase owner, DirectType direct) { base.InitData(owner, direct); RunOnce(); }