예제 #1
0
        public OfferDetailScene(JobOffer offer, PlaceState state, bool isRescheduling = false) : base(offer.Company)
        {
            this.isRescheduling     = isRescheduling;
            this.offer              = offer;
            this.place              = state;
            isOfferDestinationOwned = WorldState.PlaceOwned(this.offer.To);
            distance    = this.offer.GetDistanceInKm();
            travelHours = this.offer.GetTravelTime();

            List <TabControlItemWidget> tabs = new List <TabControlItemWidget>();

            for (int i = 0; i < place.Docks.Count; i++)
            {
                var item = place.Docks[i];
                var tab  = new TabControlItemWidget(this, "Dock " + (i + 1), item);
                tab.OnClick += Tab_OnClick;
                tabs.Add(tab);
                var newSchedule = new ScheduleWidget(this, item.Schedule, offer, item.Unlocked, isRescheduling);
                newSchedule.OnNewShipTimeSelected += NewSchedule_OnNewShipTimeSelected;
                schedules.Add(newSchedule);
            }
            tabcontrol           = new TabControlWidget(this, tabs);
            employeeFinderWidget = new EmployeeFinderWidget(this);
            employeeFinderWidget.OnEmployeeSelected += EmployeeFinderWidget_OnEmployeeSelected;

            checkmarkWidget = new CheckmarkWidget("Stay At Destination");
            checkmarkWidget.OnCheckChanged += CheckmarkWidget_OnCheckChanged;

            buttonAccept          = new DetailButtonWidget(true);
            buttonAccept.Text     = "Accept";
            buttonAccept.OnClick += ButtonAccept_OnClick;
        }
예제 #2
0
        private void applyJobFactors(PlaceState place, JobOffer offer)
        {
            if (offer.TrustFactor < 1.0f)
            {
                foreach (var dock in place.Docks)
                {
                    var schedule = dock.Schedule;
                    for (int i = 0; i < schedule.Jobs.Count; i++)
                    {
                        var item = schedule.Jobs[i];
                        if (item.Job.Id == offer.Id)
                        {
                            MessageLog.AddError(string.Format("{0} has cancelled your contract to ship {1} from {2} to {3}",
                                                              item.Job.Company,
                                                              item.Job.Item.Name,
                                                              item.Job.From.Name,
                                                              item.Job.To.Name));

                            schedule.Jobs.RemoveAt(i);
                            i--;
                        }
                    }
                }
            }
        }
예제 #3
0
        private void tsErase_Click(object sender, EventArgs e)
        {
            tsArrow.Checked  = false;
            tsPan.Checked    = false;
            tsMArrow.Checked = false;
            currentState     = PlaceState.ERASER;

            mapViewer1.Cursor = Cursors.Default;
        }
예제 #4
0
 public void EnableEditing(bool b)
 {
     if (!b)
      placeState = PlaceState.kDisabled;
       else if (placeState == PlaceState.kDisabled)
      placeState = PlaceState.kNone;
       else
      Debug.Log("what do you want from me!");
 }
예제 #5
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (isPlaceConnected())
        {
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                ChangeNumberOfPeople(1);
                if (placeState == PlaceState.vacant)
                {
                    placeState           = PlaceState.taken;
                    thisPlaceImage.color = ResourceManager.instance.occupiedPlaceColor;
                    ResourceManager.instance.AddResourceSurplace(this);
                }
                if (placeState == PlaceState.enemies & numberOfPeople >= numberOfEnemies)
                {
                    placeState = PlaceState.fighting;
                    ResourceManager.instance.currentFoodGrowth -= numberOfPeople;
                    thisPlaceImage.color = ResourceManager.instance.fightingPlaceColor;
                }

                if (placeState == PlaceState.fighting)
                {
                    if (ResourceManager.instance.currentFoodGrowth != 0)
                    {
                        ResourceManager.instance.currentFoodGrowth -= 1;
                    }
                }
            }
            else if (eventData.button == PointerEventData.InputButton.Middle)
            {
                Debug.Log("Middle click");
            }
            else if (eventData.button == PointerEventData.InputButton.Right)
            {
                if (numberOfPeople > 0 & placeState == PlaceState.fighting || placeState == PlaceState.enemies)
                {
                    if (numberOfPeople > 0)
                    {
                        ChangeNumberOfPeople(-1);
                        ResourceManager.instance.currentFoodGrowth += 1;
                    }
                }


                if (placeState == PlaceState.fighting & numberOfPeople < numberOfEnemies)
                {
                    placeState = PlaceState.enemies;
                }
            }
        }
    }
