Example #1
0
    public override bool Condition(GameObject target)
    {
        //this objective will be auto-completed if the player already has the correct sat in their inventory on objective start
        if (craftComplete == false)
        {
            if (!SatInv.CheckIfSat())
            {
                return(false);
            }

            if (SatInv.GetSatellite() == satelliteType)
            {
                craftComplete = true;
                string objectiveUpdate = $"1/1 {actionVerb[0]} <color=#FFC63B>{satelliteType.DisplayName}</color>";
                UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.UpdateObjective(0, objectiveUpdate);
            }
        }

        if (placeComplete && craftComplete)
        {
            //todo update widget
            ObjectivePopup(isFirstEvent);
            Debug.Log("EVENT CONDITION MET");
            CodexProgression();
            UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.ClearObjectives();
            SatInv        = null;
            craftComplete = false;
            placeComplete = false;
            return(true);
        }

        return(false);
    }
Example #2
0
    protected override void OnSelect(ToolController owner)
    {
        Debug.Log("Satellite Tool Selected");
        satInv = owner.GetComponent <SatelliteInventory>();
        if (satInv == null || satInv.StoredSatellites.Count == 0 || satInv.StoredSatellites[0] == null)
        {
            satInv.NoSatTooltip.SetActive(true);
            //Debug.Log("NoSat Found");
            return;
        }

        //this is such a gross way of checking what satellite type a thing is im sorry
        if (satInv.StoredSatellites[0].name == "FuelSatellite")
        {
            foreach (var cloud in cloudVisualizers)
            {
                cloud.VisualizeArea();
            }
        }

        SatellitePreview = GameObject.Instantiate(satInv.StoredSatellites[0].PreviewPrefab);
        SatellitePreview.transform.position = satInv.SatelliteSpawnPos.position;
        SatellitePreview.transform.rotation = satInv.SatelliteSpawnPos.rotation;
        SatellitePreview.transform.SetParent(owner.GetComponentInChildren <Camera>().transform);
        SatBehavior = SatellitePreview.GetComponent <SatelliteBehavior>();
    }
    void Start()
    {
        playerInventory = UIRoot.GetPlayer().GetComponent <InventoryController>();
        satInventory    = UIRoot.GetPlayer().GetComponent <SatelliteInventory>();

        //save craft text and set up craft button as uninteractable
        craftButtonText = CraftButton.GetComponentInChildren <TextMeshProUGUI>();

        //set up text colours
        interactableTextCol   = craftButtonText.color;
        uninteractableTextCol = new Color(interactableTextCol.r, interactableTextCol.g, interactableTextCol.b, 0.3f);

        //fill in each of the panels
        PopulateRecipePanel(Satellites, 0);
    }
Example #4
0
    override public void InitializeEvent()
    {
        Debug.Log("EVENT" + this.name);

        SatInv = Playstate.ActivePlayer.GetComponent <SatelliteInventory>(); //TODO If we add respawning this will break!

        //objective text
        UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.ClearObjectives();

        string objectiveUpdate = $"0/1 {actionVerb[0]} <color=#FFC63B>{satelliteType.DisplayName}</color>";

        UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.AddObjective(objectiveUpdate);

        objectiveUpdate = $"0/1 {actionVerb[1]} <color=#FFC63B>{satelliteType.DisplayName}</color>";
        UIRootModule.UIRoot.GetScreen <GameHUD>().objectivePanel.AddObjective(objectiveUpdate);
    }
Example #5
0
 protected override void OnDeselect(ToolController owner)
 {
     if (cloudVisualizers[0].enabled == true)
     {
         foreach (var cloud in cloudVisualizers)
         {
             cloud.DisableVisualizer();
         }
     }
     Debug.Log("Satellite Tool DeSelected");
     //turn off tooltips from satinv
     satInv.NoSatTooltip.SetActive(false);
     satInv.SatNotInCloud.SetActive(false);
     satInv.PlaceSat.SetActive(false);
     //nullify satinv
     satInv      = null;
     SatBehavior = null;
     Destroy(SatellitePreview);
 }
Example #6
0
    public bool CanCraftSatellite(ResourceInventory ResourceInv, InventoryController SourceInv, SatelliteInventory TargetInv, SatelliteRecipe CraftRecipe)
    {
        if (SourceInv == null || TargetInv == null || ResourceInv == null || TargetInv == null)
        {
            Debug.LogError(SourceInv);
            Debug.LogError(TargetInv);
            Debug.LogError(ResourceInv);
            return(false);
        }
        foreach (var itemIn in CraftRecipe.ItemInput)
        {
            if (SourceInv.GetItemAmount(itemIn.item) < itemIn.amount)
            {
                return(false);
            }
        }

        foreach (var resIn in CraftRecipe.ResourceInput)
        {
            if (ResourceInv.GetResource(resIn.resource) < resIn.amount)
            {
                return(false);
            }
        }

        if (CraftRecipe.CreatesByProducts)
        {
            foreach (var resOut in CraftRecipe.ResourceByProducts)
            {
                if (ResourceInv.GetResource(resOut.resource) + resOut.amount > resOut.resource.GetMaximum())
                {
                    return(false);                                                                                         //holy crap this is a kludge. TODO: Fix this
                }
            }
        }

        if (TargetInv.StoredSatellites.Count != 0 && TargetInv.StoredSatellites[0] != null)
        {
            return(false);
        }
        return(true);
    }
Example #7
0
    public bool CraftSatellite(ResourceInventory ResourceInv, InventoryController SourceInv, SatelliteInventory TargetInv, SatelliteRecipe CraftRecipe, bool ByPassCraftCheck = false)
    {
        if (!ByPassCraftCheck) //optimization to skip checking if we can craft this recipe
        {
            if (!CanCraftSatellite(ResourceInv, SourceInv, TargetInv, CraftRecipe))
            {
                return(false);
            }
        }
        foreach (var itemIn in CraftRecipe.ItemInput) //TODO Optimize data structure to allow use of a single foreach for inputs
        {
            SourceInv.RemoveFromItemBucket(itemIn.item, itemIn.amount);
        }
        foreach (var resourceIn in CraftRecipe.ResourceInput)
        {
            ResourceInv.RemoveResource(resourceIn.resource, resourceIn.amount);
        }

        TargetInv.SetSatellite(CraftRecipe.Output);
        //TODO (If required) Implement resource and item byproducts
        return(true);
    }