Esempio n. 1
0
 internal static void Postfix(GameObject ___selectedTarget, CollapsibleDetailContentPanel ___immuneSystemPanel, bool __result)
 {
     if (__result)
     {
         AttributeInstance susceptibility = Db.Get().Attributes.Get(HeartAttackMonitor.ATTRIBUTE_ID).Lookup(___selectedTarget);
         if (susceptibility != null)
         {
             ___immuneSystemPanel.SetLabel(HeartAttackMonitor.ATTRIBUTE_ID, susceptibility.modifier.Name + ": " + GameUtil.GetFormattedPercent(100f * Mathf.Clamp01(susceptibility.GetTotalValue())), susceptibility.GetAttributeValueTooltip());
         }
     }
 }
 public void InitCreater(Transform parent, AllEnemyData enemyData, EnemyTrajectoryDataMgr trajectoryData, LevelData levelData)
 {
     _normalCreaters = GameUtil.InitCreater(EnemyType.Normal, parent, enemyData, trajectoryData, levelData);
 }
Esempio n. 3
0
    private string HoverPersonalPriority(object widget_go_obj)
    {
        GameObject gameObject = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(gameObject) as PrioritizationGroupTableColumn;
        ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
        string     text       = null;
        TableRow   widgetRow  = GetWidgetRow(gameObject);

        switch (widgetRow.rowType)
        {
        case TableRow.RowType.Header:
        {
            string text2 = UI.JOBSSCREEN.HEADER_TOOLTIP.ToString();
            text2 = text2.Replace("{Job}", choreGroup.Name);
            string text3 = UI.JOBSSCREEN.HEADER_DETAILS_TOOLTIP.ToString();
            text3 = text3.Replace("{Description}", choreGroup.description);
            HashSet <string> hashSet = new HashSet <string>();
            foreach (ChoreType choreType in choreGroup.choreTypes)
            {
                hashSet.Add(choreType.Name);
            }
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;
            foreach (string item in hashSet)
            {
                stringBuilder.Append(item);
                if (num < hashSet.Count - 1)
                {
                    stringBuilder.Append(", ");
                }
                num++;
            }
            text3 = text3.Replace("{ChoreList}", stringBuilder.ToString());
            return(text2.Replace("{Details}", text3));
        }

        case TableRow.RowType.Default:
            text = UI.JOBSSCREEN.NEW_MINION_ITEM_TOOLTIP.ToString();
            break;

        case TableRow.RowType.Minion:
        case TableRow.RowType.StoredMinon:
            text = UI.JOBSSCREEN.ITEM_TOOLTIP.ToString();
            text = text.Replace("{Name}", widgetRow.name);
            break;
        }
        ToolTip             componentInChildren = gameObject.GetComponentInChildren <ToolTip>();
        IAssignableIdentity identity            = widgetRow.GetIdentity();
        MinionIdentity      minionIdentity      = identity as MinionIdentity;

        if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
        {
            IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
            int    personalPriority = priorityManager.GetPersonalPriority(choreGroup);
            string newValue         = GetPriorityStr(personalPriority);
            string priorityValue    = GetPriorityValue(personalPriority);
            if (priorityManager.IsChoreGroupDisabled(choreGroup))
            {
                Trait  trait     = null;
                Traits component = minionIdentity.GetComponent <Traits>();
                foreach (Trait trait2 in component.TraitList)
                {
                    if (trait2.disabledChoreGroups != null)
                    {
                        ChoreGroup[] disabledChoreGroups = trait2.disabledChoreGroups;
                        foreach (ChoreGroup choreGroup2 in disabledChoreGroups)
                        {
                            if (choreGroup2.IdHash == choreGroup.IdHash)
                            {
                                trait = trait2;
                                break;
                            }
                        }
                        if (trait != null)
                        {
                            break;
                        }
                    }
                }
                text = UI.JOBSSCREEN.TRAIT_DISABLED.ToString();
                text = text.Replace("{Name}", minionIdentity.GetProperName());
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Trait}", trait.Name);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
            }
            else
            {
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Priority}", newValue);
                text = text.Replace("{PriorityValue}", priorityValue);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
                if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
                {
                    text = "\n" + UI.JOBSSCREEN.MINION_SKILL_TOOLTIP.ToString();
                    text = text.Replace("{Name}", minionIdentity.GetProperName());
                    text = text.Replace("{Attribute}", choreGroup.attribute.Name);
                    AttributeInstance attributeInstance        = minionIdentity.GetAttributes().Get(choreGroup.attribute);
                    float             totalValue               = attributeInstance.GetTotalValue();
                    TextStyleSetting  tooltipTextStyle_Ability = TooltipTextStyle_Ability;
                    text += GameUtil.ColourizeString(tooltipTextStyle_Ability.textColor, totalValue.ToString());
                    componentInChildren.AddMultiStringTooltip(text, null);
                }
                componentInChildren.AddMultiStringTooltip(UI.HORIZONTAL_RULE + "\n" + GetUsageString(), null);
            }
        }
        else if ((UnityEngine.Object)(identity as StoredMinionIdentity) != (UnityEngine.Object)null)
        {
            componentInChildren.AddMultiStringTooltip(string.Format(UI.JOBSSCREEN.CANNOT_ADJUST_PRIORITY, identity.GetProperName(), (identity as StoredMinionIdentity).GetStorageReason()), null);
        }
        return(string.Empty);
    }
    public void setPropId(int prop_id)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("PropDetailPanelScript_hotfix", "setPropId"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.PropDetailPanelScript_hotfix", "setPropId", null, prop_id);
            return;
        }

        m_propInfo = PropData.getInstance().getPropInfoById(prop_id);

        if (m_propInfo != null)
        {
            m_text_name.text = m_propInfo.m_name;
            m_text_desc.text = m_propInfo.m_desc;
            CommonUtil.setImageSprite(m_image_icon, GameUtil.getPropIconPath(m_propInfo.m_id));

            if (m_propInfo.m_type != 0)
            {
                m_button_use.transform.localScale = new Vector3(0, 0, 0);
            }

            // 一元话费:显示数量调节对象
            if (m_propInfo.m_id == (int)TLJCommon.Consts.Prop.Prop_1yuanhuafei)
            {
                int myHuaFei_1 = GameUtil.getMyPropNumById((int)TLJCommon.Consts.Prop.Prop_1yuanhuafei);
                if (myHuaFei_1 >= 10)
                {
                    GameUtil.showGameObject(m_changeNum);
                    m_useNum = 10;

                    m_changeNum.transform.Find("Button_jia").GetComponent <Button>().interactable = false;
                }
                else if (myHuaFei_1 >= 5)
                {
                    GameUtil.showGameObject(m_changeNum);
                    m_useNum = 5;

                    m_changeNum.transform.Find("Button_jia").GetComponent <Button>().interactable = false;
                }

                m_changeNum.transform.Find("Text_num").GetComponent <Text>().text = m_useNum.ToString();
            }

            if ((m_propInfo.m_id == 111) ||
                (m_propInfo.m_id == 112) ||
                (m_propInfo.m_id == 113))
            {
                GameObject obj  = new GameObject();
                Text       text = obj.AddComponent <Text>();
                text.text     = "完成一次对局方可使用";
                text.fontSize = 20;
                CommonUtil.setFontColor(text, 0, 0, 0);
                text.font = transform.Find("Image_bg/Text_desc").GetComponent <Text>().font;
                text.GetComponent <RectTransform>().sizeDelta = new Vector2(250, 30);

                obj.transform.SetParent(transform.Find("Image_bg"));
                obj.transform.localPosition = new Vector3(26, 30, 0);
                obj.transform.localScale    = new Vector3(1, 1, 1);
            }
        }
    }
