Ejemplo n.º 1
0
    private void BuildBuildingOption(BuildingSlot bs)
    {
        //Create the UI:
        GameObject panelBuildingDetails = (GameObject)Instantiate(panelBuildingDetailsPrefab);

        panelBuildingDetails.transform.SetParent(content.transform);
        BuildingOption buildingOption = panelBuildingDetails.GetComponent <BuildingOption>();

        //Get the BuildingOption script and set Gameplay values:
        buildingOption.buildingSlotInfos = bs;
        buildingOption.setBuildingName(bs.Name);
        buildingOption.setBuildingSprite(Resources.Load <Sprite>(bs.Image));


        int numberOfResourcesNeedeed = bs.Resources.Resource.Count;

        for (int i = 0; i < numberOfResourcesNeedeed; i++)
        {
            GameObject panelResourcesNeededGo = panelResourcesNeededGo = (GameObject)Instantiate(panelResourcesNeedeedPrefab);
            panelResourcesNeededGo.transform.SetParent(panelBuildingDetails.transform);
            panelResourcesNeededGo.transform.localPosition = new Vector2(200 + (i * 80), -20);
            buildingOption.addPanelResourcesNeeded(panelResourcesNeededGo.GetComponent <PanelResourceNeeded>());
            BuildingResource br = bs.Resources.Resource[i];
            buildingOption.addResource((UsableObject)Activator.CreateInstance(Type.GetType(br.Text), 4), Convert.ToInt32(br.Quantity));
        }

        //Populate the UI:
        buildingOption.populateUI();
    }
Ejemplo n.º 2
0
 //  the resource is empty
 //  remove it from the world
 internal void RemoveResource(BuildingResource buildingResource)
 {
     _resourcesAtBase.Remove(buildingResource);
     new BuildingResourceUpdatedEvent {
         Resource = buildingResource
     }.Publish();
 }
Ejemplo n.º 3
0
    internal void OrderResourceShipment(string resource)
    {
        var order = new BuildingResource(resource, 20);

        order.ReserveResourceBySystem();
        _resourcesOrdered.Add(order);

        IoC.Get <ShipmentController>().OrderResourceShipment(order);
    }
Ejemplo n.º 4
0
 public static Job CreateDeliveryJob(BuildingResource resource, Tile from, Tile to)
 {
     return(new Job(to)
     {
         Type = JobType.Delivery,
         Tag = from,
         Delivery = resource
     });
 }
Ejemplo n.º 5
0
    internal void TakeResource(BuildingResource resource)
    {
        Log($"{resource.Type} @ {resource.Tile.Position}");

        resource.TakeResource();

        if (resource.IsDepleted)
        {
            Log("resource is depleted");

            IoC.Get <World>().GetInventory().RemoveResource(resource);
            resource.Tile.ResourcePile = null;

            _occupiedTiles.Remove(resource.Tile);
            _unoccupiedTiles.Add(resource.Tile);

            new BuildingResourceUpdatedEvent {
                Resource = resource
            }.Publish();
        }
    }
Ejemplo n.º 6
0
 public void PickUpResource(BuildingResource resource)
 {        
   _waitingOnPickup.Remove(resource);
   Deliveries[_waitingOnPickup.Count].SetActive(false);
 }
Ejemplo n.º 7
0
 //  Order a resource shipment from earth
 public void OrderResourceShipment(BuildingResource resource)
 {
   //  Order resource shipment
   _shipmentRequest.Enqueue(resource);
 }
Ejemplo n.º 8
0
    public void ScheduleDelivery(BuildingResource resource, Tile from, Tile to)
    {
        var delivery = Job.CreateDeliveryJob(resource, from, to);

        IoC.Get <World>().ScheduleJob(delivery);
    }
Ejemplo n.º 9
0
 public void AddOrderResourceToInventory(BuildingResource resource)
 {
     _resourcesOrdered.Remove(resource);
     _resourcesAtBase.Add(resource);
 }