//create grid //witht the raduis, height/width/length is meanless, specially width & length private void SpwanGridCreater(float width, float height, float length, float gap, float r) { var localHeight = -height; while (CustomController.Less(localHeight, height)) { var localLength = -length; while (CustomController.Less(localLength, length)) { var localWidth = -width; while (CustomController.Less(localWidth, width)) { var targetPos = new Vector3(localWidth, localHeight, localLength); if (CustomController.InRange(deviceGO.transform.position, targetPos, r)) { var newGrid = new SpawnGrid(targetPos); ssHandler.Subscribe(newGrid); } localWidth += gap; } localLength += gap; } localHeight += gap; } }
protected void UpdateNeigbor(SpawnGrid sg, List <IObersver> observers, float gap) { foreach (Direction dir in this.neighborDic.Keys.ToList()) { //set this ref to null if (neighborDic[dir] == sg) { neighborDic[dir].SignNeighbor(observers, gap); } } }
bool DirectionTest(float x, float y, float z, SpawnGrid sg) { if (x == this.X && y == this.Y && z == this.Z) { return(true); } else { return(false); } }
public void Summon(string s) { //GameObject deviceGO = GameManager.Instance.deviceGO; //get a random pos from gird; try { SpawnGrid sg = GetGrid(ssHandler.Obersvers); Vector3 pos = sg.GetPos(); Vector3 offsetPos = deviceGO.transform.position; //instantiate and set the value of bullet obj var spawnGO = Instantiate(monsterGo, pos, Quaternion.identity); spawnGO.transform.localScale = new Vector3(1, 1, 1); spawnGO.SendMessage("OccupyGrid", sg); monsters.Add(spawnGO); } catch (System.Exception e) { Debug.Log(e.StackTrace); } }
void OccupyGrid(SpawnGrid sg) { this.sg = sg; }
public void NeighborUpate(Direction dir, SpawnGrid sg) { neighborDic[dir] = sg; }