コード例 #1
0
    //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);
    }
コード例 #2
0
 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);
 }
コード例 #3
0
    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;
        }
    }
コード例 #4
0
    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;
    }
コード例 #5
0
    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);
    }
コード例 #6
0
 public void Remove(PlacementArea area, Placable oldPlacable)
 {
     area.RemoveFromArea(oldPlacable);
     Destroy(oldPlacable.gameObject);
 }
コード例 #7
0
 public Placable PlaceAt(PlacementArea area, PlacableData placable, Vector3 position, bool onNav = false)
 {
     return(PlaceAt(area, placable, position, Vector3.zero, onNav));
 }
コード例 #8
0
 public void RestoreArea()
 {
     currentArea = tempArea;
 }