Пример #1
0
        public void SetHudActive(Character c, bool active)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                data.gui.SetActive(active && VHVRConfig.ShowEnemyHuds());
            }
        }
Пример #2
0
        public void UpdateAware(Character c, bool aware)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                data.aware.gameObject.SetActive(aware);
            }
        }
Пример #3
0
        public void UpdateAlerted(Character c, bool alerted)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                data.alerted.gameObject.SetActive(alerted);
            }
        }
Пример #4
0
        public void RemoveEnemyHud(Character c)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                _enemyHuds.Remove(c);
            }
        }
Пример #5
0
        public void DestroyHudGui(Character c)
        {
            HudData data = getEnemyHud(c);

            if (data != null && data.gui != null)
            {
                Object.Destroy(data.gui);
                Object.Destroy(data.hudCanvasRoot);
            }
        }
Пример #6
0
        public void UpdateHealth(Character c, float health)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                data.healthSlow.SetValue(health);
                data.healthFast.SetValue(health);
            }
        }
Пример #7
0
        private HudData createHudDataForCharacter(Character c, GameObject baseHudPlayer,
                                                  GameObject baseHudEnemy, GameObject baseHudBoss)
        {
            if (baseHudPlayer == null)
            {
                LogError("baseHudPlayer is null.");
                return(null);
            }
            if (baseHudEnemy == null)
            {
                LogError("baseHudEnemy is null.");
                return(null);
            }
            if (baseHudBoss == null)
            {
                LogError("baseHudBoss is null.");
                return(null);
            }
            GameObject baseHud;

            if (c.IsPlayer())
            {
                baseHud = baseHudPlayer;
            }
            else if (c.IsBoss())
            {
                baseHud = baseHudBoss;
            }
            else
            {
                baseHud = baseHudEnemy;
            }
            GameObject canvasRoot = createEnemyHudCanvas();
            Canvas     canvas     = canvasRoot.GetComponent <Canvas>();
            HudData    data       = new HudData()
            {
                character = c,
                gui       = Object.Instantiate(baseHud, canvas.transform)
            };

            updateGuiLayers(data.gui.transform);
            data.gui.SetActive(true);
            data.hudCanvasRoot = canvasRoot;
            data.healthRoot    = data.gui.transform.Find("Health").gameObject;
            data.healthFast    = data.healthRoot.transform.Find("health_fast").GetComponent <GuiBar>();
            data.healthSlow    = data.healthRoot.transform.Find("health_slow").GetComponent <GuiBar>();
            data.level2        = data.gui.transform.Find("level_2") as RectTransform;
            data.level3        = data.gui.transform.Find("level_3") as RectTransform;
            data.alerted       = data.gui.transform.Find("Alerted") as RectTransform;
            data.aware         = data.gui.transform.Find("Aware") as RectTransform;
            data.name          = data.gui.transform.Find("Name").GetComponent <Text>();
            data.name.text     = Localization.instance.Localize(c.GetHoverName());
            data.gui.transform.localPosition = data.hudCanvasRoot.GetComponent <Canvas>().GetComponent <RectTransform>().rect.center;
            return(data);
        }
Пример #8
0
    public void Save()
    {
        HudData hudData = new HudData();

        hudData.maxHP     = maxHP;
        hudData.maxEnergy = maxEnergy;
        hudData.curHP     = curHP;
        hudData.curEnergy = curEnergy;
        hudData.money     = money;
        File.WriteAllText(Application.persistentDataPath + "/hudData.json", JsonMapper.ToJson(hudData).ToString());
    }
Пример #9
0
        public void UpdateLevel(Character c, int level)
        {
            HudData data = getEnemyHud(c);

            if (data != null)
            {
                if (data.level2)
                {
                    bool isLevel2 = level == 2;
                    data.level2.gameObject.SetActive(isLevel2);
                }
                if (data.level3)
                {
                    bool isLevel3 = level == 3;
                    data.level3.gameObject.SetActive(isLevel3);
                }
            }
        }
Пример #10
0
 public void AddEnemyHud(Character c, GameObject baseHudPlayer, GameObject baseHudEnemy, GameObject baseHudBoss)
 {
     if (c != null && c)
     {
         if (c.IsBoss())
         {
             // Boss is displayed on main GUI instead of world space.
             return;
         }
         HudData existingData;
         if (_enemyHuds.TryGetValue(c, out existingData))
         {
             return;
         }
         HudData newData = createHudDataForCharacter(c, baseHudPlayer, baseHudEnemy, baseHudBoss);
         if (newData != null)
         {
             _enemyHuds.Add(c, newData);
         }
     }
 }
Пример #11
0
        public void UpdateHudCoordinates(Character c)
        {
            if (!ensureHudCamera())
            {
                return;
            }
            HudData data = getEnemyHud(c);

            if (data == null || data.gui == null || !data.gui.activeSelf)
            {
                return;
            }
            if (data != null)
            {
                data.hudCanvasRoot.transform.position = c.IsPlayer() ? c.GetHeadPoint() : c.GetTopPoint();
                data.hudCanvasRoot.transform.LookAt(_hudCamera.transform);
                data.hudCanvasRoot.transform.rotation *= Quaternion.Euler(0f, 180f, 0f);
                float scale    = 0.06f / data.hudCanvasRoot.GetComponent <Canvas>().GetComponent <RectTransform>().rect.width;
                float distance = Vector3.Distance(_hudCamera.transform.position, data.gui.transform.position);
                data.hudCanvasRoot.GetComponent <Canvas>().GetComponent <RectTransform>().localScale =
                    Vector3.one * scale * distance * VHVRConfig.EnemyHudScale();
            }
        }
