private void Update()
    {
        string errMsg;

        if (_activeBuildingType && Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            if (CanSpawn(_activeBuildingType, Utils.GetMouseWorldPosition(), out errMsg))
            {
                if (ResourceManager.Instance.CanAfford(_activeBuildingType.productionCosts))
                {
                    ResourceManager.Instance.ApplyCosts(_activeBuildingType.productionCosts);
                    SoundManager.Instance.PlayClip(SoundManager.Instance.clips.BuildingPlaced);
                    BuildingUnderConstruction.Create(Utils.GetMouseWorldPosition(), _activeBuildingType);
                }
                else
                {
                    TooltipUI.Instance.ShowMsg("Can't afford to build", 2f);
                }
            }
            else
            {
                TooltipUI.Instance.ShowMsg(errMsg, 2f);
            }
        }
    }
Exemple #2
0
    public static BuildingUnderConstruction Create(Vector3 position, BuildingTypeScriptableObject buildingType)
    {
        Transform xform = Instantiate(GameAssets.Instance.buildingUnderConstructionPrefab, position, Quaternion.identity);
        BuildingUnderConstruction buildingUnderConstruction = xform.GetComponent <BuildingUnderConstruction>();

        buildingUnderConstruction.Setup(buildingType);
        return(buildingUnderConstruction);
    }
    private string GetSelectedObjectCodexID()
    {
        string text = string.Empty;
        CellSelectionObject       component  = SelectTool.Instance.selected.GetComponent <CellSelectionObject>();
        BuildingUnderConstruction component2 = SelectTool.Instance.selected.GetComponent <BuildingUnderConstruction>();
        CreatureBrain             component3 = SelectTool.Instance.selected.GetComponent <CreatureBrain>();
        PlantableSeed             component4 = SelectTool.Instance.selected.GetComponent <PlantableSeed>();
        BudUprootedMonitor        component5 = SelectTool.Instance.selected.GetComponent <BudUprootedMonitor>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            text = CodexCache.FormatLinkID(component.element.id.ToString());
        }
        else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            text = CodexCache.FormatLinkID(component2.Def.PrefabID);
        }
        else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString());
            text = text.Replace("BABY", string.Empty);
        }
        else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString());
            text = text.Replace("SEED", string.Empty);
        }
        else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
        {
            if ((UnityEngine.Object)component5.parentObject.Get() != (UnityEngine.Object)null)
            {
                text = CodexCache.FormatLinkID(component5.parentObject.Get().PrefabID().ToString());
            }
            else if ((UnityEngine.Object)component5.GetComponent <TreeBud>() != (UnityEngine.Object)null)
            {
                text = CodexCache.FormatLinkID(component5.GetComponent <TreeBud>().buddingTrunk.Get().PrefabID().ToString());
            }
        }
        else
        {
            text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString());
        }
        if (CodexCache.entries.ContainsKey(text) || CodexCache.FindSubEntry(text) != null)
        {
            return(text);
        }
        return(string.Empty);
    }
 public void Refresh()
 {
     if (connectionManager != null && !skipRefresh)
     {
         int cell = Grid.PosToCell(base.transform.GetPosition());
         Connections = connectionManager.GetConnections(cell, isPhysicalBuilding);
         KBatchedAnimController component = GetComponent <KBatchedAnimController>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             string text = connectionManager.GetVisualizerString(cell);
             BuildingUnderConstruction component2 = GetComponent <BuildingUnderConstruction>();
             if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && component.HasAnimation(text + "_place"))
             {
                 text += "_place";
             }
             if (text != null && text != string.Empty)
             {
                 component.Play(text, KAnim.PlayMode.Once, 1f, 0f);
             }
         }
     }
 }
