public bool MoveToPosition(Coordinate coordinate) { Tile targetTile = TileMapManager.GetTile(coordinate); if (targetTile != null) { if (targetTile.unit == null) { TileMapManager.GetTile(this.coordinate).unit = null; transform.position = targetTile.transform.position; targetTile.unit = this; this.coordinate = coordinate; return(true); } else { Debug.Log("Can't Move There Position. Aready Unit exist (" + coordinate.x + "," + coordinate.y + ") - move"); return(false); } } else { Debug.Log("There is NullTile (" + coordinate.x + "," + coordinate.y + ") - move"); return(false); } }
public override void Adjust() { targetList.Clear(); int angle = caster.directionToCoordinate.GetAngle(); foreach (Coordinate coord in searchArea.coordList) { Tile targetTile = TileMapManager.GetTile(coord.Rotate(angle) + caster.coordinate); if (targetTile != null) { if (targetTile.unit != null) { targetList.Add(targetTile.unit); } } } foreach (Coordinate coord in searchArea.coordList) { Tile targetTile = TileMapManager.GetTile(coord.Rotate(angle) + caster.coordinate); if (targetTile != null) { targetTile.GetComponent <SpriteRenderer>().color = new Color32(255, 100, 100, 255); } } foreach (Effect effect in effectList) { effect.targetList = targetList; effect.Adjust(); } }
void GiveDamageToPosition(Coordinate position, int damage) { Tile targetTile = TileMapManager.GetTile(position); if (targetTile != null) { if (targetTile.unit != null) { targetTile.unit.GetDamage(damage); } } }
void drawSpace(mSpace target) { Tile test; //Debug.Log(target.x + " " + target.y + " " + target.w + " " + target.h); for (int i = 0; i < target.h + 1; i++) { for (int j = 0; j < target.w + 1; j++) { if (i == 0 || i == target.h || j == 0 || j == target.w) { test = TileMapManager.GetTile(new Coordinate(target.x + j, target.y + i)); test.SetGroundInfo(E_Ground.Wall); } else { test = TileMapManager.GetTile(new Coordinate(target.x + j, target.y + i)); test.SetGroundInfo(E_Ground.Ground); } } } }
void drawPathBlock(int x, int y, PathType type) { Tile test; if (type == PathType.Wall) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i != 0 && j != 0) { test = TileMapManager.GetTile(new Coordinate(x + i, y + j)); test.SetGroundInfo(E_Ground.Wall); } } } } else { test = TileMapManager.GetTile(new Coordinate(x, y)); test.SetGroundInfo(E_Ground.Ground); } }
public void Move(E_Direction direction) { leader.direction = direction; Coordinate nextPosition; switch (direction) { case E_Direction.Up: nextPosition = new Coordinate(0, 1); break; case E_Direction.Left: nextPosition = new Coordinate(-1, 0); break; case E_Direction.Down: nextPosition = new Coordinate(0, -1); break; case E_Direction.Right: nextPosition = new Coordinate(1, 0); break; default: nextPosition = new Coordinate(0, 0); break; } Coordinate resultPosition = leader.coordinate; TraceInfo traceInfo = new TraceInfo(direction, leader.coordinate); for (int point = 1; point <= leader.movePoint; point++) { Tile t = TileMapManager.GetTile(nextPosition * point + leader.coordinate); if (t != null) { //이동 가능한지 확인구간 if (t.unit == null) { traceInfo = new TraceInfo(direction, resultPosition); resultPosition = nextPosition * point + leader.coordinate; AddTrace(traceInfo); } else { break; } } else { break; } } leader.MoveToPosition(resultPosition); for (int index = 0; index < memberList.Count; index++) { if (positionTrace.Count - 1 >= index) { memberList[index].MoveToPosition(positionTrace[index].coordinate); memberList[index].direction = positionTrace[index].direction; } else { break; } } //문제 발생 가능함. 리더의 밀쳐지기 혹은 급작스런 이동시. }
public void Dead() { TileMapManager.GetTile(coordinate).unit = null; Destroy(gameObject); }