public IEnumerator IndicatorColorIsRedNearObstacles() { GameObject baseTower = GameObject.Find("BaseTower"); Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", baseTower, hit.point); yield return(new WaitForSeconds(0.5f)); GameObject pointer = GameObject.Find("PlacementIndicator(Clone)"); // Create a tower at same point to work as an obstacle GameObject.Instantiate(GameObject.Find("BaseTower"), pointer.transform.position, pointer.transform.rotation); yield return(new WaitForSeconds(0.5f)); Assert.AreEqual(new Color(1, 0, 0, 0.3f), pointer.GetComponent <Renderer>().material.GetColor("_BaseColor")); }
public IEnumerator StartTowerUpgradeFromTowerMenuUI() { // Create the tower menu UI GameObject baseTower = GameObject.Find("BaseTower"); EventRegistry.Invoke("showMenu", baseTower, typeof(TowerMenuUISystem)); GameObject towerMenu = GameObject.Find("TowerMenuUI"); // Bring up the upgrade UI towerMenu.GetComponent <TowerMenuUISystem>().OnUpgradeClick(); GameObject upgradeMenu = GameObject.Find("UpgradeUI"); yield return(null); Assert.True(upgradeMenu.activeSelf); Assert.False(towerMenu.activeSelf); }
public IEnumerator IndicatorPlacesTower() { GameObject baseTower = GameObject.Find("BaseTower"); Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", baseTower, hit.point); yield return(new WaitForSeconds(0.5f)); // Create a tower through its intended pathway TowerPlacer placer = GameObject.Find("PlacementIndicator(Clone)").GetComponent <TowerPlacer>(); placer.SetTower(GameObject.Find("BaseTower")); placer.PlaceTower(); yield return(new WaitForSeconds(0.5f)); Assert.IsNotNull(GameObject.Find("BaseTower(Clone)")); }
public IEnumerator IndicatorCanToggle() { GameObject baseTower = GameObject.Find("BaseTower"); Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", baseTower, hit.point); yield return(new WaitForSeconds(1f)); Assert.IsNotNull(GameObject.Find("PlacementIndicator(Clone)")); // Call it again to remove the placer // This call doesn't use the parameters so nulls should work too EventRegistry.Invoke <GameObject, Vector3>("togglePlacer", null, Vector3.zero); yield return(new WaitForSeconds(0.5f)); Assert.IsNull(GameObject.Find("PlacementIndicator(Clone)")); }
public IEnumerator StartTowerMoveFromTowerUI() { // Create the tower menu UI GameObject baseTower = GameObject.Find("BaseTower"); EventRegistry.Invoke("showMenu", baseTower, typeof(TowerMenuUISystem)); GameObject towerMenu = GameObject.Find("TowerMenuUI"); // Bring up the move tool towerMenu.GetComponent <TowerMenuUISystem>().OnMoveClick(); GameObject indicator = GameObject.Find("PlacementIndicator(Clone)"); bool check = indicator.GetComponent <TowerPlacer>().PlaceTower(); yield return(null); Assert.IsTrue(check); Assert.IsNotNull(GameObject.Find("BaseTower(Clone)")); }
void Update() { // Check left mouse click or "select" if (Input.GetButtonDown("Fire1")) { if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) { GameObject hitObject = hit.transform.parent.gameObject; if (hitObject.CompareTag("Tower")) { showMenu.Invoke(hitObject, typeof(TowerMenuUISystem)); } } } // Check right mouse click or "walk" if (Input.GetButtonDown("Fire2")) { if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) { player.GetComponent <AIController>().MoveTo(hit.point); } } // Check escape button or "cancel" if (Input.GetButtonDown("Cancel")) { hideMenu.Invoke(); } // TODO: Use input mappings here // Check the X button or "place", toggle the selector if (Input.GetKeyDown(KeyCode.X)) { Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", BaseTower, hit.point, false); } if (Input.GetKeyDown(KeyCode.P)) { EventRegistry.Invoke("pause"); } }
public IEnumerator IndicatorMovesWithCursor() { GameObject baseTower = GameObject.Find("BaseTower"); Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", baseTower, hit.point); yield return(new WaitForSeconds(0.5f)); Vector3 initial = GameObject.Find("PlacementIndicator(Clone)").transform.position; // TODO: Find a better way to move here. UI testing? Ideally I should be able to move the cursor // remove it EventRegistry.Invoke("togglePlacer", baseTower, hit.point); // spawn it at another location EventRegistry.Invoke("togglePlacer", baseTower, hit.point + new Vector3(1, 1, 1)); yield return(new WaitForSeconds(0.5f)); Assert.AreNotEqual(initial, GameObject.Find("PlacementIndicator(Clone)").transform.position); }
public IEnumerator CanUpgradeToRedTower() { // Create the upgrade menu UI GameObject baseTower = GameObject.Find("BaseTower"); EventRegistry.Invoke("showMenu", baseTower, typeof(UpgradeMenuUISystem)); GameObject upgradeMenu = GameObject.Find("UIManager/UpgradeUI"); UpgradeMenuUISystem component = upgradeMenu.GetComponent <UpgradeMenuUISystem>(); // Create the red tower and store initial position for comparison Vector3 initial = baseTower.transform.position; component.CreateTower(ETowerType.Red); yield return(new WaitForSeconds(0.5f)); GameObject redTower = GameObject.Find("RedTower(Clone)"); Assert.IsNotNull(redTower); Assert.AreEqual(initial, redTower.transform.position); }
void Update() { // Check left mouse click or "select" if (Input.GetButtonDown("Fire1")) { if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) { GameObject hitObject = hit.transform.parent.gameObject; if (hitObject.CompareTag("Tower")) { // TODO: This should fire an even instead. uiManager.ShowTowerMenu(hitObject); } } } // Check right mouse click or "walk" if (Input.GetButtonDown("Fire2")) { if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) { player.GetComponent <AIController>().MoveTo(hit.point); } } // Check escape button or "cancel" if (Input.GetButtonDown("Cancel")) { // TODO: This should fire an event instead. uiManager.HideAll(); } // Check the X button or "place", toggle the selector if (Input.GetKeyDown(KeyCode.X)) { Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, LayerMask.GetMask("Ground")); EventRegistry.Invoke("togglePlacer", BaseTower, hit.point); } }