Esempio n. 5
0
 private void OnRoleResurgenceCallBack()
 {
     m_FightResultWin.Close();
     GameUtil.OnGameLevelRoleResurgence();
 }
            private static void DrawerHelper(SelectToolHoverTextCard inst, int cell, HoverTextDrawer drawer)
            {
                // Cell position info
                drawer.BeginShadowBar();
                var pos = Grid.CellToPos(cell);

                drawer.DrawText("POSITION", inst.Styles_Title.Standard);
                drawer.NewLine();
                drawer.DrawText($"({pos.x}, {pos.y})", inst.Styles_BodyText.Standard);
                drawer.NewLine();
                drawer.DrawText($"Cell {cell}", inst.Styles_BodyText.Standard);
                drawer.EndShadowBar();

                // Counts
                drawer.BeginShadowBar();
                drawer.DrawText("COUNT", inst.Styles_Title.Standard);
                drawer.NewLine();
                var p     = Grid.Objects[cell, (int)ObjectLayer.Pickupables];
                var count = 0;

                while (p != null && p.GetComponent <Pickupable>() is Pickupable p2)
                {
                    ++count;
                    p = p2.objectLayerListItem?.nextItem?.gameObject;
                }

                drawer.DrawText($"Pickupables: {count}", inst.Styles_BodyText.Standard);
                drawer.EndShadowBar();

                // Element info
                drawer.BeginShadowBar();
                var element = Grid.Element[cell];

                drawer.DrawText("ELEMENT", inst.Styles_Title.Standard);
                drawer.NewLine();
                drawer.DrawText($"Name: {element.name}", inst.Styles_BodyText.Standard);
                drawer.NewLine();
                var hardnessStr = GameUtil.GetHardnessString(element);

                if (hardnessStr == ELEMENTS.HARDNESS.NA)
                {
                    hardnessStr = "Not Solid";
                }

                drawer.DrawText($"Hardness: {hardnessStr}", inst.Styles_BodyText.Standard);

                // element.HasTransitionDown doesn't exist :c
                if (element.lowTempTransitionTarget != 0 && element.lowTempTransitionTarget != SimHashes.Unobtanium &&
                    element.lowTempTransition != null && element.lowTempTransition != element)
                {
                    drawer.NewLine();
                    drawer.DrawText(
                        $"Transition down to {element.lowTempTransition.name} at {Math.Round(GameUtil.GetTemperatureConvertedFromKelvin(element.lowTemp, GameUtil.temperatureUnit), 2)}{GameUtil.GetTemperatureUnitSuffix()}",
                        inst.Styles_BodyText.Standard
                        );
                }

                if (element.HasTransitionUp)
                {
                    drawer.NewLine();
                    drawer.DrawText(
                        $"Transition up to {element.highTempTransition.name} at {Math.Round(GameUtil.GetTemperatureConvertedFromKelvin(element.highTemp, GameUtil.temperatureUnit), 2)}{GameUtil.GetTemperatureUnitSuffix()}",
                        inst.Styles_BodyText.Standard
                        );
                }

                drawer.NewLine();
                drawer.DrawText(
                    $"Specific Heat Capacity: {GameUtil.GetFormattedSHC(element.specificHeatCapacity)}",
                    inst.Styles_BodyText.Standard
                    );

                drawer.NewLine();
                drawer.DrawText(
                    $"Thermal Conductivity: {GameUtil.GetThermalConductivityString(element)}",
                    inst.Styles_BodyText.Standard
                    );

                drawer.EndShadowBar();
            }
