private void Awake() { GameObject GameManager = GameObject.Find("GameManager"); instance = this; agentsManager = GameManager.GetComponent <ThreeAgents>(); }
private void Awake()//Ran once the program starts { instance = this; GameObject player2 = GameObject.Find("Lumberjack2"); player2.SetActive(false); GameObject player3 = GameObject.Find("Lumberjack3"); player3.SetActive(false); fNodeDiameter = fNodeRadius * 2; //Double the radius to get diameter iGridSizeX = Mathf.RoundToInt(vGridWorldSize.x / fNodeDiameter); //Divide the grids world co-ordinates by the diameter to get the size of the graph in array units. iGridSizeY = Mathf.RoundToInt(vGridWorldSize.y / fNodeDiameter); //Divide the grids world co-ordinates by the diameter to get the size of the graph in array units. CreateGrid(); //Draw the grid if (scenario == Scenario.Known && algorithm == Algorithm.AStar) { print("Scenario : " + scenario + ", Algorithm = " + algorithm); PathfindingA PAscript = this.gameObject.AddComponent(typeof(PathfindingA)) as PathfindingA; GameObject player = GameObject.Find("Agent"); Unit unitScript = player.gameObject.AddComponent(typeof(Unit)) as Unit; unitScript.enabled = true; PAscript.enabled = true; } else if (scenario == Scenario.Known && algorithm == Algorithm.Dijkstra) { print("Scenario : " + scenario + ", Algorithm = " + algorithm); Dijkstra DIJscript = this.gameObject.AddComponent(typeof(Dijkstra)) as Dijkstra; GameObject player = GameObject.Find("Agent"); UnitDijkstra unitDijkstraScript = player.gameObject.AddComponent(typeof(UnitDijkstra)) as UnitDijkstra; unitDijkstraScript.enabled = true; DIJscript.enabled = true; } else if (scenario == Scenario.Unknown && searchMode == SearchMode.CellByCell) { print("Scenario : " + scenario + ", Search Mode : " + searchMode + " , Algorithm = " + algorithm); GameObject player = GameObject.Find("Agent"); UnitSearchUnkCell UnitSearchscript = player.gameObject.AddComponent(typeof(UnitSearchUnkCell)) as UnitSearchUnkCell; UnitSearchscript.enabled = true; } else if (scenario == Scenario.Unknown && searchMode == SearchMode.Randomly) { print("Scenario : " + scenario + ", Search Mode : " + searchMode + " , Algorithm = " + algorithm); GameObject player = GameObject.Find("Agent"); UnitRandom UnitRandomscript = player.gameObject.AddComponent(typeof(UnitRandom)) as UnitRandom; UnitRandomscript.enabled = true; } else if (scenario == Scenario.ThreeAgents) { player2.SetActive(true); player3.SetActive(true); print("Scenario : " + scenario + ", Algorithm = " + algorithm); ThreeAgents CompThreeAgents = this.gameObject.AddComponent(typeof(ThreeAgents)) as ThreeAgents; CompThreeAgents.enabled = true; } }
private void Awake() { instance = this; player2 = GameObject.Find("Lumberjack2"); player3 = GameObject.Find("Lumberjack3"); player = GameObject.Find("Agent"); lostForestPlayer = player.GetComponent <LostForest>(); lostForestPlayer2 = player2.GetComponent <LostForest>(); lostForestPlayer3 = player3.GetComponent <LostForest>(); allMovableThings = GameObject.FindGameObjectsWithTag("avoidSpawn"); }