コード例 #1
0
    public List <Descriptor> InformationDescriptors(GameObject go)
    {
        List <Descriptor> list = new List <Descriptor>();
        Tag        tag         = new Tag(cropVal.cropId);
        GameObject prefab      = Assets.GetPrefab(tag);
        Edible     component   = prefab.GetComponent <Edible>();
        float      num         = 0f;
        string     arg         = string.Empty;

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            num = component.FoodInfo.CaloriesPerUnit;
        }
        float           calories   = num * (float)cropVal.numProduced;
        InfoDescription component2 = prefab.GetComponent <InfoDescription>();

        if ((bool)component2)
        {
            arg = component2.description;
        }
        string     arg2  = GameTags.DisplayAsCalories.Contains(tag) ? GameUtil.GetFormattedCalories(calories, GameUtil.TimeSlice.None, true) : ((!GameTags.DisplayAsUnits.Contains(tag)) ? GameUtil.GetFormattedMass((float)cropVal.numProduced, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}") : GameUtil.GetFormattedUnits((float)cropVal.numProduced, GameUtil.TimeSlice.None, false));
        LocString  yIELD = UI.UISIDESCREENS.PLANTERSIDESCREEN.YIELD;
        Descriptor item  = new Descriptor(string.Format(yIELD, prefab.GetProperName(), arg2), string.Format(UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.YIELD, arg, GameUtil.GetFormattedCalories(num, GameUtil.TimeSlice.None, true), GameUtil.GetFormattedCalories(calories, GameUtil.TimeSlice.None, true)), Descriptor.DescriptorType.Effect, false);

        list.Add(item);
        SeedProducer component3 = GetComponent <SeedProducer>();

        if ((bool)component3 && component3.seedInfo.productionType == SeedProducer.ProductionType.Harvest)
        {
            Descriptor item2 = new Descriptor(string.Format(UI.UISIDESCREENS.PLANTERSIDESCREEN.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), string.Format(UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), Descriptor.DescriptorType.Effect, false);
            list.Add(item2);
        }
        return(list);
    }
コード例 #2
0
 protected override void HandleError(InfoDescription error)
 {
     switch (error)
     {
     case InfoDescription.CannotPlayThatCard:
         uiDeck.playedCard.HideCard();
         break;
     }
 }
コード例 #3
0
ファイル: UIPlayer.cs プロジェクト: JnRMnT/SpadesJM.UI
 private void HandleError(InfoDescription error)
 {
     switch (error)
     {
     case InfoDescription.CannotPlayThatCard:
         uiDeck.playedCard.ResetPosition(true);
         break;
     }
 }
コード例 #4
0
    protected override void SetResultDescriptions(GameObject go)
    {
        string          text      = string.Empty;
        InfoDescription component = go.GetComponent <InfoDescription>();

        if ((bool)component)
        {
            text += component.description;
        }
        descriptionLabel.SetText(text);
    }
    protected virtual void SetResultDescriptions(GameObject go)
    {
        string          text      = "Entity prefab has no info description component.";
        InfoDescription component = go.GetComponent <InfoDescription>();

        if ((bool)component)
        {
            text = component.description;
        }
        descriptionLabel.SetText(text);
    }
コード例 #6
0
ファイル: Info.cs プロジェクト: JnRMnT/SpadesJM.Logic
        public Info(InfoDescription description)
        {
            switch (description)
            {
            case InfoDescription.CannotPlayThatCard:
                infoCode = 1;
                break;

            case InfoDescription.BidNotValid:
                infoCode = 2;
                break;
            }
        }