Esempio n. 7
0
 /// <summary>
 ///     Get the tower gun sprite's bounding rectangle
 /// </summary>
 /// <returns> the rectangle </returns>
 protected internal virtual Rect2 GetRect() => GameUtil.GetRect(TowerGun);
    public void showTab(CurShowTab m_curShowTab)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("TuiGuangYouLiPanelScript_hotfix", "showTab"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.TuiGuangYouLiPanelScript_hotfix", "showTab", null, m_curShowTab);
            return;
        }

        switch (m_curShowTab)
        {
        case CurShowTab.CurShowTab_wodetuiguang:
        {
            GameUtil.showGameObject(m_tab_wodetuiguang);
            GameUtil.hideGameObject(m_tab_tuiguangguize);
            GameUtil.hideGameObject(m_tab_bulingjiangli);

            GameUtil.showGameObject(m_btn_yijianlingqu.gameObject);

            {
                CommonUtil.setImageSprite(m_btn_myTuiGuang.GetComponent <Image>(), "Sprites/Common/tab_xuanze");
                CommonUtil.setImageSprite(m_btn_tuigungguize.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");
                CommonUtil.setImageSprite(m_btn_bulingjiangli.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");

                m_btn_myTuiGuang.GetComponent <Image>().SetNativeSize();
                m_btn_tuigungguize.GetComponent <Image>().SetNativeSize();
                m_btn_bulingjiangli.GetComponent <Image>().SetNativeSize();

                CommonUtil.setImageSpriteByAssetBundle(m_btn_myTuiGuang.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "wdtg02");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_tuigungguize.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "tg01");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_bulingjiangli.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "bljl01");
            }

            loadMyTuiGuangData();
        }
        break;

        case CurShowTab.CurShowTab_tuiguangguize:
        {
            GameUtil.hideGameObject(m_tab_wodetuiguang);
            GameUtil.showGameObject(m_tab_tuiguangguize);
            GameUtil.hideGameObject(m_tab_bulingjiangli);

            GameUtil.hideGameObject(m_btn_yijianlingqu.gameObject);

            {
                CommonUtil.setImageSprite(m_btn_myTuiGuang.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");
                CommonUtil.setImageSprite(m_btn_tuigungguize.GetComponent <Image>(), "Sprites/Common/tab_xuanze");
                CommonUtil.setImageSprite(m_btn_bulingjiangli.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");

                m_btn_myTuiGuang.GetComponent <Image>().SetNativeSize();
                m_btn_tuigungguize.GetComponent <Image>().SetNativeSize();
                m_btn_bulingjiangli.GetComponent <Image>().SetNativeSize();

                CommonUtil.setImageSpriteByAssetBundle(m_btn_myTuiGuang.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "wdtg01");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_tuigungguize.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "tg02");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_bulingjiangli.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "bljl01");
            }
        }
        break;

        case CurShowTab.CurShowTab_bulingjiangli:
        {
            GameUtil.hideGameObject(m_tab_wodetuiguang);
            GameUtil.hideGameObject(m_tab_tuiguangguize);
            GameUtil.showGameObject(m_tab_bulingjiangli);

            GameUtil.hideGameObject(m_btn_yijianlingqu.gameObject);

            {
                CommonUtil.setImageSprite(m_btn_myTuiGuang.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");
                CommonUtil.setImageSprite(m_btn_tuigungguize.GetComponent <Image>(), "Sprites/Common/tab_weixuanze");
                CommonUtil.setImageSprite(m_btn_bulingjiangli.GetComponent <Image>(), "Sprites/Common/tab_xuanze");

                m_btn_myTuiGuang.GetComponent <Image>().SetNativeSize();
                m_btn_tuigungguize.GetComponent <Image>().SetNativeSize();
                m_btn_bulingjiangli.GetComponent <Image>().SetNativeSize();

                CommonUtil.setImageSpriteByAssetBundle(m_btn_myTuiGuang.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "wdtg01");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_tuigungguize.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "tg01");
                CommonUtil.setImageSpriteByAssetBundle(m_btn_bulingjiangli.transform.Find("Image").GetComponent <Image>(), "tuiguang.unity3d", "bljl02");
            }
        }
        break;
        }
    }
    public void onCallBackOneKeyGetAllTuiGuangReward(string data)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("TuiGuangYouLiPanelScript_hotfix", "onCallBackOneKeyGetAllTuiGuangReward"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.TuiGuangYouLiPanelScript_hotfix", "onCallBackOneKeyGetAllTuiGuangReward", null, data);
            return;
        }

        NetLoading.getInstance().Close();

        JsonData jsonData = JsonMapper.ToObject(data);
        int      code     = (int)jsonData["code"];

        if (code == (int)TLJCommon.Consts.Code.Code_OK)
        {
            // 禁用一键领取按钮
            m_btn_yijianlingqu.interactable = false;

            string reward = (string)jsonData["reward"];

            if (reward.CompareTo("") != 0)
            {
                List <string> list = new List <string>();
                CommonUtil.splitStr(reward, list, ';');
                for (int i = 0; i < list.Count; i++)
                {
                    GameUtil.changeData(GameUtil.getPropIdFromReward(list[i]), GameUtil.getPropNumFromReward(list[i]));

                    ShowRewardPanelScript.Show(list[i], false);
                }

                for (int i = 0; i < MyTuiGuangData.getInstance().getMyTuiGuangDataList().Count; i++)
                {
                    MyTuiGuangDataContent temp = MyTuiGuangData.getInstance().getMyTuiGuangDataList()[i];

                    GameObject obj = null;
                    for (int j = 0; j < m_listview_player.getItemList().Count; j++)
                    {
                        if (m_listview_player.getItemList()[j].transform.name.CompareTo(temp.uid) == 0)
                        {
                            obj = m_listview_player.getItemList()[j];
                            break;
                        }
                    }

                    if (temp.task1_state == 2)
                    {
                        temp.task1_state = 3;

                        obj.transform.Find("Text_task1_state").GetComponent <Text>().text          = "";
                        obj.transform.Find("Text_task1_state/Image_yilingqu").transform.localScale = new Vector3(1, 1, 1);
                        CommonUtil.setFontColor(obj.transform.Find("Text_task1_state").GetComponent <Text>(), 99, 99, 99);
                    }

                    if (temp.task2_state == 2)
                    {
                        temp.task2_state = 3;

                        obj.transform.Find("Text_task2_state").GetComponent <Text>().text          = "";
                        obj.transform.Find("Text_task2_state/Image_yilingqu").transform.localScale = new Vector3(1, 1, 1);
                        CommonUtil.setFontColor(obj.transform.Find("Text_task2_state").GetComponent <Text>(), 99, 99, 99);
                    }
                }

                ToastScript.createToast("领取奖励成功");
            }
            else
            {
                ToastScript.createToast("当前没有奖励可领取");
            }
        }
        else
        {
            string msg = (string)jsonData["msg"];

            ToastScript.createToast(msg);
        }
    }
