public void CreateOBJ(ItemPrefab item, UnderGrid gridTo, int Plan) { GameObject TempOBJ = Instantiate(item.PrefabItem) as GameObject; if (item.nameItem == "Start Level") { if (SpawnPosition != null) { for (int j = 0; j < 4; j++) { for (int i = 0; i < 3; i++) { if (SpawnPosition.SousGrid[j].Plans[i] != null) { if (SpawnPosition.SousGrid[j].Plans[i].name == "0$1") { Destroy(SpawnPosition.SousGrid[j].Plans[i]); } } } } SpawnPosition = null; } SpawnPosition = gridTo.MasterGrid; } gridTo.AddOBJ(item, TempOBJ, MapHolder, Plan); }
void Update() { if (!CoreGame.m_pCoreGame.m_pDynamicLoader.IsLoading) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray ray2 = CameraGUI.camera.ScreenPointToRay(Input.mousePosition); if (!Physics.Raycast(ray, Mathf.Infinity)) { CurrentMasterGrid = null; CurrentUnderGrid = null; } if (Physics.Raycast(ray2, out HitGUI, Mathf.Infinity)) { if (HitGUI.collider.gameObject.tag == "UIElement") { Debug.Log("Currently On GUI"); Eventsys.SetActive(true); CurrentMasterGrid = null; CurrentUnderGrid = null; } else { Eventsys.SetActive(false); } } else { Eventsys.SetActive(false); } if (Input.GetMouseButton(0) && CurrentMasterGrid != null) { GridMapper.CreateOBJ(CurrentObjectToPlace, CurrentUnderGrid, CurrentPlan); } if (Input.GetMouseButton(1) && Input.GetKey(KeyCode.LeftControl) && CurrentMasterGrid != null) { for (int i = 0; i < 3; i++) { if (CurrentUnderGrid.Plans[i] != null) { if (CurrentUnderGrid.Plans[i].name == "0$1") { GridMapper.SpawnPosition = null; } Destroy(CurrentUnderGrid.Plans[i]); } } } else if (Input.GetMouseButton(1) && CurrentMasterGrid != null) { if (CurrentUnderGrid.Plans[CurrentPlan] != null) { if (CurrentUnderGrid.Plans[CurrentPlan].name == "0$1") { GridMapper.SpawnPosition = null; } Destroy(CurrentUnderGrid.Plans[CurrentPlan]); } } } }