コード例 #7
0
ファイル: UIPlayer.cs プロジェクト: JnRMnT/SpadesJM.UI
 public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
 {
     this.callbackObject = callbackObject;
     unityPlayer.TurnTimeoutHandler.StartTurnTimer(this, actionType, callbackObject);
     if (error == InfoDescription.NoError)
     {
         //  NO ERROR
         HandleActionRequest(actionType);
         TurnArrowController.SetActive(GetPlayersSeat());
     }
     else
     {
         //  SHOW ERROR
         HandleError(error);
         HandleActionRequest(actionType);
         TurnArrowController.SetActive(GetPlayersSeat());
         LogManager.Log(error.ToString("G"));
     }
 }
コード例 #8
0
    public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
    {
        unityComputer.TurnTimeoutHandler.StartTurnTimer(this, actionType, callbackObject);
        LogManager.Log(unityComputer.transform.name + " : " + actionType.ToString("G"));
        staticCallBackObject = callbackObject;

        if (error == InfoDescription.NoError)
        {
            //  NO ERROR
            TurnArrowController.SetActive(UIPlayer.GetRelativePlayerSeat(base.GetPlayersSeat()));
            awaitingAction = actionType;
            unityComputer.WaitForAction();
        }
        else
        {
            //  SHOW ERROR
            TurnArrowController.SetActive(UIPlayer.GetRelativePlayerSeat(GetPlayersSeat()));
            LogManager.Log(error.ToString());
        }
    }
コード例 #9
0
    public static GameObject ConfigBasicEntity(GameObject template, string id, string name, string desc, float mass, bool unitMass, KAnimFile anim, string initialAnim, Grid.SceneLayer sceneLayer, SimHashes element = SimHashes.Creature, List <Tag> additionalTags = null, float defaultTemperature = 293f)
    {
        ConfigEntity(template, id, name, true);
        KPrefabID kPrefabID = template.AddOrGet <KPrefabID>();

        if (additionalTags != null)
        {
            foreach (Tag additionalTag in additionalTags)
            {
                kPrefabID.AddTag(additionalTag, false);
            }
        }
        KBatchedAnimController kBatchedAnimController = template.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            anim
        };
        kBatchedAnimController.sceneLayer  = sceneLayer;
        kBatchedAnimController.initialAnim = initialAnim;
        template.AddOrGet <StateMachineController>();
        PrimaryElement primaryElement = template.AddOrGet <PrimaryElement>();

        primaryElement.ElementID   = element;
        primaryElement.Temperature = defaultTemperature;
        if (unitMass)
        {
            primaryElement.MassPerUnit = mass;
            primaryElement.Units       = 1f;
            GameTags.DisplayAsUnits.Add(kPrefabID.PrefabTag);
        }
        else
        {
            primaryElement.Mass = mass;
        }
        InfoDescription infoDescription = template.AddOrGet <InfoDescription>();

        infoDescription.description = desc;
        template.AddOrGet <Notifier>();
        return(template);
    }