예제 #6
0
        public EmployeeDetailScene(EmployeeState employee, PlaceState state) : base(employee.Name + ", " + employee.Age + ", " + employee.Id)
        {
            this.employee    = employee;
            this.place       = state;
            assignableTrucks = state.Trucks.Where(e => e.Assignee == null || e == employee.AssignedTruck).ToList();

            if (this.employee.AssignedTruck != null)
            {
                for (int i = 0; i < assignableTrucks.Count; i++)
                {
                    var truck = assignableTrucks[i];
                    if (truck == employee.AssignedTruck)
                    {
                        selectedTruckIndex = i;
                        break;
                    }
                }
            }

            List <TabControlItemWidget> tabs = new List <TabControlItemWidget>();

            for (int i = 0; i < place.Docks.Count; i++)
            {
                var item = place.Docks[i];
                var tab  = new TabControlItemWidget(this, "Dock " + (i + 1), item);
                tab.OnClick += Tab_OnClick;
                tabs.Add(tab);
                var newSchedule = new ScheduleWidget(this, item.Schedule, null, item.Unlocked, false, employee);
                schedules.Add(newSchedule);
            }
            tabcontrol = new TabControlWidget(this, tabs);

            buttonAccept          = new DetailButtonWidget(true);
            buttonAccept.Text     = "Accept";
            buttonAccept.OnClick += ButtonAccept_OnClick;

            arrowButtonLeft           = new ArrowButtonWidget(PointingTo.Left);
            arrowButtonLeft.OnClick  += ArrowButtonLeft_OnClick;
            arrowButtonRight          = new ArrowButtonWidget(PointingTo.Right);
            arrowButtonRight.OnClick += ArrowButtonRight_OnClick;
            if (employee.AssignedTruck == null)
            {
                truckBanner = new BannerWidget("No Assigned Truck");
            }
            else
            {
                truckBanner = new TruckBannerWidget(employee.AssignedTruck);
            }
            truckBanner.Disabled = true;
        }
예제 #7
0
        private void tsPan_Click(object sender, EventArgs e)
        {
            tsArrow.Checked  = false;
            tsErase.Checked  = false;
            tsMArrow.Checked = false;
            currentState     = PlaceState.PAN;

            MemoryStream str = new MemoryStream(Properties.Resources.hand_cur);

            mapViewer1.Cursor = new Cursor(str);
            str.Close();
            tsLblSelX.Text = "";
            tsLblSelY.Text = "";
        }
예제 #8
0
        public void SetGridColor(PlaceState placeState)
        {
            switch (placeState)
            {
            case PlaceState.CanPlace:
                Grid.sprite = CanPlaceSprite;
                break;

            case PlaceState.CanNotPlace:
                Grid.sprite = CannotPlaceSprite;
                break;

            default:
                break;
            }
        }
예제 #9
0
        public ScheduleDetailScene(PlaceState state) : base("Schedule for " + state.Place.Name)
        {
            this.place = state;
            List <TabControlItemWidget> tabs = new List <TabControlItemWidget>();

            for (int i = 0; i < place.Docks.Count; i++)
            {
                var item = place.Docks[i];
                var tab  = new TabControlItemWidget(this, "Dock " + (i + 1), item);
                tab.OnClick += Tab_OnClick;
                tabs.Add(tab);
                var schedule = new ScheduleWidget(this, item.Schedule, null, item.Unlocked);
                schedule.OnScheduledOfferSelected += Schedule_OnScheduledOfferSelected;
                schedules.Add(schedule);
            }
            tabcontrol          = new TabControlWidget(this, tabs);
            buttonEdit          = new DetailButtonWidget(true);
            buttonEdit.OnClick += ButtonEdit_OnClick;
        }