Esempio n. 10
0
 protected virtual void InitializeNumberBounces()
 {
     BouncesLeft = 1 + GameUtil.PlusOneIfMaxWeaponLevel(BulletLevel);
 }
Esempio n. 11
0
    public void FilterVisibleObjects(float percentage, float psysPercent)
    {
        List <Renderer> VisibleRenderers = new List <Renderer>();
        List <ParticleSystemRenderer> VisiblePSysRenderers = new List <ParticleSystemRenderer>();

        foreach (Renderer r in UnityEngine.Object.FindObjectsOfType(typeof(Renderer)) as Renderer[])
        {
            if (r.isVisible && r.enabled && IsEnvironmentObject(r.gameObject))
            {
                if (r is ParticleSystemRenderer)
                {
                    VisiblePSysRenderers.Add((ParticleSystemRenderer)r);
                }
                else
                {
                    VisibleRenderers.Add(r);
                }
            }
        }

        DoFilter <Renderer>(VisibleRenderers, DisabledRenderers, GameUtil.Clamp(percentage, 0.0f, 1.0f));
        DoFilter <ParticleSystemRenderer>(VisiblePSysRenderers, DisabledParticleSystems, GameUtil.Clamp(psysPercent, 0.0f, 1.0f));
    }
    public override string GetFormattedValue(float value, GameUtil.TimeSlice timeSlice, GameObject parent_instance)
    {
        int quality = (int)value;

        return(Util.StripTextFormatting(GameUtil.GetFormattedFoodQuality(quality)));
    }
 public override string GetFormattedModifier(AttributeModifier modifier, GameObject parent_instance)
 {
     return(GameUtil.GetFormattedInt(modifier.Value, GameUtil.TimeSlice.None));
 }
Esempio n. 14
0
        public EquipmentDef CreateEquipmentDef()
        {
            var attributeModifiers = new List <AttributeModifier>();

            #region Def Show Effect

            var temperature        = $"{DUPLICANTS.ATTRIBUTES.THERMALCONDUCTIVITYBARRIER.NAME}: {GameUtil.GetFormattedDistance(clothingInfo.conductivityMod)}";
            var temperatureTooltip = temperature;

            var decor        = $"{DUPLICANTS.ATTRIBUTES.DECOR.NAME}: {clothingInfo.decorMod}";
            var decorTooltip = decor;

            #endregion

            Descriptor temperatureDesc = new Descriptor(temperature,temperatureTooltip,Descriptor.DescriptorType.Effect,false);
            Descriptor decorDesc       = new Descriptor(decor,decorTooltip,Descriptor.DescriptorType.Effect,false);

            var def = EquipmentTemplates.CreateEquipmentDef(ID,SLOT,SimHashes.Carbon,MASS,ANIM,SNAP_ON,BUILD_OVERRIDE,4,attributeModifiers,SNAP_ON1,true,EntityTemplates.CollisionShape.RECTANGLE,0.75f,0.4f,null,null);
            def.additionalDescriptors.Add(temperatureDesc);
            def.additionalDescriptors.Add(decorDesc);
            def.OnEquipCallBack   = delegate(Equippable eq) { OnEquip(eq,clothingInfo); };
            def.OnUnequipCallBack = ActionEq ?? (ActionEq = new Action <Equippable>(OnUnequip));
            def.RecipeDescription = RECIPE_DESC;

            return(def);
        }
