void Start() { highlightManager = HighlightManager.GetInstance(); client = FindObjectOfType <Client> (); this.pieces = new Piece[9, 9]; SetUpBoard(); }
private void Awake() { highlightManager = GetComponent <HighlightManager>(); functionLibrary = GetComponent <FunctionLibrary>(); selectedMorphBot = null; currentTime = initialTime; }
private void Awake() { if (instance == null) { instance = this; } }
//sets selectedPiece & legelMoves in BoardManager public void SelectPiece() { //Debug.Log ("Selecting piece at " + selectedX + ", " + selectedY); //selected coord is empty if (pieceStacks [selectedX, selectedY].Peek() == null) { Debug.Log("Slected Piece is null"); return; } //return if not my piece if (pieceStacks [selectedX, selectedY].Peek().isPlayerOne != boardManager.isPlayerOnesTurn) { Debug.Log("Not my piece"); //return; } //selected piece = top of stack at x, y boardManager.selectedPiece = pieceStacks [selectedX, selectedY].Peek(); GetLegalMoves(); HighlightManager.GetInstance().ShowLegalMoves(boardManager.legalMoves); //Debug.Log ("Piece at: " + selectedX + ", " + selectedY + " = "); //Debug.Log (pieceStacks [selectedX, selectedY].Peek ()); //Debug.Log (board.selectedPiece); }
protected void UpdateInteracting() { var ray = new Ray(transform.position, transform.forward); RaycastHit hit; Transform objectToInteractWith = null; if (Physics.Raycast(ray, out hit, raycastDistance, grabbedInteractableMask.value, QueryTriggerInteraction.Collide)) { // Debug.Log("Hiting object to interact with"); objectToInteractWith = hit.transform; if (InteractingObject.OnGrabbedHighlight(hit.transform)) { // UpdateGrabbedHighlight(hit.transform); if (highlightedGrabbedObject) { highlightedGrabbedObject.OffHighlight(); } var highlight = hit.transform.GetComponent <HighlightManager>(); if (highlight) { highlightedGrabbedObject = highlight; highlight.OnHighlight(); } } else { if (highlightedGrabbedObject) { highlightedGrabbedObject.OffHighlight(); } } } else { if (highlightedGrabbedObject) { highlightedGrabbedObject.OffHighlight(); } } InteractingObject.LogicUpdate(); if (IsClickDown()) { // interacting = false; interacting = !interactingObject.OffInteract(this, objectToInteractWith); if (!interacting) { if (highlightedGrabbedObject) { highlightedGrabbedObject.OffHighlight(); } } } }
// Update is called once per frame private void OnMouseDown() { if (!EventSystem.current.IsPointerOverGameObject()) { //Do your thing. HighlightManager.Highlight(tile); } }
public void OnEndDrag(PointerEventData eventData) { foreach (GameObject node in HighlightManager.hlNodes) { GridManager.EnableNodeByPosition(node.transform.position.x, node.transform.position.y); } HighlightManager.ResetHl(); }
protected virtual void Awake() { highlightManager = GetComponent <HighlightManager>(); if (startInteractionWithGameStart) { StartInteraction(); } }
public override void Start() { base.Start(); characterController = GetComponent <CharacterController>(); animator = GetComponent <Animator>(); HUDController.gInstance.SetHP((int)health); HUDController.gInstance.SetWeaponDamage(attackDamage.ToString()); highlightManager = GetComponentInChildren <HighlightManager>(); cameraTarget = transform.Find("cameraTarget"); }
private static void HighlightSelected() { List <Unit> unitForHighlight = new List <Unit>(); unitForHighlight.AddRange(selectedObjects); foreach (var group in selectedGroups) { unitForHighlight.AddRange(group.units); } HighlightManager.HighlightUnits(unitForHighlight); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
void Awake() { if (Instance == null) { Instance = this; Highlitables = new HashSet <IHighlightable>(); } else { Destroy(gameObject); } }
protected virtual void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { DestroyImmediate(this); return; } }
private void Start() { mainCamera = gameObject.AddSceneComponent <Camera>(); mainCamera.transform.localPosition = new Vector3(3.5f, 9.0f, -1.0f); mainCamera.transform.localRotation = Quaternion.AngleAxis(67.0f, Vector3.right); spawnManager = new SpawnManager(this); actionManager = new ActionManager(this); highlightManager = new HighlightManager(this); spawnManager.InitialSpawn(); InitialTriggerBoxes(); actionManager.GameoverEvent += ActionManager_GameoverEvent; }
/* DESCRIPTION: * This method implements the A Algorithm. * Uses direct distance to the final city as a heuristic. * At each step finds the best next city to explore from citiesToExplore. * Finds the cities connected to it and examines them. * If the connected city is already found, then it examines is the new path to * it shorter than the already known one. If it is, than it renew the information * about the city in foundCities and citiesToExplore. * If the city has not been found yet, then it add it to citiesToExplore and * foundCities. * When all cities have been explored it finds the minimal path using the idea * that if the city B preceds the destination city A in the minimum path, * then the minimum path also includes the minimum path from the start city * to B. Thus, it goes from city to city in the reverse order and adds them * to the minimum path. */ public List<City> FindOptimalPath(City startCity, City endCity) { City nextCity; // Next city to explore CityInfo nextCityInfo; // Next city information CityInfo nextConnectedCityInfo; // Information about the currently examined city connected to nextCity CityInfo nextConnectedCityOldInfo; // Old information about the currently examined city List<City> nextCityConnections; // Connections of the nextCity Coordinates tempStartPoint, tempEndPoint; // Help variables. Store points on the map. City tempCity, tempPrevCity; // Help variables. Store consecutive sities in the optimal path CityInfo tempCityInfo; // Help variable. Stores a city's info HighlightManager highlightManager; // Start with the start city:)) nextCity = startCity; nextCityInfo = new CityInfo(this, startCity, null, endCity, 0); // Initialize foundCities = new Dictionary<City, CityInfo>(); citiesToExplore = new Dictionary<City, CityInfo>(); highlightManager = new HighlightManager(graphLayout); // Add the start city foundCities.Add(nextCity, nextCityInfo); citiesToExplore.Add(nextCity, nextCityInfo); // While we have cities to explore while (citiesToExplore.Count != 0) { // Find the next best city among citiesToExplore nextCity = FindBest(); highlightManager.MarkNode(nextCity, Graph_Colors.BestNode); Thread.Sleep(SLEEP_TIME); // Get its info and connections citiesToExplore.TryGetValue(nextCity, out nextCityInfo); citiesConnecitons.connections.TryGetValue(nextCity, out nextCityConnections); // Examine all the connections of the nextCity foreach (City nextConnectedCity in nextCityConnections) { highlightManager.MarkNode(nextConnectedCity, Graph_Colors.CheckedNode); highlightManager.MarkEdge(nextCity, nextConnectedCity, Graph_Colors.CheckedEdge); Thread.Sleep(SLEEP_TIME); // Get the examined city location and the nextCity location citiesLocations.locations.TryGetValue(nextCity, out tempStartPoint); citiesLocations.locations.TryGetValue(nextConnectedCity, out tempEndPoint); // Create information about the currently examined city nextConnectedCityInfo = new CityInfo(this, nextConnectedCity, nextCity, endCity, FindDistance(tempStartPoint, tempEndPoint) + nextCityInfo.getFromStart()); // If the examined city has already been found. // If the current path is better, then update the city's info if (foundCities.ContainsKey(nextConnectedCity)) { // Get the city's old info from foundCities foundCities.TryGetValue(nextConnectedCity, out nextConnectedCityOldInfo); // Compare its old path distance to the new path distance if (nextConnectedCityInfo.getPathDistance() < nextConnectedCityOldInfo.getPathDistance()) { // Update the info if the new path is shorter nextConnectedCityOldInfo.prevCity = nextConnectedCityInfo.prevCity; nextConnectedCityOldInfo.setFromStart(nextConnectedCityInfo.getFromStart()); highlightManager.MarkNode(nextConnectedCity, Graph_Colors.UpdatedNode); Thread.Sleep(SLEEP_TIME); } else { highlightManager.MarkNode(nextConnectedCity, Graph_Colors.RejectedNode); Thread.Sleep(SLEEP_TIME); } } // If we have not found this city so far. // Add it to foundCities and citiesToExplore. else { // Add the city to foundCities and citiesToExplore. foundCities.Add(nextConnectedCity, nextConnectedCityInfo); citiesToExplore.Add(nextConnectedCity, nextConnectedCityInfo); highlightManager.MarkNode(nextConnectedCity, Graph_Colors.AddedNode); Thread.Sleep(SLEEP_TIME); } } // Mark nextCity as explored. // Remove it from citiesToExplore nextCityInfo.IsExplored = true; citiesToExplore.Remove(nextCity); highlightManager.UnmarkAllNodes(); highlightManager.UnmarkAllEdges(); foreach (City city in foundCities.Keys) { foundCities.TryGetValue(city, out tempCityInfo); if (tempCityInfo.IsExplored) { highlightManager.MarkNode(city, Graph_Colors.ExploredNode); } } Thread.Sleep(SLEEP_TIME); } // If we were able to reach the destination, // then construct the optimal path. if (foundCities.ContainsKey(endCity)) { // Start with the end city tempCity = endCity; // Get the end city info foundCities.TryGetValue(tempCity, out tempCityInfo); // Initialize List<City> optimalPath = new List<City>(); // Add the end city to the optimal path optimalPath.Add(tempCity); // Set the city that preceds the end city in the optimal path tempPrevCity = tempCityInfo.prevCity; // While we have not reached the start city while (tempPrevCity != null) { // Add the city that preceds the current city in the optimal path tempCity = tempPrevCity; optimalPath.Add(tempCity); // Move to the previous city in the path in order to // add it in the next loop iteration. foundCities.TryGetValue(tempCity, out tempCityInfo); tempPrevCity = tempCityInfo.prevCity; } return (optimalPath); } // Output an error if the destination could not be reached. else { Console.WriteLine("ERROR! Cannot find any path."); return (null); } }
public void OnBeginDrag(PointerEventData eventData) { // Change Highlight Grid HighlightManager.HighlightByLocalPosition(p.localPos); }
void Start() { highlightManager = HighlightManager.GetInstance(); this.pieces = new Piece[9, 9]; SetUpBoard(); }
// Start is called before the first frame update void Start() { instance = this; texture = mat.mainTexture; }
void Awake() { instance = this; }
public static void ClearSelected() { selectedObjects.Clear(); selectedGroups.Clear(); HighlightManager.Clear(); }
public void DropPiece(int x, int y) { //check for move is legal if (boardManager.legalMoves [x, y]) { //pop top of stack //Debug.Log ((int)board.selectedPiece.transform.localPosition.x); //Debug.Log ((int)board.selectedPiece.transform.localPosition.y); Vector3 coord = boardManager.selectedPiece.transform.localPosition; pieceStacks [Mathf.RoundToInt(coord.x), Mathf.RoundToInt(coord.y)].Pop(); //set newPos to selected coordinate boardManager.pieces [x, y] = boardManager.selectedPiece; //.5 compensation for truncated floats to ints boardManager.selectedPiece.transform.position = new Vector3(x + .5f, 0, y + .5f); //cache new position boardManager.selectedPiece.GetCurrentPos(); //parent piece to the board object boardManager.selectedPiece.transform.SetParent(boardManager.transform); //switch turns boardManager.isPlayerOnesTurn = !boardManager.isPlayerOnesTurn; if (boardManager.selectedPiece.isPlayerOne) { boardManager.selectedPiece.transform.SetParent(GameObject.Find("Player 1").transform); } else { boardManager.selectedPiece.transform.SetParent(GameObject.Find("Player 2").transform); } boardManager.selectedPiece.isCaptured = false; boardManager.GetComponent <AudioSource> ().Play(); if (Settings.GetInstance().showScore) { try{ Score.GetInstance().UpdateScore(); } catch { Debug.LogError("Trying to update the score while disabled"); } } } else { Debug.Log("ILLEGAL DROP"); } //un-select piece boardManager.selectedPiece = null; HighlightManager.GetInstance().HideMoves(); if (AI.GetInstance().isActive&& boardManager.isPlayerOnesTurn) { AI.GetInstance().Go(); } }
protected void UpdateInteracting() { var ray = new Ray(transform.position, transform.forward); RaycastHit hit; Transform objectToInteractWith = null; if (Physics.Raycast(ray, out hit, raycastDistance, grabbedInteractableMask.value, QueryTriggerInteraction.Collide)) { // Debug.Log("Hiting object to interact with"); objectToInteractWith = hit.transform; if (InteractingObject.OnGrabbedHighlight(hit.transform)) { // UpdateGrabbedHighlight(hit.transform); if(highlightedGrabbedObject) highlightedGrabbedObject.OffHighlight(); var highlight = hit.transform.GetComponent<HighlightManager>(); if (highlight) { highlightedGrabbedObject = highlight; highlight.OnHighlight(); } } else { if (highlightedGrabbedObject) highlightedGrabbedObject.OffHighlight(); } } else { if(highlightedGrabbedObject) highlightedGrabbedObject.OffHighlight(); } InteractingObject.LogicUpdate(); if (IsClickDown()) { // interacting = false; interacting = !interactingObject.OffInteract(this, objectToInteractWith); if (!interacting) { if (highlightedGrabbedObject) highlightedGrabbedObject.OffHighlight(); } } }
public void DropPiece(int x, int y) { //check for move is legal if (boardManager.legalMoves [x, y]) { Debug.Log("SHOULD BE SENDING DROP TO SERVER"); Vector3 coord = boardManager.selectedPiece.transform.localPosition; if (boardManager.client != null && boardManager.client.isHost == boardManager.isPlayerOnesTurn) { string msg = "CDROP|"; msg += coord.x.ToString() + "|"; msg += coord.y.ToString() + "|"; msg += x.ToString() + "|"; msg += y.ToString() + "|"; boardManager.client.Send(msg); } pieceStacks [Mathf.RoundToInt(coord.x), Mathf.RoundToInt(coord.y)].Pop(); //set newPos to selected coordinate boardManager.pieces [x, y] = boardManager.selectedPiece; //.5 compensation for truncated floats to ints boardManager.selectedPiece.transform.position = new Vector3(x + .5f, 0, y + .5f); //cache new position boardManager.selectedPiece.GetCurrentPos(); //parent piece to the board object boardManager.selectedPiece.transform.SetParent(boardManager.transform); //switch turns boardManager.isPlayerOnesTurn = !boardManager.isPlayerOnesTurn; //organize piece gameobject if (boardManager.selectedPiece.isPlayerOne) { boardManager.selectedPiece.transform.SetParent(GameObject.Find("Player 1").transform); } else { boardManager.selectedPiece.transform.SetParent(GameObject.Find("Player 2").transform); } boardManager.selectedPiece.isCaptured = false; boardManager.GetComponent <AudioSource> ().Play(); //update score if (Settings.GetInstance().showScore) { try{ Score.GetInstance().UpdateScore(); } catch { Debug.LogError("Trying to update the score while disabled"); } } } else { Debug.Log("ILLEGAL DROP"); } //un-select piece boardManager.selectedPiece = null; HighlightManager.GetInstance().HideMoves(); //AI Go if (AI.GetInstance().isActive&& boardManager.isPlayerOnesTurn) { AI.GetInstance().Go(); } }
/* DESCRIPTION: * This method implements the A Algorithm. * Uses direct distance to the final city as a heuristic. * At each step finds the best next city to explore from citiesToExplore. * Finds the cities connected to it and examines them. * If the connected city is already found, then it examines is the new path to * it shorter than the already known one. If it is, than it renew the information * about the city in foundCities and citiesToExplore. * If the city has not been found yet, then it add it to citiesToExplore and * foundCities. * When all cities have been explored it finds the minimal path using the idea * that if the city B preceds the destination city A in the minimum path, * then the minimum path also includes the minimum path from the start city * to B. Thus, it goes from city to city in the reverse order and adds them * to the minimum path. */ public List <City> FindOptimalPath(City startCity, City endCity) { City nextCity; // Next city to explore CityInfo nextCityInfo; // Next city information CityInfo nextConnectedCityInfo; // Information about the currently examined city connected to nextCity CityInfo nextConnectedCityOldInfo; // Old information about the currently examined city List <City> nextCityConnections; // Connections of the nextCity Coordinates tempStartPoint, tempEndPoint; // Help variables. Store points on the map. City tempCity, tempPrevCity; // Help variables. Store consecutive sities in the optimal path CityInfo tempCityInfo; // Help variable. Stores a city's info HighlightManager highlightManager; // Start with the start city:)) nextCity = startCity; nextCityInfo = new CityInfo(this, startCity, null, endCity, 0); // Initialize foundCities = new Dictionary <City, CityInfo>(); citiesToExplore = new Dictionary <City, CityInfo>(); highlightManager = new HighlightManager(graphLayout); // Add the start city foundCities.Add(nextCity, nextCityInfo); citiesToExplore.Add(nextCity, nextCityInfo); // While we have cities to explore while (citiesToExplore.Count != 0) { // Find the next best city among citiesToExplore nextCity = FindBest(); highlightManager.MarkNode(nextCity, Graph_Colors.BestNode); Thread.Sleep(SLEEP_TIME); // Get its info and connections citiesToExplore.TryGetValue(nextCity, out nextCityInfo); citiesConnecitons.connections.TryGetValue(nextCity, out nextCityConnections); // Examine all the connections of the nextCity foreach (City nextConnectedCity in nextCityConnections) { highlightManager.MarkNode(nextConnectedCity, Graph_Colors.CheckedNode); highlightManager.MarkEdge(nextCity, nextConnectedCity, Graph_Colors.CheckedEdge); Thread.Sleep(SLEEP_TIME); // Get the examined city location and the nextCity location citiesLocations.locations.TryGetValue(nextCity, out tempStartPoint); citiesLocations.locations.TryGetValue(nextConnectedCity, out tempEndPoint); // Create information about the currently examined city nextConnectedCityInfo = new CityInfo(this, nextConnectedCity, nextCity, endCity, FindDistance(tempStartPoint, tempEndPoint) + nextCityInfo.getFromStart()); // If the examined city has already been found. // If the current path is better, then update the city's info if (foundCities.ContainsKey(nextConnectedCity)) { // Get the city's old info from foundCities foundCities.TryGetValue(nextConnectedCity, out nextConnectedCityOldInfo); // Compare its old path distance to the new path distance if (nextConnectedCityInfo.getPathDistance() < nextConnectedCityOldInfo.getPathDistance()) { // Update the info if the new path is shorter nextConnectedCityOldInfo.prevCity = nextConnectedCityInfo.prevCity; nextConnectedCityOldInfo.setFromStart(nextConnectedCityInfo.getFromStart()); highlightManager.MarkNode(nextConnectedCity, Graph_Colors.UpdatedNode); Thread.Sleep(SLEEP_TIME); } else { highlightManager.MarkNode(nextConnectedCity, Graph_Colors.RejectedNode); Thread.Sleep(SLEEP_TIME); } } // If we have not found this city so far. // Add it to foundCities and citiesToExplore. else { // Add the city to foundCities and citiesToExplore. foundCities.Add(nextConnectedCity, nextConnectedCityInfo); citiesToExplore.Add(nextConnectedCity, nextConnectedCityInfo); highlightManager.MarkNode(nextConnectedCity, Graph_Colors.AddedNode); Thread.Sleep(SLEEP_TIME); } } // Mark nextCity as explored. // Remove it from citiesToExplore nextCityInfo.IsExplored = true; citiesToExplore.Remove(nextCity); highlightManager.UnmarkAllNodes(); highlightManager.UnmarkAllEdges(); foreach (City city in foundCities.Keys) { foundCities.TryGetValue(city, out tempCityInfo); if (tempCityInfo.IsExplored) { highlightManager.MarkNode(city, Graph_Colors.ExploredNode); } } Thread.Sleep(SLEEP_TIME); } // If we were able to reach the destination, // then construct the optimal path. if (foundCities.ContainsKey(endCity)) { // Start with the end city tempCity = endCity; // Get the end city info foundCities.TryGetValue(tempCity, out tempCityInfo); // Initialize List <City> optimalPath = new List <City>(); // Add the end city to the optimal path optimalPath.Add(tempCity); // Set the city that preceds the end city in the optimal path tempPrevCity = tempCityInfo.prevCity; // While we have not reached the start city while (tempPrevCity != null) { // Add the city that preceds the current city in the optimal path tempCity = tempPrevCity; optimalPath.Add(tempCity); // Move to the previous city in the path in order to // add it in the next loop iteration. foundCities.TryGetValue(tempCity, out tempCityInfo); tempPrevCity = tempCityInfo.prevCity; } return(optimalPath); } // Output an error if the destination could not be reached. else { Console.WriteLine("ERROR! Cannot find any path."); return(null); } }
protected virtual void Awake() { highlightManager = GetComponent<HighlightManager>(); if(startInteractionWithGameStart) StartInteraction(); }
private void Awake() { audioSource = GetComponent <AudioSource>(); highlightManager = GetComponent <HighlightManager>(); qManager = GetComponentInChildren <QuestionManager>(); }