예제 #10
0
    public void StateMachine()
    {
        switch (placeState)
        {
        case PlaceState.vacant:

            return;

        case PlaceState.taken:

            return;

        case PlaceState.grabing:


            return;

        case PlaceState.enemies:
            // show indicator
            if (isPlaceConnected())
            {
                ResourceManager.instance.GrowAngerEnemies();
            }
            return;

        case PlaceState.fighting:
            // launch indicator
            indicatorValue += (ResourceManager.instance.fightSpeed + 5 * (numberOfPeople - numberOfEnemies)) * Time.deltaTime;

            placeIndicator.fillAmount = indicatorValue * 0.01f;
            ResourceManager.instance.GrowAngerEnemies();
            if (indicatorValue >= 100)
            {
                ResourceManager.instance.currentFoodGrowth += numberOfPeople;
                placeState = PlaceState.taken;
                SetColorForPlace();
                ResourceManager.instance.AddResourceSurplace(this);
                SetPlaceImage();
            }
            return;
        }
    }
예제 #11
0
파일: Place.cs 프로젝트: FeedFestival/LG
    public bool ChangeState(PlaceState state)
    {
        if (State == PlaceState.Full)
        {
            return(false);
        }

        State = state;

        if (State == PlaceState.Idle)
        {
            Material.SetTextureScale("_MainTex", new Vector2(0.5f, 1f));
        }
        else
        {
            Material.SetTextureScale("_MainTex", new Vector2(-0.5f, 1f));
        }

        return(true);
    }
