Ejemplo n.º 1
0
    ////////////////////////
    /// Auxiliar Methods ///
    ////////////////////////

    void InitiallizeWorkOffers()
    {
        nonAllocatedWorkOffers = new List <Coords>();
        cityOffersGrid         = new WorkOfferInGrid[32, 32];
        Job.TYPE currentJobType = (Job.TYPE) 1;
        int      aux            = Global.Values.jobsQuantity[(int)Jobs[(int)currentJobType].GetExtension(), (int)currentJobType];

        for (int i = 0; i < 1024; i++)
        {
            //Global.Methods.PrintInfo(Jobs[(int)currentJobType].GetExtension() + "_" + i.ToString() +": " + currentJobType);
            if (i < aux)
            {
                if ((int)currentJobType >= Global.Values.jobsQuantity.Length)
                {
                    break;
                }
                int x = i / 32;
                int y = i % 32;
                cityOffersGrid[x, y] = new WorkOfferInGrid(currentJobType, false);
                nonAllocatedWorkOffers.Insert(Global.Methods.GetRandom(nonAllocatedWorkOffers.Count), new Coords(x, y)); // The insertion is random
            }
            else
            {
                currentJobType++;
                if (jobsCount > (int)currentJobType)
                {
                    aux += Global.Values.jobsQuantity[(int)Jobs[(int)currentJobType].GetExtension(), (int)currentJobType];
                }
                else
                {
                    break;
                }
            }
        }
    }
Ejemplo n.º 2
0
    //////////////////////
    /// Public Methods ///
    //////////////////////

    public AcceptedJob GetWorkOffer()
    {
        Coords      availableOffferCords = AllocateWorkOffer();
        AcceptedJob res = GetNullJob();

        if (availableOffferCords.X < 0)
        {
            return(res);
        }
        WorkOfferInGrid offer = cityOffersGrid[availableOffferCords.X, availableOffferCords.Y];

        res.Coords        = availableOffferCords;
        res.JobType       = offer.Job;
        res.Salary        = Jobs[(int)offer.Job].Salary;
        res.TimeRequiered = Jobs[(int)offer.Job].Schedule.RequieredTime;
        res.Enter         = Jobs[(int)offer.Job].Schedule.Start;
        res.RemainingDays = Jobs[(int)offer.Job].ContractedDays;
        res.CityPlace     = CityPlace;
        return(res);
    }