void Start () { grid = GetComponent<Grid>(); requestManager = GetComponent<PathRequestManager>(); consumePathQ = new Queue<Stack<Node>>(); TrafficIntensityTimer.gameTime = GameObject.Find("HUDGameTime").GetComponent<GameTime>(); poison = false; ModifiedBFS(); initProducer(); initConsumers(); }
public void ReCalcPath() { PathRequestManager.RequestPath(transform.position, target.position, OnPathFound); }
public void FindPath(IGrid grid, Vector3 start, Vector3 target, PathRequestManager requestManager) { StartCoroutine(CalculatePath(grid, start, target, requestManager)); }
// Use this for initialization void Start() { PathRequestManager.RequestPath(transform.position, target.position, OnPathFound); }
void Awake() { requestManager = GetComponent<PathRequestManager> (); grid = GetComponent<Grid> (); }
/// <summary> /// Awake this instance. Gets a PathRequestManager component /// as well as a Grid component. /// </summary> void Awake() { requestManager = GetComponent<PathRequestManager>(); grid=GetComponent<Grid>(); TestFileRecord.CreateFile(String.Format("{0:yyy-MM-dd HH.mm.ss}__{1}.txt", DateTime.Now, "TestFile")); }
void Awake() { grid = ResourceGrid.Grid; requestManager = GetComponent<PathRequestManager>(); }
void Awake() { pInstance = this; mPathfinding = GetComponent <Pathfinding>(); }
// Start is called before the first frame update void Start() { StartCoroutine(UpdatePath()); PathRequestManager.RequestPath(new PathRequest(transform.position, target.position, OnPathFound)); }
void Move() { PathRequestManager.RequestPath(transform.position, target, OnPathFound); }
private void Awake() { requestManager = GetComponent <PathRequestManager>(); grid = GameObject.FindGameObjectWithTag("Grid").GetComponent <Grid>(); }
public override IEnumerator Update() { // 적을 찾는다. List <Unit> enemies = FindEnemiesWithTag(); // 조건. 적이 없다면. if (enemies.Count <= 0) { yield return(new WaitForSeconds(sc.GetRandomDelay())); yield break; } // 가장 가까운 적을 찾는다. Unit target = GetClosest(enemies); sc.target = target; // 조건. 사거리 내에 있는지 확인한다. // 사거리 내에 있다면, 상태를 변경한다. if (IsInAttackrange()) { // 왼쪽이 0 int dir = (sc.target.transform.position.x - controller.Position.x < 0) ? 0 : 1; controller.modelTr.rotation = Quaternion.Euler(new Vector3(0, 180 * dir, 0)); sc.ChangeState(sc.attackState); yield break; } // 사거리내에 없다면. // 사이에 장애물이 있는지 확인한다. if (CheckAround()) { PathRequestManager.RequestPath(new PathRequest(controller.Position, target.transform.position, OnPathFound)); } else { if (follow != null) { controller.StopCoroutine(follow); follow = null; } follow = sc.StartCoroutine(this.FollowTarget()); } var range = UnityEngine.Random.Range(0, 100); if (range <= 10) { if (YellowBean.SoundManager.Instance != null) { if (sc.tag.CompareTo("Yellow") == 0) { YellowBean.SoundManager.Instance.PlaySFX(string.Format("y_battle{0}", UnityEngine.Random.Range(0, 7))); } else { YellowBean.SoundManager.Instance.PlaySFX(string.Format("g_battle{0}", UnityEngine.Random.Range(0, 9))); } } } yield return(new WaitForSeconds(sc.GetRandomDelay())); sc.ChangeState(sc.chaseSate); }
void Awake() { map = GetComponent<AStarMap>(); requestManager = GetComponent<PathRequestManager>(); }
// Script must be on the same gameobject to work void Awake() { // make reference requestManager = GetComponent<PathRequestManager>(); grid = GetComponent<Grid>(); }
Grid grid;//get grid script //Scripts void Awake() { requestManager = GetComponent<PathRequestManager>(); grid = GetComponent<Grid>();//gets the grit info }
void Awake(){ heatmanager = GetComponent<HeatMapManager>(); grid = GetComponentInParent<Grid>(); pathManager = GetComponent<PathRequestManager>(); }
private void Awake() { m_grid = GetComponent <Grid> (); m_requestManager = GetComponent <PathRequestManager> (); }
// Use this for initialization void Awake() { NodeGrid = GetComponent<Grid>(); RequestManager = GetComponent<PathRequestManager>(); }
private void Awake() { requestManager = GetComponent <PathRequestManager>(); grid = GetComponent <NodeGraph>(); }
void Awake() { instance = this; pathFinding = GetComponent<FindPath>(); }
private void Awake() { this.requestManager = this.GetComponent <PathRequestManager>(); this.grid = this.GetComponent <NavGrid>(); }
void Start() { grid = Grid.Instance; requestManager = GetComponent<PathRequestManager>(); }
void Awake() { grid = GetComponent <Graph> (); requestManager = GetComponent <PathRequestManager> (); }
void Awake(){ manager = this; pathFinding = GetComponent<PathFinding>(); }
public void RequestPathInstantly() { PathRequestManager.RequestPath(transform.position, player.position, OnPathFound); }
public void findPlayer() { PathRequestManager.RequestPath(transform.position, target.position, OnPathFound); }
private void Awake() { instance = this; pathfinding = GetComponent <Astar>(); }
public IEnumerator CalculatePath(IGrid grid, Vector3 startPos, Vector3 targetPos, PathRequestManager requestManager) { if (grid == null) { yield break; } Vector3[] waypoints = new Vector3[0]; bool pathFound = false; INode startNode = grid.NodeFromWorldPosition(startPos); INode targetNode = grid.NodeFromWorldPosition(targetPos); var openSet = new Heap <INode>(grid.NodeCount); var closedSet = new HashSet <INode>(); openSet.Add(startNode); while (openSet.Count > 0) { INode currentNode = openSet.Unshift(); closedSet.Add(currentNode); if (currentNode == targetNode) { pathFound = true; break; } AnalyzeNeighbourNodes(grid, currentNode, targetNode, openSet, closedSet); } yield return(null); if (pathFound) { waypoints = RetracePath(startNode, targetNode); } if (requestManager != null) { requestManager.OnProcessingFinished(waypoints, pathFound); } }
void Awake() { navigationGrid = GetComponent<NavigationGridMap>(); requestManager = GetComponent<PathRequestManager>(); }
private void OnTriggerEnter(Collider collision) { if (collision.gameObject.name.Contains("Rock") || collision.gameObject.name.Contains("Cube")) { UnityEngine.Debug.Log("i hit a rock"); avoided = true; if (collision.gameObject.transform.position.x < transform.position.x) { walkLeft = true; } else { walkLeft = false; } myNode = Grid.instance.NodeFromWorldPoint(transform.position); previousX = myNode.gridX; previousY = myNode.gridY; int targetX = (walkLeft == false) ? myNode.gridX - 1 : myNode.gridX + 1; int targetY = myNode.gridY - 1; if (targetX >= Grid.instance.GridSizeX) { targetY -= 1; } else if (targetX < 0) { targetX = 0; } targetNode = Grid.instance.NodeFromXY(targetX, targetY); targetPosition = targetNode.worldPosition; targetPosition.y = transform.position.y; yChangedCount += 1; } if (collision.gameObject.name.Contains("Sawmill")) { UnityEngine.Debug.Log("i hit a Sawmill"); millPos = Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).worldPosition; millPos.y = transform.position.y; foundMill = true; Grid.instance.DiscoveredNode(myId, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).gridX, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).gridY); Grid.instance.DiscoveredNodes(myId, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position)); if (foundMill == true && foundTree == true) { if (treeCut == false) { PathRequestManager.RequestPath(myId, transform.position, treePos, OnPathFound); searching = false; UnityEngine.Debug.Log("done2"); action = 1; } else { sw.Stop(); UnityEngine.Debug.Log("done by " + myId); print("Task Complete: " + sw.ElapsedMilliseconds + " ms"); UnityEngine.Debug.Log("TREEE IS GONE N"); action = 2; } } } if (collision.gameObject.name.Contains("Tree")) { UnityEngine.Debug.Log("i hit a Tree"); treePos = Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).worldPosition; treePos.y = transform.position.y; foundTree = true; Grid.instance.DiscoveredNode(myId, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).gridX, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position).gridY); Grid.instance.DiscoveredNodes(myId, Grid.instance.NodeFromWorldPoint(collision.gameObject.transform.position)); if (foundMill == true && foundTree == true) { if (treeCut == false) { collision.gameObject.SetActive(false); searching = false; treeCut = true; UnityEngine.Debug.Log("cutting tree"); action = 1; PathRequestManager.RequestPath(myId, transform.position, millPos, OnPathFound); } } } if (collision.gameObject.tag == "Player") { UnityEngine.Debug.Log("sharing knowledge"); Node[,] mygrid = Grid.instance.GetGridFromID(this.gameObject.GetInstanceID()); Node[,] othergrid = Grid.instance.GetGridFromID(collision.gameObject.GetInstanceID()); for (int x = 0; x < mygrid.GetLength(0); x++) { for (int y = 0; y < mygrid.GetLength(1); y++) { if (mygrid[x, y].discovered) { Grid.instance.DiscoveredNode(collision.gameObject.GetInstanceID(), x, y, mygrid[x, y].walkable); UnityEngine.Debug.Log("knowledge shared 1"); } else if (othergrid[x, y].discovered) { UnityEngine.Debug.Log("knowledge shared 2"); Grid.instance.DiscoveredNode(myId, x, y, mygrid[x, y].walkable); } } } } }
void Awake() { _instance = this; _pathFinding = GetComponent <PathFinding>(); }
void Awake() { requestManager = GetComponent <PathRequestManager>(); grid = GetComponent <Grid>(); }
void Awake() { requestManager = GetComponent <PathRequestManager> (); // grid = GetComponent<Grid> (); // grid = GetComponent<MapGenerator> ().MapGrid; }
void Awake() { // class is an instance of itself instance = this; pathFinding = GetComponent <Pathfinding>(); }
void Awake() { grid = GetComponent <Grid>(); requestManager = GetComponent <PathRequestManager>(); drawThis = true; }
void Awake() { instance = this; pathfinding = GetComponent <Pathfinding>(); }
/// <summary> /// Update del jugador en cada frame, si es su turno /// </summary> public void UpdatePlayer() { Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition); // posición del raycast donde está el mouse RaycastHit hit; GridNode selectedNode = null; if (Physics.Raycast(cameraRay, out hit, 100f, _groundMask)) { selectedNode = PathRequestManager.RequestNodeFromWorldPosition(hit.point); // obtiene el nodo de la grid bajo el mouse } if (type == PlayerType.User) // Update del equipo del jugador { if (selectedNode != null && Input.GetMouseButtonDown(0)) { OnPlayerLeftClick(selectedNode); //Comprobar input del jugador } } else // Update del equipo controlado por la IA { Unit chip = team.units[_enemyIndex]; if (chip != _selectedUnit) { GridNode selectedNodeChip = chip.GetGridNode(); // obtiene el nodo de la grid bajo de la ficha UnitSelection(chip); // _selectedUnit pasa a ser chip y se muestrean las casillas accesibles _enemyTimer = 0; _movida = false; } else if (_enemyTimer >= _hoverTime * 1.5) { if (!_movida) { GridNode newNode; newNode = BestNodeSelection(chip); // devuelve la mejor casilla accesible if (newNode == null) { chip.EnableUnit(false); // si no hay buenos resultados, no hacer nada } else { OnSelectedUnit(newNode); // se mueve al nodo elegido y lo deselecciona } _movida = true; } _enemyIndex++; } else { _enemyTimer += Time.deltaTime; } } //Si el mouse del jugador simplemente se encuentra encima de una casilla no vacia if (selectedNode != null) { //Comprobar si esta ocupada por una unidad if (selectedNode.isOccupied != null && selectedNode.isOccupied.tag == "Unit") { Unit unit = (Unit)selectedNode.isOccupied; if (unit != _hoveredUnit) //Comprobar si es una unidad diferente { UnitInfoManager.instance.HideLevelInfo(); UnitInfoManager.instance.HideAdvantageInfo(); _hoverTimer = 0; _hoveredUnit = unit; } else //Si es el mismo { if (_hoverTimer >= _hoverTime) //Ha pasado el tiempo minimo para que { UnitInfoManager.instance.ShowLevelInfo(_hoveredUnit); //Mostrar nivel if (_selectedUnit != null && _selectedUnit.unitTeam != _hoveredUnit.unitTeam) //Si tenemos otra unidad seleccionada y sobre la que estamos es de otro equipo { UnitInfoManager.instance.ShowAdvantageInfo(_selectedUnit, _hoveredUnit); //Mostrar ventaja en combate } } else { _hoverTimer += Time.deltaTime; } } } else { UnitInfoManager.instance.HideAdvantageInfo(); UnitInfoManager.instance.HideLevelInfo(); } } }
public void Awake() { requestManager = GetComponent<PathRequestManager>(); }
private void Awake() { instance = this; pathfinding = GetComponent <Pathfinding>(); pathRequestQueue = new Queue <PathRequest>(); }
void Start() { managerContext = this; targetFinder = GetComponent<PathFinding>(); }
Pathfinding pathfinding; // Reference to the pathfinding script // Executes at the start of a game private void Awake() { instance = this; // Makes sure there is only one instance of the class ? pathfinding = GetComponent <Pathfinding>(); // Loads the pathfinding functions }
void Awake() { requestManager = GetComponent <PathRequestManager>(); grid = GetComponent <QuadTree>(); }
void RequestPathToTarget(Transform target) { PathRequestManager.RequestPath(new PathRequest(entity.transform.position, target.position, OnPathFound)); }
void Awake() { instance = this; PathFinder = GetComponent<PathFinding>(); }
void RequestPathToTarget(Vector3 target) { PathRequestManager.RequestPath(new PathRequest(entity.transform.position, target, OnPathFound)); //Debug.Log("Target: " + target); lineOnScreen(target); }
void Awake() { requestManager = GetComponent<PathRequestManager>(); grid = GetComponent<QuadTree>(); }
private void Awake() { requestManger = GetComponent <PathRequestManager>(); grid = this.GetComponent <NodeGrid>(); }
void Awake() { instance = this; pathfinding = GetComponent<Pathfinding> (); }
void Awake() { requestManager = GetComponent<PathRequestManager>(); sphericalGrid = GetComponent<SphericalGrid>(); }