Esempio n. 15
0
 /// <summary>
 /// 设置用户分数
 /// </summary>
 /// <param name="score"></param>
 /// <returns></returns>
 public LeaderBoardDialog setUserScore(int score)
 {
     mUserScore = score;
     mCurrentScoreContentStr = GameUtil.GetTimeStr(score);
     return(this);
 }
Esempio n. 16
0
        /// <summary>
        /// Sums up thermal masses and reports the total thermal mass.
        /// </summary>
        /// <param name="values">The info cards to add up.</param>
        /// <returns>A string describing their total thermal mass.</returns>
        private static string SumThermalMass(string _, List <float> values)
        {
            float sum = 0;

            foreach (var value in values)
            {
                sum += value;
            }
            return(string.Format(ThermalTooltipsStrings.THERMAL_MASS, ExtendedThermalTooltip.
                                 DoScientific(sum), STRINGS.UI.UNITSUFFIXES.HEAT.KDTU.text.Trim(), GameUtil.
                                 GetTemperatureUnitSuffix()?.Trim()) + ThermalTooltipsStrings.SUM);
        }
 public LocString ThresholdValueUnits()
 {
     return(GameUtil.GetCurrentMassUnit(true));
 }
Esempio n. 18
0
    public static void SetInstanceMaterialParams_Disslove(Material material)
    {
        // public enum BlendMode
        //{
        //    Opaque,
        //    Cutout,
        //    Fade,		// Old school alpha-blending mode, fresnel does not affect amount of transparency
        //    Transparent // Physically plausible transparency mode, implemented as alpha pre-multiply
        //}
        string shaderName = material.shader.name;

        if (GameUtil.isLightMappingShader(shaderName))
        {
            return;
        }
        if (!GameUtil.isStandardShader(shaderName))
        {
            return;
        }

        //对于原来不是cutout的,把cutoff设置为0
        if (!GameUtil.FloatEquls(material.GetFloat("_Mode"), 1))
        {
            material.SetFloat("_Cutoff", 0.0f);
        }


        //1是cutout
        material.SetFloat("_Mode", 1.0f);

        material.SetOverrideTag("RenderType", "TransparentCutout");
        material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
        material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
        material.SetInt("_ZWrite", 1);
        material.EnableKeyword("_ALPHATEST_ON");
        material.DisableKeyword("_ALPHABLEND_ON");
        material.DisableKeyword("_ALPHAPREMULTIPLY_ON");


        //if (shaderName.Contains("Standard (Specular setup)"))
        //{
        //    Texture t = material.GetTexture("_SpecGlossMap");
        //    if (t)
        //    {
        //        material.EnableKeyword("_SPECGLOSSMAP");
        //    }
        //    else
        //    {
        //        material.DisableKeyword("_SPECGLOSSMAP");
        //    }
        //}
        //else
        //{
        //    Texture t = material.GetTexture("_MetallicGlossMap");
        //    if (t)
        //    {
        //        material.EnableKeyword("_METALLICGLOSSMAP");
        //    }
        //    else
        //    {
        //        material.DisableKeyword("_METALLICGLOSSMAP");
        //    }
        //}
        //Color emissioncolor = material.GetColor("_EmissionColor");
        //bool shouldEmissionBeEnabled = emissioncolor.grayscale > (0.1f / 255.0f);

        //MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
        //if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
        //{
        //    flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
        //    if (!shouldEmissionBeEnabled)
        //        flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;

        //    material.globalIlluminationFlags = flags;
        //}

        material.renderQueue = 2450;
    }