Exemple #5
0
        public static string GetFilterLayerFromGameObject(GameObject gameObject)
        {
            BuildingComplete buildingComplete = gameObject.GetComponent <BuildingComplete>();

            if (buildingComplete != null)
            {
                return(GetFilterLayerFromObjectLayer(buildingComplete.Def.ObjectLayer));
            }

            BuildingUnderConstruction buildingUnderConstruction = gameObject.GetComponent <BuildingUnderConstruction>();

            if (buildingUnderConstruction != null)
            {
                return(GetFilterLayerFromObjectLayer(buildingUnderConstruction.Def.ObjectLayer));
            }

            if (gameObject.GetComponent <Clearable>() != null || gameObject.GetComponent <Moppable>() != null)
            {
                return("CleanAndClear");
            }

            return(gameObject.GetComponent <Diggable>() != null ? "DigPlacer" : "Default");
        }
    public virtual string GetFilterLayerFromGameObject(GameObject input)
    {
        BuildingComplete          component  = input.GetComponent <BuildingComplete>();
        BuildingUnderConstruction component2 = input.GetComponent <BuildingUnderConstruction>();

        if ((bool)component)
        {
            return(GetFilterLayerFromObjectLayer(component.Def.ObjectLayer));
        }
        if ((bool)component2)
        {
            return(GetFilterLayerFromObjectLayer(component2.Def.ObjectLayer));
        }
        if ((UnityEngine.Object)input.GetComponent <Clearable>() != (UnityEngine.Object)null || (UnityEngine.Object)input.GetComponent <Moppable>() != (UnityEngine.Object)null)
        {
            return("CleanAndClear");
        }
        if ((UnityEngine.Object)input.GetComponent <Diggable>() != (UnityEngine.Object)null)
        {
            return("DigPlacer");
        }
        return("Default");
    }
Exemple #7
0
    private void SetPanels(GameObject target)
    {
        MinionIdentity            component  = target.GetComponent <MinionIdentity>();
        Amounts                   amounts    = target.GetAmounts();
        PrimaryElement            component2 = target.GetComponent <PrimaryElement>();
        BuildingComplete          component3 = target.GetComponent <BuildingComplete>();
        BuildingUnderConstruction component4 = target.GetComponent <BuildingUnderConstruction>();
        CellSelectionObject       component5 = target.GetComponent <CellSelectionObject>();
        InfoDescription           component6 = target.GetComponent <InfoDescription>();
        Edible component7 = target.GetComponent <Edible>();

        attributeLabels.ForEach(delegate(LocText x)
        {
            UnityEngine.Object.Destroy(x.gameObject);
        });
        attributeLabels.Clear();
        vitalsPanel.gameObject.SetActive(amounts != null);
        string text  = string.Empty;
        string text2 = string.Empty;

        if (amounts != null)
        {
            vitalsContainer.selectedEntity = selectedTarget;
            Uprootable component8 = selectedTarget.gameObject.GetComponent <Uprootable>();
            if ((UnityEngine.Object)component8 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive((UnityEngine.Object)component8.GetPlanterStorage != (UnityEngine.Object)null);
            }
            WiltCondition component9 = selectedTarget.gameObject.GetComponent <WiltCondition>();
            if ((UnityEngine.Object)component9 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive(true);
            }
        }
        if ((bool)component)
        {
            text = string.Empty;
        }
        else if ((bool)component6)
        {
            text = component6.description;
        }
        else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            text  = component3.Def.Effect;
            text2 = component3.Def.Desc;
        }
        else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            text  = component4.Def.Effect;
            text2 = component4.Def.Desc;
        }
        else if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
        {
            EdiblesManager.FoodInfo foodInfo = component7.FoodInfo;
            text += string.Format(UI.GAMEOBJECTEFFECTS.CALORIES, GameUtil.GetFormattedCalories(foodInfo.CaloriesPerUnit, GameUtil.TimeSlice.None, true));
        }
        else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
        {
            text = component5.element.FullDescription(false);
        }
        else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            Element element = ElementLoader.FindElementByHash(component2.ElementID);
            text = ((element == null) ? string.Empty : element.FullDescription(false));
        }
        List <Descriptor> gameObjectEffects = GameUtil.GetGameObjectEffects(target, true);
        bool flag = gameObjectEffects.Count > 0;

        descriptionContainer.gameObject.SetActive(flag);
        descriptionContainer.descriptors.gameObject.SetActive(flag);
        if (flag)
        {
            descriptionContainer.descriptors.SetDescriptors(gameObjectEffects);
        }
        descriptionContainer.description.text = text;
        descriptionContainer.flavour.text     = text2;
        infoPanel.gameObject.SetActive((UnityEngine.Object)component == (UnityEngine.Object)null);
        descriptionContainer.gameObject.SetActive(infoPanel.activeSelf);
        descriptionContainer.flavour.gameObject.SetActive(text2 != string.Empty && text2 != "\n");
        if (vitalsPanel.gameObject.activeSelf && amounts.Count == 0)
        {
            vitalsPanel.gameObject.SetActive(false);
        }
    }