public void CreatePheromoneTrail(PheromoneNode home, PheromoneNode away, GV.PhermoneTypes pherType) { PheromoneTrail newPt = Instantiate <GameObject>(phermoneTrailPrefab).GetComponent <PheromoneTrail>(); newPt.GetComponent <DrawLineSprite>().Initialize(new Vector2(), new Vector2()); newPt.Initialize(home, away, pherType); pheromoneTrails.Add(newPt); }
private PheromoneNode RetrieveNewNode(GV.PhermoneTypes pherType, Vector2 spawnLocation) { GameObject newNodeGO = Instantiate(phermoneNodePrefab, spawnLocation, Quaternion.identity) as GameObject; PheromoneNode newNode = newNodeGO.GetComponent <PheromoneNode>(); newNode.initialRoot = true; pheromoneNodes.Add(newNode); return(newNode); }
public void Initialize(PheromoneNode _home, PheromoneNode _away, GV.PhermoneTypes _pherType) { pherType = _pherType; pHome = _home; pAway = _away; strength = GV.PHEROMONE_START_ENERGY; if (pHome && pAway) { drawTrail.Initialize(pHome.transform.position, pAway.transform.position); } }
public static PheromoneNode DropPheromone(PheromoneNode parentNode, GV.PhermoneTypes pherType, Vector2 atPos) { List <PheromoneNode> allNearbyPher = GetAllNearbyByTag <PheromoneNode>("Node", GV.PHEROMONE_PLACEMENT_ABSORPTION_RADIUS, atPos); if (allNearbyPher.Contains(parentNode) && !parentNode.immortal) //this means parent node will be consumed, so it cannot be a parent { parentNode = null; } PheromoneNode pn = FindObjectOfType <PheromoneManager>().CreateNewNode(parentNode, pherType, atPos); foreach (PheromoneNode toMerge in allNearbyPher) { if (!toMerge.immortal && !toMerge.initialRoot) { pn.AbsorbNode(toMerge); } } return(pn); }
public PheromoneNode CreateNewNode(PheromoneNode parentNode, GV.PhermoneTypes pherType, Vector2 spawnLocation) { if (parentNode == null) { return(RetrieveNewNode(pherType, spawnLocation)); } GameObject newNodeGO = Instantiate(phermoneNodePrefab, spawnLocation, Quaternion.identity) as GameObject; GameObject newTrailGO = Instantiate <GameObject>(phermoneTrailPrefab); PheromoneNode newNode = newNodeGO.GetComponent <PheromoneNode>(); PheromoneTrail newTrail = newTrailGO.GetComponent <PheromoneTrail>(); newTrail.Initialize(parentNode, newNode, pherType); parentNode.AddTrail(newTrail); parentNode.initialRoot = false; newNode.InitializeNode(newTrail); pheromoneNodes.Add(newNode); pheromoneTrails.Add(newTrail); return(newNode); }