コード例 #10
0
        public static bool Prefix(Crop __instance, ref List <Descriptor> __result)
        {
            Dictionary <string, int> setting;

            if (CustomizePlantsState.StateManager.State.SpecialCropSettings == null ||
                CustomizePlantsState.StateManager.State.SpecialCropSettings.TryGetValue(__instance.cropId, out setting) == false)
            {
                return(true);
            }

            __result = new List <Descriptor>();

            foreach (KeyValuePair <string, int> entry in setting)
            {
                Tag        tag       = new Tag(entry.Key);
                GameObject prefab    = Assets.GetPrefab(tag);
                Edible     edible    = prefab.GetComponent <Edible>();
                float      calories1 = 0.0f;
                string     str1      = string.Empty;
                if (edible != null)
                {
                    calories1 = edible.FoodInfo.CaloriesPerUnit;
                }
                float           calories2       = calories1 * entry.Value;
                InfoDescription infoDescription = prefab.GetComponent <InfoDescription>();
                if (infoDescription != null)
                {
                    str1 = infoDescription.description;
                }
                string str2 = !GameTags.DisplayAsCalories.Contains(tag) ? (!GameTags.DisplayAsUnits.Contains(tag) ? GameUtil.GetFormattedMass(entry.Value, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}") : GameUtil.GetFormattedUnits(entry.Value, GameUtil.TimeSlice.None, false)) : GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true);

                __result.Add(new Descriptor(string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.YIELD, prefab.GetProperName(), str2), string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.YIELD, str1, GameUtil.GetFormattedCalories(calories1, GameUtil.TimeSlice.None, true), GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true)), Descriptor.DescriptorType.Effect, false));
            }

            if ((__instance.GetComponent <SeedProducer>()?.seedInfo.productionType ?? SeedProducer.ProductionType.DigOnly) == SeedProducer.ProductionType.Harvest)
            {
                __result.Add(new Descriptor(string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), string.Format(STRINGS.UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.BONUS_SEEDS, GameUtil.GetFormattedPercent(10f, GameUtil.TimeSlice.None)), Descriptor.DescriptorType.Effect, false));
            }

            return(false);
        }
    private string GetSpawnableDescription()
    {
        Element element = ElementLoader.GetElement(info.id.ToTag());

        if (element != null)
        {
            return(element.Description());
        }
        GameObject prefab = Assets.GetPrefab(info.id);

        if ((UnityEngine.Object)prefab == (UnityEngine.Object)null)
        {
            return(string.Empty);
        }
        InfoDescription component = prefab.GetComponent <InfoDescription>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            return(component.description);
        }
        return(prefab.GetProperName());
    }
コード例 #12
0
            public static void Postfix(Crop __instance, List <Descriptor> __result, GameObject go)
            {
                if (__instance == null)
                {
                    return;
                }
                Crop.CropVal cropVal = __instance.cropVal;
                if (string.IsNullOrEmpty(cropVal.cropId))
                {
                    return;
                }
                if (cropVal.cropId != CactusFleshConfig.Id)
                {
                    return;
                }
                Tag        tag        = new Tag(CactusFlowerConfig.Id);
                GameObject prefab     = Assets.GetPrefab(tag);
                Edible     component1 = prefab.GetComponent <Edible>();
                float      calories1  = 0.0f;
                string     str1       = string.Empty;

                if (component1 != null)
                {
                    calories1 = component1.FoodInfo.CaloriesPerUnit;
                }
                float           calories2  = calories1 * 1.0f;
                InfoDescription component2 = prefab.GetComponent <InfoDescription>();

                if ((bool)(component2))
                {
                    str1 = component2.description;
                }
                string     str2        = !GameTags.DisplayAsCalories.Contains(tag) ? (!GameTags.DisplayAsUnits.Contains(tag) ? GameUtil.GetFormattedMass(1.0f, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}") : GameUtil.GetFormattedUnits(1.0f, GameUtil.TimeSlice.None, false)) : GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true);
                Descriptor descriptor1 = new Descriptor(string.Format((string)UI.UISIDESCREENS.PLANTERSIDESCREEN.YIELD, (object)prefab.GetProperName(), (object)str2), string.Format((string)UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.YIELD, (object)str1, (object)GameUtil.GetFormattedCalories(calories1, GameUtil.TimeSlice.None, true), (object)GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true)), Descriptor.DescriptorType.Effect, false);

                __result.Add(descriptor1);
            }
コード例 #13
0
ファイル: Computer.cs プロジェクト: JnRMnT/SpadesJM.Logic
        public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
        {
            this.callbackObject = callbackObject;
            switch (actionType)
            {
            case ActionType.DO_BIDDING:
                HandleBidding();
                break;

            case ActionType.PLAY_CARD:
                Hand currentHand = (Hand)callbackObject;
                PlayCard(DeckHelper.GetBestMove(currentHand, playersDeck, this));
                break;

            case ActionType.SET_TRUMP_TYPE:
                SetTrumpType(GetPlayersDeck().GetTrumpToChoose());
                break;
            }
        }
