//might move listening to individual placement areas. public void OnEndDrag(EndDragEvent ev) { //temp solution if (RoadCheck(ev.obj)) { return; } PlacementArea targetArea = null; SIZE buildingSize = ev.obj.GetComponent <PlaceableObject>().Size; foreach (PlacementArea pa in placementAreas) { pa.DisableLight(); if (pa.IsMarked && pa.Size.Equals(buildingSize)) { targetArea = pa; } } if (targetArea == null) { Destroy(ev.obj); return; } ev.obj.GetComponent <PlaceableObject>().SnapToArea(targetArea); }
private void StartPlacement() { playArea = Instantiate(PlayAreaPrefab).GetComponent <PlayArea>(); playArea.transform.SetParent(provider.GetRoot()); currentArea = playArea; currentAreaType = AreaType.Play; //buildArea = BuildAreaPrefab.GetComponent<BuildArea>(); //cookArea = CookAreaPrefab.GetComponent<CookArea>(); //UIManager.Instance.ShowUI(HelpUI.gameObject); LoadingUI.SetActive(false); HelpUI.gameObject.SetActive(true); }
public void SetTempArea(AreaType areaType) { tempArea = currentArea; switch (areaType) { case AreaType.None: currentArea = null; break; case AreaType.Play: currentArea = playArea; break; case AreaType.Build: currentArea = buildArea; break; case AreaType.Cook: currentArea = cookArea; break; } }
public void SetArea(AreaType areaType) { if (currentArea != null) { currentArea.gameObject.SetActive(false); } if (provider != null) { switch (areaType) { case AreaType.None: provider.TurnOff(); currentArea = null; break; case AreaType.Play: provider.TurnOn(); currentArea = playArea; break; case AreaType.Build: provider.TurnOff(); currentArea = buildArea; break; case AreaType.Cook: provider.TurnOff(); currentArea = cookArea; break; } } if (currentArea != null) { currentArea.gameObject.SetActive(true); } lastAreaType = currentAreaType; currentAreaType = areaType; }
public Placable PlaceAt(PlacementArea area, PlacableData placable, Vector3 position, Vector3 rotation, bool onNav = false) { Placable newPlacable = null; if (onNav) { newPlacable = Instantiate(placable.Prefab, GetWorldNavPos(position), Quaternion.identity).GetComponent <Placable>(); newPlacable.Data = placable; newPlacable.transform.SetParent(area.Contents); } else { newPlacable = Instantiate(placable.Prefab).GetComponent <Placable>(); newPlacable.Data = placable; newPlacable.transform.SetParent(area.Contents); newPlacable.transform.localPosition = position; } newPlacable.transform.localRotation = Quaternion.Euler(rotation); newPlacable.transform.localScale = Vector3.one; area.AddToArea(newPlacable); return(newPlacable); }
public void Remove(PlacementArea area, Placable oldPlacable) { area.RemoveFromArea(oldPlacable); Destroy(oldPlacable.gameObject); }
public Placable PlaceAt(PlacementArea area, PlacableData placable, Vector3 position, bool onNav = false) { return(PlaceAt(area, placable, position, Vector3.zero, onNav)); }
public void RestoreArea() { currentArea = tempArea; }