Пример #1
0
 public bool TryRecruit(RecruitmentWorkOrder recruitmentWorkOrder)
 {
     if (population.CanReqruit(recruitmentWorkOrder.Population))
     {
         population.current += recruitmentWorkOrder.Population;
         OnPopulationUpdated?.Invoke(population);
         return(true);
     }
     return(false);
 }
Пример #2
0
    private void Awake()
    {
        mainCamera = Camera.main;

        population = new Population(0, Settings.DefaultPopulation);

        resources = new Resources(
            Settings.DefaultResources.Wood,
            Settings.DefaultResources.Food,
            Settings.DefaultResources.Stone,
            Settings.DefaultResources.Metal
            );

        OnResourcesUpdated  += userInterfaceController.GetOnResourcesUpdatedAction();
        OnPopulationUpdated += userInterfaceController.GetOnPopulationUpdatedAction();

        playerController.OnSelected   += userInterfaceController.GetOnSelectedAction();
        playerController.OnDeselected += userInterfaceController.GetOnDeselectedAction();

        playerController.OnStructuresSelected   += userInterfaceController.OnStructuresSelected;
        playerController.OnStructuresDeselected += userInterfaceController.OnStructuresDeselected;

        units = new List <Unit>();

        structures = new List <Structure>();
        foreach (var structure in unregisteredStructures)
        {
            structures.Add(structure);
            structure.Initialize(this, this);

            if (structure is IUnitRecruiter)
            {
                (structure as IUnitRecruiter).OnUnitRecruited += OnUnitRecruited;
            }

            population.allowed += structure.Properties.housing;
        }

        harvestables = new List <ISelectable>();
        foreach (var harvestable in GameObject.FindGameObjectsWithTag(Settings.Tags.Harvestable))
        {
            harvestables.Add(harvestable.GetComponent <ISelectable>());
        }

        playerController.SetGetSelectablesCall(GetSelectablesInBounds);

        OnResourcesUpdated?.Invoke(resources);
        OnPopulationUpdated?.Invoke(population);

        fogOfWarManager = Camera.main.GetComponent <IFogOfWarManager>();

        fogOfWarManager.AddLightObjects(structures.Select(structure => structure as ILighter));
        fogOfWarManager.AddLightObjects(units.Select(unit => unit as ILighter));
    }
Пример #3
0
 public void Cancel(RecruitmentWorkOrder recruitmentWorkOrder)
 {
     population.current -= recruitmentWorkOrder.Population;
     OnPopulationUpdated?.Invoke(population);
 }