public double Fy(int y, IPos A, IPos B) { int byay = B.Y - A.Y; byay = byay == 0 ? 1 : byay; return((B.X - A.X) * (y - A.Y) / (byay) + A.X); }
public List <IPos> SetNeighborsSquare(IPos p, Dictionary <string, IPos> map) { float x = p.gridLoc.x(); float y = p.gridLoc.y(); List <IPos> neighbors = new List <IPos>(); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i != 0 || j != 0) { float X = wrapEastWest ? (dim + x + i) % dim : x + i; float Y = wrapNorthSouth ? (dim + y + j) % dim : y + j; Loc l2 = new Loc(X, Y); if (map.ContainsKey(l2.key())) { neighbors.Add(map[l2.key()]); } else { Debug.Log("Map doesn't contain " + l2.x() + "," + l2.y()); } } } } return(neighbors); }
public double PrecisionLength(IPos target) { int x = target.X - this.X; int y = target.Y - this.Y; return(Math.Sqrt(x * x + y * y)); }
public ExodusLand(IPos _pos, float _elevation, float _temperature) : base(_pos) { if (_elevation < 0.5f) { if (_temperature < 0.5f) { iLand = 1; } else { iLand = 2; } } else { if (_temperature < 0.5f) { iLand = 3; } else { iLand = 4; } } }
public override string ToString() { string gcodeLineText = ""; gcodeLineText += LineNumber.ToString() + ";"; foreach (string command in Command) { gcodeLineText += command + ";"; } gcodeLineText += XPos.ToString() + SEPERATOR + YPos.ToString() + SEPERATOR + ZPos.ToString() + SEPERATOR + IPos.ToString() + SEPERATOR + JPos.ToString() + SEPERATOR + CRNumber.ToString() + SEPERATOR; foreach (ErrorGCode error in Error) { gcodeLineText += error.ToString() + SEPERATOR; } return(gcodeLineText); }
public double Fx(int x, IPos A, IPos B) { int bxax = B.X - A.X; bxax = bxax == 0 ? 1 : bxax; return((x - A.X) * (B.Y - A.Y) / (bxax) + A.Y); }
public bool Collideing(IPos other) { float[] otherTransform = other.GetTransform(); float dx = (otherTransform[0] - this.x); float dy = (otherTransform[1] - this.y); return(dx * dx + dy * dy <= (this.size / 2 + otherTransform[2] / 2) * (this.size / 2 + otherTransform[2] / 2)); }
public List <IPos> SetNeighborsHex(IPos p, Dictionary <string, IPos> map) { List <IPos> neighbors = new List <IPos>(); List <int[]> hexNeighbors = new List <int[]>(); if (p.gridLoc.y() % 2 == 0) { hexNeighbors.Add(new int[] { 1, 0 }); hexNeighbors.Add(new int[] { 1, -1 }); hexNeighbors.Add(new int[] { 0, -1 }); hexNeighbors.Add(new int[] { -1, 0 }); hexNeighbors.Add(new int[] { 0, 1 }); hexNeighbors.Add(new int[] { 1, 1 }); } else { hexNeighbors.Add(new int[] { 1, 0 }); hexNeighbors.Add(new int[] { -1, -1 }); hexNeighbors.Add(new int[] { 0, -1 }); hexNeighbors.Add(new int[] { -1, 0 }); hexNeighbors.Add(new int[] { 0, 1 }); hexNeighbors.Add(new int[] { -1, 1 }); } float x = p.gridLoc.x(); float y = p.gridLoc.y(); for (int k = 0; k < hexNeighbors.Count; k++) { int i = hexNeighbors[k][0]; int j = hexNeighbors[k][1]; float X = wrapEastWest ? (dim + x + i) % dim : x + i; float Y = wrapNorthSouth ? (dim + y + j) % dim : y + j; Loc l2 = new Loc(X, Y); if (map.ContainsKey(l2.key())) { neighbors.Add(map[l2.key()]); } else { Debug.Log("Map doesn't contain " + l2.x() + "," + l2.y()); } } return(neighbors); }
public static ILand CreateLand(IPos _pos, Dictionary <string, float> _val, LandType _landType) { if (_landType == LandType.BasicLand) { return(new LandBasic(_pos, _val["elevation"])); } else if (_landType == LandType.ExodusLand) { return(new ExodusLand(_pos, _val["elevation"], _val["temperature"])); } else { return(new LandBasic(_pos, _val["elevation"])); } }
public void InitCamera() { IPos midPos = game.map.GetCenterPos(); Vector3 p = goMap[midPos].transform.position; if (game.tileShape == TileShape.SQUARE) { Camera.main.transform.position = new Vector3(p.x, 1, p.z); Camera.main.orthographicSize = game.map.dim / 1.75f; } else { Camera.main.transform.position = new Vector3(p.x * 3 / 2, 1, p.z * 3 / 2); Camera.main.orthographicSize = (3 / 2) * game.map.dim / 1.75f; } }
public Dictionary <string, IPos> SetNeighborsFor2DGrid(Dictionary <string, IPos> map) { foreach (string k in map.Keys) { IPos p = map[k]; if (tileShape == TileShape.SQUARE) { p.neighbors = SetNeighborsSquare(p, map); } else if (tileShape == TileShape.HEX) { p.neighbors = SetNeighborsHex(p, map); } } return(map); }
public Dictionary <string, IPos> Generate2DGrid(int _dim) { Dictionary <string, IPos> map = new Dictionary <string, IPos>(); for (int x = 0; x < _dim; x++) { for (int y = 0; y < _dim; y++) { Loc l = new Loc(x, y); IPos p = PosFactory.CreatePos(l, game); map[p.gridLoc.key()] = p; } } return(map); }
public static Vector2Int GetPos(this IPos target) { return(new Vector2Int(target.PosX, target.PosY)); }
public LandAbstract(IPos _pos) { pos = _pos; }
public void setPos(IPos _pos) { pos = _pos; }
public LandBasic(IPos _pos, float val) : base(_pos) { SetTerrainType(val); }
public bool HandleClick(IPos _pos, bool _leftClick, bool _rightClick) { return(true); }