예제 #12
0
        private void StartJob(PlaceState place, ShipTimeAssignment assignee, ScheduledJob job)
        {
            if (!place.Employees.Contains(assignee.AssignedEmployee))
            {
                job.Job.JobWasCompletedUnsuccesfully();

                MessageLog.AddError(string.Format("{0} {1} missed their trip to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            var employee = assignee.AssignedEmployee;

            if (employee.AssignedTruck == null)
            {
                MessageLog.AddError(string.Format("{0} {1} does not have a truck to drive to {2} from {3} at {4}",
                                                  assignee.AssignedEmployee.Name,
                                                  assignee.AssignedEmployee.Id,
                                                  job.Job.To.Name, job.Job.From.Name, assignee.Time.ToString("h':'m''")));
                return;
            }

            if (employee.CurrentJob == null)
            {
                employee.CurrentLocation = null;
                place.Employees.Remove(assignee.AssignedEmployee);
                var activeJob = new ActiveJob(job, assignee, Time - TimeSpan.FromMinutes(Time.Minute % 15), employee);
                Money -= activeJob.GasPrice();

                employee.CurrentJob = activeJob;
                ActiveJobs.Add(activeJob);

                MessageLog.AddInfo(string.Format("{0} left {1}, driving to {2}", assignee.AssignedEmployee.Name, job.Job.From.Name, job.Job.To.Name));
            }
        }
예제 #13
0
        public PlaceDetailScene(BasePlace place) : base(place.Name)
        {
            this.state = WorldState.GetStateForPlace(place);
            state.OnEmployeeArrived += State_OnEmployeeArrived;

            employeeButton  = new DetailButtonWidget();
            offersButton    = new DetailButtonWidget();
            schedulesButton = new DetailButtonWidget();
            garageButton    = new DetailButtonWidget();

            employeeButton.Text  = "Employees";
            schedulesButton.Text = "Schedules";
            offersButton.Text    = "Job Offers";
            garageButton.Text    = "Garage";

            employeeButton.OnClick  += EmployeeButton_OnClick;
            offersButton.OnClick    += JobsButton_OnClick;
            schedulesButton.OnClick += SchedulesButton_OnClick;
            garageButton.OnClick    += GarageButton_OnClick;

            createEmployeeBanners();
            createJobBanners();
            createTruckBanners();
        }
예제 #14
0
 public void ResetPlacement()
 {
     roomStuffObject.SetActive(false);
     dataText.text = "Place First Anchor";
     placeState    = PlaceState.PLACE_ANCHOR;
 }
예제 #15
0
        public void Update()
        {
            if (Input.GetKey(KeyCode.Escape))
            {
                Application.Quit();
            }

            _QuitOnConnectionErrors();

            // Check that motion tracking is tracking.
            if (Session.Status != SessionStatus.Tracking)
            {
                const int lostTrackingSleepTimeout = 15;
                Screen.sleepTimeout = lostTrackingSleepTimeout;
                if (!m_IsQuitting && Session.Status.IsValid())
                {
                    // statusText.text = "Looking for surfaces";
                    //  SearchingForPlaneUI.SetActive(true);
                }

                return;
            }

            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            // Iterate over planes found in this frame and instantiate corresponding GameObjects to visualize them.
            Session.GetTrackables <DetectedPlane>(m_NewPlanes, TrackableQueryFilter.New);
            for (int i = 0; i < m_NewPlanes.Count; i++)
            {
                // Instantiate a plane visualization prefab and set it to track the new plane. The transform is set to
                // the origin with an identity rotation since the mesh for our prefab is updated in Unity World
                // coordinates.
                GameObject planeObject = Instantiate(TrackedPlanePrefab, Vector3.zero, Quaternion.identity,
                                                     transform);
                planeObject.GetComponent <DetectedPlaneVisualizer>().Initialize(m_NewPlanes[i]);
            }

            // Disable the snackbar UI when no planes are valid.
            Session.GetTrackables <DetectedPlane>(m_AllPlanes);
            // bool showSearchingUI = true;
            for (int i = 0; i < m_AllPlanes.Count; i++)
            {
                if (m_AllPlanes[i].TrackingState == TrackingState.Tracking)
                {
                    // showSearchingUI = false;
                    break;
                }
            }



            if (placeState != PlaceState.SHOW && placeState != PlaceState.START)
            {
                Touch touch;
                if (Input.touchCount > 0)

                {
                    touch = Input.GetTouch(0);
                    numTouches++;
                    if (touch.phase == TouchPhase.Began)
                    {
                        //statusText.text = "num touches:" + numTouches.ToString();
                        // Raycast against the location the player touched to search for planes.


                        TrackableHit      hit;
                        TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
                                                          TrackableHitFlags.FeaturePointWithSurfaceNormal;

                        if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
                        {
                            //  statusText.text = "hit pos:" + hit.Pose.position.ToString();

                            // first touch, place the anchor
                            if (placeState == PlaceState.PLACE_ANCHOR)
                            {
                                roomStuffObject.SetActive(true);
                                // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
                                // world evolves.
                                anchor = hit.Trackable.CreateAnchor(hit.Pose);

                                roomStuffObject.transform.position = hit.Pose.position;
                                anchorPos = hit.Pose.position;
                                roomStuffObject.transform.parent = anchor.transform;
                                // statusText.text = utilObject.ReportLocation();
                                placeState    = PlaceState.PLACE_HEADING;
                                dataText.text = "Place 2nd Anchor";
                            } // if placestate.anch
                            else if (placeState == PlaceState.PLACE_HEADING)
                            {
                                orientPos = hit.Pose.position;
                                Quaternion newRot = Quaternion.LookRotation(anchorPos - orientPos, Vector3.up);
                                roomStuffObject.transform.rotation = newRot;
                                placeState    = PlaceState.SHOW;
                                dataText.text = "";
                                placeButton.gameObject.SetActive(false);
                                navMeshBuilder.BuildNavMeshes();

                                TourGuide.SetActive(true);
                            }
                        }
                        else
                        {
                            // statusText.text = "No Hit";
                        }
                    }
                }
            }
        }
    void Update()
    {
        if (_placeState == PlaceState.Preview)
        {

            // If the mouse is over an UI element, don't show the place transform
            if (UICamera.hoveredObject)
            {
                _placeDisplay.gameObject.SetActive(false);
            }
            else
            {
                RaycastHit hit;
                // If the mouse if over the terrain
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, placeDistance, 1 << 9))
                {

                    _placeDisplay.gameObject.SetActive(true);
                    _placeDisplay.position = hit.point;
                    if (Input.GetMouseButtonDown(0))
                    {
                        _placePosition = hit.point;
                        switch (_placeType)
                        {
                            case PlaceType.Single:
                                Instantiate(BuildingPreview, _placePosition, _placeDisplay.rotation);
                                break;
                            case PlaceType.Drag:
                                // Instantiate at inital position
                                Transform t  = Instantiate(BuildingPreview, _placePosition, _placeDisplay.rotation) as Transform;
                        //        StartCoroutine(DragPlace(t));
                                break;
                        }
                    }
                }
                else
                {
                    // If not don't display the preview
                    _placeDisplay.gameObject.SetActive(false);
                }
            }

        }
        else if (_placeState == PlaceState.Placing)
        {
            if (!UICamera.hoveredObject)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    _placeState = PlaceState.Preview;
                    return;
                }
                else if (Input.GetMouseButtonDown(0))
                {
                    // Instantiate the building prefab and attatch the building constructor script
                    Instantiate(BuildingPreview, _placePosition, _placeDisplay.rotation);
                    _placeState = PlaceState.Preview;
                    return;
                }
            }
        }
    }