コード例 #14
0
ファイル: Player.cs プロジェクト: JnRMnT/SpadesJM.Logic
 public virtual void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
 {
     //  DISPLAY ERROR MESSAGE
     this.callbackObject = callbackObject;
 }
コード例 #15
0
        public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
        {
            this.callbackObject = callbackObject;
            switch (actionType)
            {
            case ActionType.DO_BIDDING:
                Bid(((InitialPhase)callbackObject).GetLowestPossibleBid());
                break;

            case ActionType.PLAY_CARD:
                Hand currentHand = (Hand)callbackObject;
                if (DeckHelper.GetAvailableMoves(currentHand, playersDeck, this).Count == 0)
                {
                    return;
                }
                PlayCard(DeckHelper.GetAvailableMoves(currentHand, playersDeck, this)[0]);
                break;

            case ActionType.SET_TRUMP_TYPE:
                SetTrumpType(CardType.Spade);
                break;
            }
        }
コード例 #16
0
    protected override void SetResultDescriptions(GameObject seed_or_plant)
    {
        string            text       = string.Empty;
        GameObject        gameObject = seed_or_plant;
        PlantableSeed     component  = seed_or_plant.GetComponent <PlantableSeed>();
        List <Descriptor> list       = new List <Descriptor>();

        if ((Object)component != (Object)null)
        {
            list = component.GetDescriptors(component.gameObject);
            if ((Object)targetReceptacle.rotatable != (Object)null && targetReceptacle.Direction != component.direction)
            {
                if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Top)
                {
                    text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_FLOOR;
                }
                else if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Side)
                {
                    text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_WALL;
                }
                else if (component.direction == SingleEntityReceptacle.ReceptacleDirection.Bottom)
                {
                    text += UI.UISIDESCREENS.PLANTERSIDESCREEN.ROTATION_NEED_CEILING;
                }
                text += "\n\n";
            }
            gameObject = Assets.GetPrefab(component.PlantID);
            if (!string.IsNullOrEmpty(component.domesticatedDescription))
            {
                text += component.domesticatedDescription;
            }
        }
        else
        {
            InfoDescription component2 = gameObject.GetComponent <InfoDescription>();
            if ((bool)component2)
            {
                text += component2.description;
            }
        }
        descriptionLabel.SetText(text);
        List <Descriptor> plantLifeCycleDescriptors = GameUtil.GetPlantLifeCycleDescriptors(gameObject);

        if (plantLifeCycleDescriptors.Count > 0)
        {
            HarvestDescriptorPanel.SetDescriptors(plantLifeCycleDescriptors);
            HarvestDescriptorPanel.gameObject.SetActive(true);
        }
        List <Descriptor> plantRequirementDescriptors = GameUtil.GetPlantRequirementDescriptors(gameObject);

        if (list.Count > 0)
        {
            GameUtil.IndentListOfDescriptors(list, 1);
            plantRequirementDescriptors.InsertRange(plantRequirementDescriptors.Count, list);
        }
        if (plantRequirementDescriptors.Count > 0)
        {
            RequirementsDescriptorPanel.SetDescriptors(plantRequirementDescriptors);
            RequirementsDescriptorPanel.gameObject.SetActive(true);
        }
        List <Descriptor> plantEffectDescriptors = GameUtil.GetPlantEffectDescriptors(gameObject);

        if (plantEffectDescriptors.Count > 0)
        {
            EffectsDescriptorPanel.SetDescriptors(plantEffectDescriptors);
            EffectsDescriptorPanel.gameObject.SetActive(true);
        }
        else
        {
            EffectsDescriptorPanel.gameObject.SetActive(false);
        }
    }
コード例 #17
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);
        }
    }
コード例 #18
0
    public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
    {
        base.AskForAction(actionType, callbackObject, error);

        unityPlayer.TurnTimeoutHandler.StartTurnTimer(this, actionType, callbackObject);
    }