Esempio n. 19
0
 /// <summary>
 /// Creates the text which describes the calorie delta for one cycle.
 /// </summary>
 /// <param name="text">The description text.</param>
 /// <param name="produced">The kcal produced.</param>
 /// <param name="consumed">The kcal consumed.</param>
 /// <returns>The description text with the formatted kcal values substituted.</returns>
 private static string FormatDeltaTooltip(string text, float produced, float consumed)
 {
     return(text.F(GameUtil.GetFormattedCalories(produced), GameUtil.
                   GetFormattedCalories(consumed)));
 }
            public override void InitializeStates(out BaseState default_state)
            {
                if (waitingForCoolantStatus == null)
                {
                    waitingForCoolantStatus = new StatusItem("waitingForCoolantStatus", BUILDING.STATUSITEMS.ENOUGH_COOLANT.NAME, BUILDING.STATUSITEMS.ENOUGH_COOLANT.TOOLTIP, "status_item_no_liquid_to_pump", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID)
                    {
                        resolveStringCallback = delegate(string str, object obj)
                        {
                            var lcfr = (LiquidCooledFueledRefinery)obj;
                            return(string.Format(str, lcfr.coolantTag.ProperName(), GameUtil.GetFormattedMass(lcfr.minCoolantMass, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")));
                        }
                    };
                }
                if (waitingForFuelStatus == null)
                {
                    waitingForFuelStatus = new StatusItem("waitingForFuelStatus", BUILDING.STATUSITEMS.ENOUGH_FUEL.NAME, BUILDING.STATUSITEMS.ENOUGH_FUEL.TOOLTIP, "status_item_resource_unavailable", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID)
                    {
                        resolveStringCallback = delegate(string str, object obj)
                        {
                            var lcfr = (LiquidCooledFueledRefinery)obj;
                            return(string.Format(str, lcfr.fuelTag.ProperName(), GameUtil.GetFormattedMass(SmelterConfig.START_FUEL_MASS, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")));
                        }
                    };
                }
                if (waitingForEmptyingStatus == null)
                {
                    waitingForEmptyingStatus = new StatusItem("waitingForEmptying", STRINGS.BUILDINGS.STATUSITEMS.SMELTERNEEDSEMPTYING.NAME, STRINGS.BUILDINGS.STATUSITEMS.SMELTERNEEDSEMPTYING.TOOLTIP, "status_item_empty_pipe", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID);
                }

                default_state = waiting;
                // у нас нет выходной трубы, однако воспользуемся готовым флагом для обработки нехватки топлива
                // внимание! если событие OnStorageChange (или иное событие)
                // прилетело из глубины недр ComplexFabricator в процессе выполнения рецепта
                // то попытка манипулировать флагами operational.SetFlag
                // приводит к хитровыебанному вылету в недрах ComplexFabricator
                // поэтому выключать флаг нужно только в проверке IsOutOfFuel (прилетает от ElementConverter)
                // или в проверках выполняемых не во время выполнения рецепта
                root
                .OnSignal(coolant_too_hot, needsEmptying);
                waiting
                .Enter((StatesInstance smi) => smi.UpdateStates())
                .EventHandler(GameHashes.OnStorageChange, (StatesInstance smi) => smi.UpdateStates());
                waiting.for_coolant
                .ToggleStatusItem(waitingForCoolantStatus, (StatesInstance smi) => smi.master);
                waiting.for_fuel
                .ToggleStatusItem(waitingForFuelStatus, (StatesInstance smi) => smi.master);
                waiting.for_coolant_and_fuel
                .ToggleStatusItem(waitingForCoolantStatus, (StatesInstance smi) => smi.master)
                .ToggleStatusItem(waitingForFuelStatus, (StatesInstance smi) => smi.master);
                ready
                .Enter((StatesInstance smi) =>
                {
                    smi.master.SetQueueDirty();
                    smi.master.operational.SetFlag(coolantOutputPipeEmpty, true);
                })
                .EventTransition(GameHashes.OnStorageChange, waiting, (StatesInstance smi) => !smi.master.HasEnoughCoolant() || smi.master.IsOutOfFuel());
                needsEmptying
                .Enter((StatesInstance smi) =>
                {
                    smi.master.operational.SetFlag(coolantOutputPipeEmpty, false);
                    smi.master.SetQueueDirty();
                    smi.Trigger((int)GameHashes.DroppedAll);     // обработчик в ComplexFabricator очищает и обновляет очередь задач. должно помочь предотвратить сбои
                    smi.CreateEmptyChore();
                })
                .Exit((StatesInstance smi) => smi.CancelEmptyChore())
                .EventTransition(GameHashes.OnStorageChange, waiting, (StatesInstance smi) => smi.master.IsHotCoolantIsRemoved())
                .ToggleStatusItem(waitingForEmptyingStatus);
            }
Esempio n. 21
0
 public string Format(float value, bool units)
 {
     return(GameUtil.GetFormattedInt((float)(int)value, GameUtil.TimeSlice.None));
 }
Esempio n. 22
0
    /// <summary>
    /// 摇骰子 只使用第二次摇骰子
    /// </summary>
    /// <param name="firstDiceA">第一次摇</param>
    /// <param name="firstDiceB"></param>
    /// <param name="secondDiceA">第二次摇</param>
    /// <param name="secondDiceB"></param>
    private IEnumerator RollDice(int firstDiceA, int firstDiceB, int secondDiceA, int secondDiceB, System.Action OnComplete = null)
    {
        int bankerPos = RoomPaiJiuProxy.Instance.BankerSeat.Pos;

        if (bankerPos == 2 && RoomPaiJiuProxy.Instance.CurrentRoom.SeatList.Count == 2)
        {
            bankerPos = 3;
        }
        //==================手动画动画==========================
        if (SystemProxy.Instance.HasHand)
        {
            if (hand == null)
            {
                string handPrefabName = "dicehand";
                string handPath       = string.Format("download/{0}/prefab/model/{1}.drb", ConstDefine.GAME_NAME, handPrefabName);
                AssetBundleManager.Instance.LoadOrDownload(handPath, handPrefabName, (GameObject go) =>
                {
                    hand = Instantiate(go);
                    hand.SetParent(m_DiceHandContainer);
                    hand.transform.localEulerAngles = new Vector3(0, (bankerPos - 1) * (-90f), 0);
                });
            }
            else
            {
                hand.transform.localEulerAngles = new Vector3(0, (bankerPos - 1) * (-90f), 0);
                hand.SetActive(true);
            }


            yield return(new WaitForSeconds(0.5f));
        }


        //==================骰子动画==========================
        AudioEffectManager.Instance.Play("rolldice", Vector3.zero, false);
        string prefabName = "dice";
        string path       = string.Format("download/{0}/prefab/model/{1}.drb", ConstDefine.GAME_NAME, prefabName);

        AssetBundleManager.Instance.LoadOrDownload(path, prefabName, (GameObject go) =>
        {
            go = Instantiate(go);
            DRB.MahJong.DiceCtrl ctrl = go.GetComponent <DRB.MahJong.DiceCtrl>();
            go.SetParent(m_DiceContainer[0]);
            go.transform.localPosition = GameUtil.GetRandomPos(go.transform.position, 1f);
            ctrl.Roll(firstDiceA, secondDiceA);
        });

        AssetBundleManager.Instance.LoadOrDownload(path, prefabName, (GameObject go) =>
        {
            go = Instantiate(go);
            DRB.MahJong.DiceCtrl ctrl2 = go.GetComponent <DRB.MahJong.DiceCtrl>();
            go.SetParent(m_DiceContainer[1]);
            go.transform.localPosition = GameUtil.GetRandomPos(go.transform.position, 1f);
            ctrl2.Roll(firstDiceB, secondDiceB);
        });

        if (OnComplete != null)
        {
            yield return(new WaitForSeconds(2f));

            OnComplete();
        }
    }
Esempio n. 23
0
 /// <summary>
 /// When the door is first instantiated, initializes the static fields, to avoid the
 /// crash that the stock Door has if it is loaded too early.
 /// </summary>
 private static void StaticInit()
 {
     doorControlState = new StatusItem("CurrentDoorControlState", "BUILDING", "",
                                       StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.
                                       None.ID)
     {
         resolveStringCallback = (str, data) => {
             bool locked = (data as AirlockDoor)?.locked ?? true;
             return(str.Replace("{ControlState}", Strings.Get(
                                    "STRINGS.BUILDING.STATUSITEMS.CURRENTDOORCONTROLSTATE." + (locked ?
                                                                                               "LOCKED" : "AUTO"))));
         }
     };
     storedCharge = new StatusItem("AirlockStoredCharge", "BUILDING", "", StatusItem.
                                   IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID)
     {
         resolveStringCallback = (str, data) => {
             if (data is AirlockDoor door)
             {
                 str = string.Format(str, GameUtil.GetFormattedRoundedJoules(door.
                                                                             EnergyAvailable), GameUtil.GetFormattedRoundedJoules(door.
                                                                                                                                  EnergyCapacity), GameUtil.GetFormattedRoundedJoules(door.
                                                                                                                                                                                      EnergyPerUse));
             }
             return(str);
         }
     };
 }
    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);
        }
    }
 protected override void Execute(List <GameEntity> entities)
 {
     GameUtil.MakeState(_game, _syncBuffer);
 }
Esempio n. 26
0
            public override void InitializeStates(out BaseState defaultState)
            {
                serializable = true;
                defaultState = Alive;

                var dead    = CREATURES.STATUSITEMS.DEAD.NAME;
                var tooltip = CREATURES.STATUSITEMS.DEAD.TOOLTIP;
                var main    = Db.Get().StatusItemCategories.Main;

                Dead
                .ToggleStatusItem(dead, tooltip, string.Empty, StatusItem.IconType.Info, 0, false, OverlayModes.None.ID, 0, category: main)
                .Enter(smi =>
                {
                    if (smi.master.rm.Replanted && !smi.master.GetComponent <KPrefabID>().HasTag(GameTags.Uprooted))
                    {
                        smi.master.gameObject.AddOrGet <Notifier>().Add(smi.master.CreateDeathNotification());
                    }

                    GameUtil.KInstantiate(Assets.GetPrefab(EffectConfigs.PlantDeathId), smi.master.transform.GetPosition(), Grid.SceneLayer.FXFront).SetActive(true);
                    if (smi.master.harvestable != null && smi.master.harvestable.CanBeHarvested && GameScheduler.Instance != null)
                    {
                        GameScheduler.Instance.Schedule("SpawnFruit", 0.2f, smi.master.crop.SpawnFruit);
                    }

                    smi.master.Trigger((int)GameHashes.Died);
                    smi.master.GetComponent <KBatchedAnimController>().StopAndClear();
                    Destroy(smi.master.GetComponent <KBatchedAnimController>());
                    smi.Schedule(0.5f, smi.master.DestroySelf);
                });
                Alive
                .InitializeStates(masterTarget, Dead)
                .DefaultState(Alive.Idle)
                .ToggleComponent <Growing>();

                Alive.Idle
                .Enter(smi => smi.master.elementConsumer.EnableConsumption(true))
                .EventTransition(GameHashes.Wilt, Alive.WiltingPre, smi => smi.master.wiltCondition.IsWilting())
                .EventTransition(GameHashes.Grow, Alive.PreFruiting, smi => smi.master.growing.ReachedNextHarvest())
                .PlayAnim(AnimSet.grow, KAnim.PlayMode.Loop)
                .Exit(smi => smi.master.elementConsumer.EnableConsumption(false));

                Alive.PreFruiting
                .PlayAnim("grow", KAnim.PlayMode.Once)
                .EventTransition(GameHashes.AnimQueueComplete, Alive.Fruiting);

                Alive.FruitingLost
                .Enter(smi => smi.master.harvestable.SetCanBeHarvested(false))
                .GoTo(Alive.Idle);

                Alive.Wilting
                .PlayAnim(AnimSet.wilt1, KAnim.PlayMode.Loop)
                .EventTransition(GameHashes.WiltRecover, Alive.WiltingPst, smi => !smi.master.wiltCondition.IsWilting())
                .EventTransition(GameHashes.Harvest, Alive.Harvest);
                Alive.WiltingPst
                .PlayAnim(AnimSet.wilt1, KAnim.PlayMode.Once)
                .OnAnimQueueComplete(Alive.Idle);

                Alive.Fruiting
                .DefaultState(Alive.Fruiting.FruitingIdle)
                .EventTransition(GameHashes.Wilt, Alive.WiltingPre)
                .EventTransition(GameHashes.Harvest, Alive.Harvest)
                .EventTransition(GameHashes.Grow, Alive.FruitingLost, smi => !smi.master.growing.ReachedNextHarvest());

                Alive.Fruiting.FruitingIdle
                .PlayAnim(AnimSet.idle_full, KAnim.PlayMode.Loop)
                .Enter(smi => smi.master.harvestable.SetCanBeHarvested(true))
                .Enter(smi => smi.master.elementConsumer.EnableConsumption(true))
                .Enter(smi => smi.master.elementEmitter.SetEmitting(true))
                .Update("fruiting_idle", (smi, dt) =>
                {
                    if (!smi.IsOld())
                    {
                        return;
                    }
                    smi.GoTo(Alive.Fruiting.FruitingOld);
                }, UpdateRate.SIM_4000ms)
                .Exit(smi => smi.master.elementEmitter.SetEmitting(false))
                .Exit(smi => smi.master.elementConsumer.EnableConsumption(false));

                Alive.Fruiting.FruitingOld
                .PlayAnim(AnimSet.wilt1, KAnim.PlayMode.Loop)
                .Enter(smi => smi.master.harvestable.SetCanBeHarvested(true))
                .Update("fruiting_old", (smi, dt) =>
                {
                    if (smi.IsOld())
                    {
                        return;
                    }
                    smi.GoTo(Alive.Fruiting.FruitingIdle);
                }, UpdateRate.SIM_4000ms);

                Alive.Harvest
                .PlayAnim(AnimSet.harvest, KAnim.PlayMode.Once)
                .Enter(smi =>
                {
                    if (GameScheduler.Instance == null || smi.master == null)
                    {
                        return;
                    }

                    GameScheduler.Instance.Schedule("SpawnFruit", 0.2f, smi.master.crop.SpawnFruit);
                    smi.master.harvestable.SetCanBeHarvested(false);
                })
                .OnAnimQueueComplete(Alive.Idle);
            }
Esempio n. 27
0
    public void FilterVisibleObjects(float percentage, float psysPercent)
    {
        List <Renderer> visible1 = new List <Renderer>();
        List <ParticleSystemRenderer> visible2 = new List <ParticleSystemRenderer>();

        foreach (Renderer renderer in Object.FindObjectsOfType(typeof(Renderer)) as Renderer[])
        {
            if (renderer.get_isVisible() && renderer.get_enabled() && this.IsEnvironmentObject(((Component)renderer).get_gameObject()))
            {
                if (renderer is ParticleSystemRenderer)
                {
                    visible2.Add((ParticleSystemRenderer)renderer);
                }
                else
                {
                    visible1.Add(renderer);
                }
            }
        }
        this.DoFilter <Renderer>(visible1, this.DisabledRenderers, GameUtil.Clamp(percentage, 0.0f, 1f));
        this.DoFilter <ParticleSystemRenderer>(visible2, this.DisabledParticleSystems, GameUtil.Clamp(psysPercent, 0.0f, 1f));
    }
Esempio n. 28
0
 void Update()
 {
     button.interactable = PlayerController.instance.gems >= unitPrefab.buildCost;
     GameUtil.SetImageAlpha(background, button.interactable ? 1 : 0.6f);
 }
Esempio n. 29
0
 private string GetUsageString()
 {
     return(GameUtil.ReplaceHotkeyString(UI.JOBSSCREEN.INCREASE_PRIORITY_TUTORIAL, Action.MouseLeft) + "\n" + GameUtil.ReplaceHotkeyString(UI.JOBSSCREEN.DECREASE_PRIORITY_TUTORIAL, Action.MouseRight));
 }
Esempio n. 30
0
 public LocString ThresholdValueUnits()
 {
     return(GameUtil.GetCurrentMassUnit(desiredState == Element.State.Gas));
 }