예제 #17
0
    // Update is called once per frame
    void Update()
    {
        if (placeState == PlaceState.kDisabled) return;

          if (mousePosition != Input.mousePosition)
          {
         if (currentCurve == null && !Input.GetMouseButtonDown(0))
         {
            placeState = PlaceState.kNone;
            return;
         }
         mousePosition = Input.mousePosition;
         Vector3 inWorldMousePos = GetInWorldMousePos();

         switch (placeState)
         {
            case PlaceState.kPoint:
               currentCurve.SetBezierPoint(3, inWorldMousePos);
               currentCurve.SetBezierPoint(2, inWorldMousePos);
               break;
            case PlaceState.kStartTangent:
               currentCurve.SetBezierPoint(1, inWorldMousePos);
               break;
            case PlaceState.kEndTangent:
               currentCurve.SetBezierPoint(2, inWorldMousePos);
               break;
         }

         if (placeState != PlaceState.kNone && placeState != PlaceState.kDisabled)
            currentCurve.UpdateMesh();
          }

          if (Input.GetMouseButtonDown(0))
          {
         switch (placeState)
         {
            case PlaceState.kEndTangent:
               Vector2[] curveInfo = currentCurve.GetBezierPoints();
               Vector2 newPos = curveInfo[3];
               Vector2 normalTangent = (newPos - curveInfo[2]).normalized;
               Vector2 newTangent = newPos + normalTangent;
               Vector2[] uvs = currentCurve.GetComponent<MeshFilter>().mesh.uv;
               float lastU = uvs[uvs.Length-1].x;
               currentCurve = CurveMgr.Instance.NewCurve(newPos, newPos, newTangent, newPos, newPos, true);
               currentCurve.initialU = lastU;
               placeState = PlaceState.kPoint;
               newLine = false;
               break;
            case PlaceState.kPoint:
               placeState = newLine ? PlaceState.kStartTangent : PlaceState.kEndTangent;
               break;
            case PlaceState.kStartTangent:
               placeState = PlaceState.kEndTangent;
               break;
            case PlaceState.kNone:
               Vector3 inWorldMousePos = GetInWorldMousePos();
               currentCurve = CurveMgr.Instance.NewCurve(inWorldMousePos, inWorldMousePos,
                                                         inWorldMousePos, inWorldMousePos, inWorldMousePos, false);
               placeState = PlaceState.kPoint;
               newLine = true;
               break;

         }
          }
          else if (Input.GetMouseButtonDown(1) && placeState != PlaceState.kNone)
          {
         CurveMgr.Instance.RemoveLatestCurve();
         placeState = PlaceState.kNone;
          }
    }
예제 #18
0
 // Use this for initialization
 void Start()
 {
     mousePlane = new Plane(Vector3.forward, new Vector3(0, 0, 0));
       placeState = PlaceState.kNone;
 }
예제 #19
0
 public void ClearCurrent()
 {
     currentCurve = null;
       placeState = PlaceState.kNone;
 }