public void OnMouseDown() { Vector2 clickPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D[] hits = Physics2D.RaycastAll(clickPoint, Vector2.zero); PheromoneNode clickedNode = null; if (hits.Length != 0) { foreach (RaycastHit2D rhit in hits) //def better way of doing this, but debug function { if (rhit.transform.CompareTag("Node")) { clickedNode = rhit.collider.gameObject.GetComponent <PheromoneNode>(); } } } if (clickedNode) //if not null { SetNewLastClicked(clickedNode); } else //otherwise make a new one { SetNewLastClicked(PheromoneManager.DropPheromone(lastClicked, GV.PhermoneTypes.Friendly, clickPoint)); } foreach (PheromoneTrail pt in FindObjectsOfType <PheromoneTrail>()) { pt.strength = 40; } }
PheromoneNode DropPheromoneOnExistingTrail(PheromoneTrail pt) { PheromoneNode pn = PheromoneManager.DropPheromone(lastVisitedNode, GetPherType(), transform.position); if (lastVisitedNode) { lastVisitedNode.initialRoot = false; } lastVisitedNode = pn; timeSinceLastEvent = 0; //pt.SplitByNode(pn); return(pn); }
PheromoneNode DropPheromone(Transform foodLoc) { PheromoneNode pn = PheromoneManager.DropPheromone(lastVisitedNode, GetPherType(), foodLoc.position); if (lastVisitedNode) { lastVisitedNode.initialRoot = false; } lastVisitedNode = pn; timeSinceLastEvent = 0; ArriveAtNode(pn); return(pn); }
void RightClick() { if (playerEnergy > GV.PLAYER_CLICK_E_COST) { bool bnsDmg = lastNode != null; onTheMove = true; goalLocation = GetMousePosition(); playerEnergy -= GV.PLAYER_CLICK_E_COST; lastNode = PheromoneManager.DropPheromone(lastNode, GV.PhermoneTypes.Friendly, transform.position); if (bnsDmg && lastNode.trails.Count > 0 && lastNode.trails[0] != null) { lastNode.trails[0].strength = (int)GV.PLAYER_PHER_START; } } }