Ejemplo n.º 1
0
        /// <summary>
        /// Returns all employees that were hired at the given location.
        /// </summary>
        /// <param name="place"></param>
        /// <returns></returns>
        public static IEnumerable <EmployeeState> InternalEmployeesFromPlace(BasePlace place)
        {
            foreach (var ownedPlace in OwnedPlaces)
            {
                foreach (var employee in ownedPlace.Employees)
                {
                    if (employee.CurrentJob != null)
                    {
                        continue;
                    }
                    if (employee.OriginalLocation == place)
                    {
                        yield return(employee);
                    }
                }
            }

            foreach (var job in Simulation.simulation.ActiveJobs)
            {
                if (job.Employee.OriginalLocation == place)
                {
                    yield return(job.Employee);
                }
            }
        }
Ejemplo n.º 2
0
 public WorldLocationWidget(BaseScene scene, BasePlace place) : base()
 {
     bg            = ContentLoader.GetTexture("menu-button");
     Place         = place;
     owned         = WorldState.PlaceOwned(place);
     clickEffect   = ContentLoader.GetSample("pop2");
     this.OnClick += WorldLocationWidget_OnClick;
 }
Ejemplo n.º 3
0
        public void AddPlace(BasePlace place)
        {
            Realm       _realm       = Realm.GetInstance();
            Transaction _transaction = _realm.BeginWrite();

            _realm.Add(place.ToRealmPlace());

            _transaction.Commit();
            _transaction.Dispose();
        }
        public TruckManufacturerSelectionScene(BasePlace place) : base("Dealers")
        {
            this.place = place;
            manufacturers.Add(new ManufacturerWidget(BaseTruckManufacturer.ManManufacturer, "manufacturer-man-logo"));
            manufacturers.Add(new ManufacturerWidget(BaseTruckManufacturer.ManManufacturer, "manufacturer-mercedes-logo"));

            foreach (var item in manufacturers)
            {
                item.OnClick += Item_OnClick;
            }
        }
Ejemplo n.º 5
0
 public static PlaceState GetStateForPlace(BasePlace place)
 {
     foreach (var item in OwnedPlaces)
     {
         if (item.Place.Name == place.Name)
         {
             return(item);
         }
     }
     throw new Exception("Place is not owned yet");
 }
Ejemplo n.º 6
0
 public static bool PlaceOwned(BasePlace place)
 {
     foreach (var item in OwnedPlaces)
     {
         if (item.Place.Name == place.Name)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
 public static void UnlockPlace(BasePlace place)
 {
     foreach (var p in OwnedPlaces)
     {
         if (p.Place.Name == place.Name)
         {
             throw new Exception("Place is already unlocked.");
         }
     }
     Simulation.simulation.Money -= place.GaragePrice;
     OwnedPlaces.Add(new PlaceState(place));
 }
Ejemplo n.º 8
0
        public JobOffer(int id, string company, BasePlace from, BasePlace to, TransportableItem item, decimal reward, List <Weekday> shipDays, List <BasePlace> connections = null)
        {
            Id   = id;
            From = from;
            To   = to;
            var conn = connections == null?GetConnections() : connections;

            Item          = item;
            OfferedReward = reward;
            ShipDays      = shipDays;
            Connections   = conn;
            Company       = company;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Return all employees that are at the given location but were not hired there.
 /// </summary>
 /// <param name="place"></param>
 /// <returns></returns>
 public static IEnumerable <EmployeeState> ExternalEmployeesCurrentlyAt(BasePlace place)
 {
     foreach (var ownedPlace in OwnedPlaces)
     {
         foreach (var employee in ownedPlace.Employees)
         {
             if (employee.CurrentLocation == place && employee.OriginalLocation != place)
             {
                 yield return(employee);
             }
         }
     }
 }
Ejemplo n.º 10
0
 public PlaceState(BasePlace place)
 {
     Trucks        = new List <BaseTruck>();
     Employees     = new List <EmployeeState>();
     AvailableJobs = new List <JobOffer>();
     Docks         = new List <DockState>();
     Docks.Add(new DockState(true));
     Docks.Add(new DockState(true));
     for (int i = 0; i < 5; i++)
     {
         Docks.Add(new DockState(false));
     }
     Place = place;
 }
Ejemplo n.º 11
0
        public TruckBrowseScene(BasePlace place, BaseTruckManufacturer manufacturer) : base(manufacturer.Name + " Dealership")
        {
            this.place        = place;
            this.manufacturer = manufacturer;
            selectedTruck     = manufacturer.Trucks[selectedIndex];
            truckIcon         = ContentLoader.GetTexture("truck-icon");

            purchasePurchase          = new DetailButtonWidget(true);
            purchasePurchase.Text     = "Purchase";
            purchasePurchase.OnClick += PurchasePurchase_OnClick;

            arrowButtonLeft           = new ArrowButtonWidget(PointingTo.Left);
            arrowButtonRight          = new ArrowButtonWidget(PointingTo.Right);
            arrowButtonLeft.OnClick  += ArrowButtonLeft_OnClick;
            arrowButtonRight.OnClick += ArrowButtonRight_OnClick;
        }
Ejemplo n.º 12
0
        private bool GetConnection(ref List <BasePlace> places, BasePlace parent, BasePlace from)
        {
            places.Add(from);
            int countBefore = places.Count;

            var destVec            = new Vector2((float)To.Longtitude, (float)To.Lattitude);
            var orderedConnections = new List <Tuple <float, BasePlace> >();

            foreach (var connection in from.Connections)
            {
                float distance = Vector2.Distance(new Vector2((float)connection.Longtitude, (float)connection.Lattitude), destVec);
                orderedConnections.Add(new Tuple <float, BasePlace>(distance, connection));
            }
            orderedConnections = orderedConnections.OrderBy(e => e.Item1).ToList();

            foreach (var connection in orderedConnections)
            {
                if (places.Contains(connection.Item2))
                {
                    continue;
                }
                if (parent == connection.Item2)
                {
                    continue;
                }
                if (connection.Item2 == this.To)
                {
                    return(true);
                }
                if (GetConnection(ref places, from, connection.Item2))
                {
                    return(true);
                }
                else
                {
                    places.RemoveRange(countBefore, places.Count - countBefore);
                }
            }
            return(false);
        }
Ejemplo n.º 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();
        }