private bool CheckMove(Directon direction, int x, int y) { // check in front of position switch (direction) { case Directon.Right: if (map2darray[x, y + 1] == TerrainType.Empty) { return(true); } break; case Directon.Left: if (map2darray[x, y - 1] == TerrainType.Empty) { return(true); } break; case Directon.Up: if (map2darray[x - 1, y] == TerrainType.Empty) { return(true); } break; case Directon.Down: if (map2darray[x + 1, y] == TerrainType.Empty) { return(true); } break; } return(false); }
public void Rotate180() { if (Directon == Directon.DOWN) { Directon = Directon.UP; } else if (Directon == Directon.UP) { Directon = Directon.DOWN; } else if (Directon == Directon.LEFT) { Directon = Directon.RIGHT; } else if (Directon == Directon.RIGHT) { Directon = Directon.LEFT; } Offset(1); }
private void Move(Directon direction, int x, int y) { switch (direction) { case Directon.Right: map2darray[x, y + 1] = map2darray[x, y]; int i1 = GetLocationArray(x, y + 1); MapArray[i1] = map2darray[x, y]; break; case Directon.Left: map2darray[x, y - 1] = map2darray[x, y]; int i2 = GetLocationArray(x, y - 1); MapArray[i2] = map2darray[x, y]; break; case Directon.Up: map2darray[x - 1, y] = map2darray[x, y]; int i3 = GetLocationArray(x - 1, y); MapArray[i3] = map2darray[x, y]; break; case Directon.Down: map2darray[x + 1, y] = map2darray[x, y]; int i4 = GetLocationArray(x + 1, y); MapArray[i4] = map2darray[x, y]; break; default: break; } map2darray[x, y] = TerrainType.Empty; int i = GetLocationArray(x, y); MapArray[i] = TerrainType.Empty; }
public bool MovePlayer(Directon direction) { Tuple <int, int> t = GetPlayerLocation(); switch (direction) { case Directon.Right: if (map2darray[t.Item1, t.Item2 + 1] == TerrainType.MoveableBlock) { if (CheckMove(Directon.Right, t.Item1, t.Item2 + 1)) { Move(Directon.Right, t.Item1, t.Item2 + 1); Move(Directon.Right, t.Item1, t.Item2); return(true); } } else if (CheckMove(Directon.Right, t.Item1, t.Item2)) { Move(Directon.Right, t.Item1, t.Item2); return(true); } break; case Directon.Left: if (map2darray[t.Item1, t.Item2 - 1] == TerrainType.MoveableBlock) { if (CheckMove(Directon.Left, t.Item1, t.Item2 - 1)) { Move(Directon.Left, t.Item1, t.Item2 - 1); Move(Directon.Left, t.Item1, t.Item2); return(true); } } else if (CheckMove(Directon.Left, t.Item1, t.Item2)) { Move(Directon.Left, t.Item1, t.Item2); return(true); } break; case Directon.Up: if (map2darray[t.Item1 - 1, t.Item2] == TerrainType.MoveableBlock) { if (CheckMove(Directon.Up, t.Item1 - 1, t.Item2)) { Move(Directon.Up, t.Item1 - 1, t.Item2); Move(Directon.Up, t.Item1, t.Item2); return(true); } } else if (CheckMove(Directon.Up, t.Item1, t.Item2)) { Move(Directon.Up, t.Item1, t.Item2); return(true); } break; case Directon.Down: if (map2darray[t.Item1 + 1, t.Item2] == TerrainType.MoveableBlock) { if (CheckMove(Directon.Down, t.Item1 + 1, t.Item2)) { Move(Directon.Down, t.Item1 + 1, t.Item2); Move(Directon.Down, t.Item1, t.Item2); return(true); } } else if (CheckMove(Directon.Down, t.Item1, t.Item2)) { Move(Directon.Down, t.Item1, t.Item2); return(true); } break; } return(false); }
/// <summary> /// 设置组牌中的UI显示 /// </summary> /// <param name="data"></param> /// <param name="isOther"></param> /// <returns></returns> public virtual List <MahjongItem> SetGroup(MahjongGroupData data, List <MahjongItem> items, float groupWidth, float groupHeight, float fourOffsetY, bool isOther, Directon direction, bool changeNum = true) { _data = data; int[] values = data.values; Vector3 pos = Vector3.zero; if (items == null) { items = new List <MahjongItem>(); foreach (var value in values) { items.Add(GameTools.CreateMahjong(value, changeNum).GetComponent <MahjongItem>()); } } bool isHorizontal = direction.Equals(Directon.Horizontal); for (int i = 0, lenth = values.Length; i < lenth; i++) { MahjongItem item = items[i]; if (item == null) { YxDebug.LogError("找不到一张牌了?"); } Transform newTran = item.transform; switch (data.type) { case GroupType.Chi: case GroupType.Peng: case GroupType.MingGang: case GroupType.ZhuaGang: case GroupType.PengGang: case GroupType.CaiGang: case GroupType.FengGang: SetNewItem(item, values[i], EnumMahJongAction.Lie); break; case GroupType.AnGang: if (isOther) { SetNewItem(item, values[i], EnumMahJongAction.Push); } else { if (i != 3) { SetNewItem(item, values[i], EnumMahJongAction.Push); } else { SetNewItem(item, values[i], EnumMahJongAction.Lie); } } break; case GroupType.JueGang: if (isOther) { SetNewItem(item, values[i], EnumMahJongAction.Push); } else { if (i != 1) { SetNewItem(item, values[i], EnumMahJongAction.Push); } else { SetNewItem(item, values[i], EnumMahJongAction.Lie); } } break; default: SetNewItem(item, values[i], EnumMahJongAction.Lie); break; } if (i == 3 && data.type != GroupType.Other) { if (isHorizontal) { pos.x = 1 * groupWidth; pos.y = pos.y + fourOffsetY; } else { pos.y = 1 * groupHeight + fourOffsetY; } } else { if (isHorizontal) { pos.x = i * groupWidth; } else { pos.y = i * groupHeight; } } newTran.localPosition = pos; } return(items); }
protected Enity(int size, Point location, Directon directon) : base(size, location) { Directon = directon; }
private void Rotate(Directon newDdirecton) { if (CurrentDirection == Directon.DOWN) { if (newDdirecton == Directon.LEFT) { _img.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (newDdirecton == Directon.UP) { _img.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (newDdirecton == Directon.RIGHT) { _img.RotateFlip(RotateFlipType.Rotate270FlipNone); } } else if (CurrentDirection == Directon.UP) { if (newDdirecton == Directon.LEFT) { _img.RotateFlip(RotateFlipType.Rotate270FlipNone); } else if (newDdirecton == Directon.DOWN) { _img.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (newDdirecton == Directon.RIGHT) { _img.RotateFlip(RotateFlipType.Rotate90FlipNone); } } else if (CurrentDirection == Directon.LEFT) { if (newDdirecton == Directon.UP) { _img.RotateFlip(RotateFlipType.Rotate90FlipNone); } if (newDdirecton == Directon.DOWN) { _img.RotateFlip(RotateFlipType.Rotate270FlipNone); } if (newDdirecton == Directon.RIGHT) { _img.RotateFlip(RotateFlipType.Rotate180FlipNone); } } else if (CurrentDirection == Directon.RIGHT) { if (newDdirecton == Directon.LEFT) { _img.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (newDdirecton == Directon.DOWN) { _img.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (newDdirecton == Directon.UP) { _img.RotateFlip(RotateFlipType.Rotate270FlipNone); } } CurrentDirection = newDdirecton; }
public Tank(int size, Point location, Directon directon) : base(size, location, directon) { }
public Kolobok(int size, Point location, Directon directon) : base(size, location, directon) { }