Пример #12
0
        private void incomingHudData(HudData huddata)
        {
            PlayerInfo player = null;
            player = Array.Find(PlayerStore.Instance.playerlist, x => x.Name == huddata.player_name);

            switch (huddata.action)
            {
                case "EXP":
                    player.Exp += huddata.value;
                    break;
                case "HP":
                    player.HP += huddata.value;
                    break;
                default:
                    break;
            }
        }
        public static void GetHoverText_light(ref Fermenter __instance, ref string __result)
        {
            if (__result.IsNullOrWhiteSpace())
            {
                return;
            }

            ZNetView m_nview = (ZNetView)AccessTools.Field(typeof(Fermenter), "m_nview").GetValue(__instance);

            if (!m_nview.GetZDO().GetString("Content", "").IsNullOrWhiteSpace())
            {
                DateTime d = new DateTime(m_nview.GetZDO().GetLong("StartTime", 0L));
                if (d.Ticks != 0L)
                {
                    double time = (ZNet.instance.GetTime() - d).TotalSeconds;
                    if (!time.Equals(-1) && time < (double)__instance.m_fermentationDuration)
                    {
                        if ((bool)AccessTools.Field(typeof(Fermenter), "m_exposed").GetValue(__instance))
                        {
                            if (hudData != null)
                            {
                                hudData.m_gui.SetActive(false);
                            }
                            return;
                        }

                        float percentage = (float)(time / (double)__instance.m_fermentationDuration * 100);
                        int   perc       = (int)percentage;

                        if (hudData == null && !ProgressBar.OFF.Equals(progressBar.Value))
                        {
                            hudData = new HudData();

                            hudData.m_gui = UnityEngine.Object.Instantiate <GameObject>(EnemyHud.instance.m_baseHud, EnemyHud.instance.m_hudRoot.transform);
                            hudData.m_gui.SetActive(true);
                            hudData.m_gui.transform.SetPositionAndRotation(Hud.instance.m_crosshair.transform.position, new Quaternion());
                            hudData.m_healthRoot = hudData.m_gui.transform.Find("Health").gameObject;
                            hudData.m_healthFast = hudData.m_healthRoot.transform.Find("health_fast").GetComponent <GuiBar>();
                            hudData.m_healthSlow = hudData.m_healthRoot.transform.Find("health_slow").GetComponent <GuiBar>();
                            hudData.m_name       = hudData.m_gui.transform.Find("Name").GetComponent <Text>();
                            hudData.m_name.text  = "";
                            hudData.m_level2     = hudData.m_gui.transform.Find("level_2") as RectTransform;
                            hudData.m_level2.gameObject.SetActive(false);
                            hudData.m_level3 = hudData.m_gui.transform.Find("level_3") as RectTransform;
                            hudData.m_level3.gameObject.SetActive(false);
                            hudData.m_alerted = hudData.m_gui.transform.Find("Alerted") as RectTransform;
                            hudData.m_alerted.gameObject.SetActive(false);
                            hudData.m_aware = hudData.m_gui.transform.Find("Aware") as RectTransform;
                            hudData.m_aware.gameObject.SetActive(false);
                        }

                        if (hudData != null)
                        {
                            hudData.m_gui.transform.SetPositionAndRotation(Hud.instance.m_crosshair.transform.position, new Quaternion());
                            hudData.m_gui.SetActive(true);
                            if (ProgressBar.YELLOW.Equals(progressBar.Value))
                            {
                                hudData.m_healthSlow.SetValue(percentage);
                                hudData.m_healthSlow.SetMaxValue(100);
                                hudData.m_healthFast.SetValue(0);
                            }
                            else
                            {
                                hudData.m_healthFast.SetValue(percentage);
                                hudData.m_healthFast.SetMaxValue(100);
                                hudData.m_healthSlow.SetValue(0);
                            }
                        }

                        if (color.Value)
                        {
                            string colorHex = $"#{(255 / 100 * (100 - perc)):X2}{(255 / 100 * perc):X2}{0:X2}";

                            if (ProgressText.PERCENT.Equals(progressText.Value))
                            {
                                __result = __result.Replace(")", $"<color={colorHex}>{perc}%</color> )");
                            }
                            else if (ProgressText.TIME.Equals(progressText.Value))
                            {
                                double left = (double)__instance.m_fermentationDuration * percentage;
                                int    min  = (int)Math.Floor(left / 60);
                                int    sec  = ((int)left) % 60;

                                __result = __result.Replace(")", $"<color={colorHex}>{min}m {sec}s</color> )");
                            }
                            return;
                        }
                        else
                        {
                            if (ProgressText.PERCENT.Equals(progressText.Value))
                            {
                                __result = __result.Replace(")", $"{perc}% )");
                            }
                            else if (ProgressText.TIME.Equals(progressText.Value))
                            {
                                double left = ((double)__instance.m_fermentationDuration) - time;
                                int    min  = (int)Math.Floor(left / 60);
                                int    sec  = ((int)left) % 60;

                                __result = __result.Replace(")", $"{min}m {sec}s )");
                            }
                            return;
                        }
                    }
                }
            }
            if (hudData != null)
            {
                hudData.m_gui.SetActive(false);
            }
        }