void Start()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            Debug.Log("gts instance");
            instance = this;
        }

        if (PlayerPrefs.GetInt("FirstTime", 0) == 0)
        {
            Debug.Log("gts first time");
            isFirstTime = true;
            PlayerPrefs.SetInt("FirstTime", 1);
            PlayerPrefs.SetFloat("CurrentXP", 0f);
            PlayerPrefs.SetInt("CurrentLevel", 1);
            PlayerPrefs.SetFloat("LevelXP", 50f);
            PlayerPrefs.SetInt("TotalCoinCount", 20);//20
            PlayerPrefs.SetInt("TotalCoinTimerCounter", 30);
        }
        else
        {
            print(PlayerPrefs.GetInt("FirstTime"));
            Debug.Log("gts not first time");
            isFirstTime = false;
            DateTime dateNow = DateTime.Now;
            timeSpan = dateNow - Convert.ToDateTime(PlayerPrefs.GetString("LastTime"));
        }
    }
Esempio n. 2
0
 public PlayerNetworkingControl(Player player, IPAddress roku_ip, int roku_port)
 {
     this.Depth      = player.Depth - 1;
     this.Player     = player;
     this.RokuIP     = roku_ip;
     this.RokuPort   = roku_port;
     this.SendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
     {
         SendTimeout = 100
     };
     this.ReceiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
     {
         ReceiveTimeout = 100
     };
     this.RemoteEndPoint = new IPEndPoint(this.RokuIP, this.RokuPort);
     try {
         this.SendSocket.Connect(this.RemoteEndPoint);
     } catch {}
     try {
         this.ReceiveSocket.Bind(new IPEndPoint(this.GetMyIP(), this.RokuPort));
     } catch {}
     this.SendDelayTimer = new GameTimeSpan();
     this.InitializeData();
     this.StartReceivingPackets();
     NeonPartyGamesControllerGame.FocusChangeEvent += this.onFocusChange;
 }
Esempio n. 3
0
        private void ParseServerSettingsFromXml(XmlElement rootElement)
        {
            foreach (XmlNode xmlNode in rootElement.ChildNodes)
            {
                if (!(xmlNode is XmlElement element))
                {
                    continue;
                }

                switch (element.Name)
                {
                case "Fame":
                    ParseFameElement(element);
                    break;

                case "ClusterChange":
                    ClusterChangeCooldown = GameTimeSpan.FromSeconds(XmlUtils.GetXmlAttributeFloat(element, "cooldownseconds", 10));
                    break;
                }
            }
        }
Esempio n. 4
0
            static void Postfix(PlantingBoxInfoUI __instance, bool isInit, ref TextMeshProUGUI ___progText, bool ___isEnable, bool ___riped, bool ___isBadSeason, GameTimeSpan ___timeToRipe)
            {
                if (!enabled)
                {
                    return;
                }
                if (!isInit)
                {
                    if (!__instance.enabled)
                    {
                        return;
                    }
                    if (!___isEnable)
                    {
                        return;
                    }
                }

                GameTimeSpan gts = new GameTimeSpan((long)Math.Round(___timeToRipe.Ticks / settings.plantGrowMult));

                if (!___riped && !___isBadSeason && gts.TotalDays <= 99.0)
                {
                    if (gts.TotalDays < 1)
                    {
                        ___progText.text = string.Format(TextMgr.GetStr(100373, -1), gts.Hours, gts.Minutes);
                    }
                    else if (gts.TotalDays < 2)
                    {
                        ___progText.text = string.Format($"{TextMgr.GetStr(100972, -1)} {TextMgr.GetStr(100373, -1)}", (int)gts.TotalDays, gts.Hours, gts.Minutes).Replace("(s)", "").Replace("(e)", "");
                    }
                    else
                    {
                        ___progText.text = string.Format($"{TextMgr.GetStr(100972, -1)} {TextMgr.GetStr(100373, -1)}", (int)gts.TotalDays, gts.Hours, gts.Minutes).Replace("(s)", "s").Replace("(e)", "e");
                    }
                }
            }
Esempio n. 5
0
            static void Postfix()
            {
                if (!Singleton <GameFlag> .Self.Gaming ||
                    UIStateMgr.Instance.currentState.type != UIStateMgr.StateType.Play ||
                    Player.Self.actor == null ||
                    (!KeyDown(settings.StopTimeKey) &&
                     !KeyDown(settings.SubtractTimeKey) &&
                     !KeyDown(settings.AdvanceTimeKey) &&
                     !KeyDown(settings.SlowTimeKey) &&
                     !KeyDown(settings.SpeedTimeKey))
                    )
                {
                    return;
                }

                if (KeyDown(settings.StopTimeKey))
                {
                    AccessTools.FieldRefAccess <TimeManager, BoolLogic>(TimeManager.Self, "timeStopLogic").Clear();
                    if (TimeManager.Self.TimeStoped)
                    {
                        TimeManager.Self.RemoveTimeStop(LockTime);
                        TimeManager.Self.EnableForStory = true;
                        Singleton <TipsMgr> .Instance.SendImageTip($"Time Started!", MessageUITipImageAssets.ImageType.CalendarRemind, 0);
                    }
                    else
                    {
                        TimeManager.Self.AddTimeStop(LockTime);
                        TimeManager.Self.EnableForStory = false;
                        Singleton <TipsMgr> .Instance.SendImageTip($"Time Stopped!", MessageUITipImageAssets.ImageType.CalendarRemind, 0);
                    }
                }
                else if (KeyDown(settings.SubtractTimeKey))
                {
                    GameDateTime dt = TimeManager.Self.DateTime.AddSeconds(-60 * 60);
                    GameTimeSpan t  = dt - TimeManager.Self.DateTime;
                    TimeManager.Self.SetDateTime(dt, true, TimeManager.JumpingType.Max);
                }
                else if (KeyDown(settings.AdvanceTimeKey))
                {
                    TimeManager.Self.JumpTimeByGameTime(60 * 60);
                }
                else if (KeyDown(settings.SlowTimeKey))
                {
                    if (settings.TimeScaleModifier > 0.1f)
                    {
                        if (Input.GetKey("left shift"))
                        {
                            settings.TimeScaleModifier = Math.Max(0.1f, (float)Math.Round(settings.TimeScaleModifier - 1f));
                        }
                        else
                        {
                            settings.TimeScaleModifier = (float)Math.Round(settings.TimeScaleModifier - 0.1f, 1);
                        }
                        Singleton <TipsMgr> .Instance.SendImageTip($"Time speed set to {TimeSpeedString()} speed", MessageUITipImageAssets.ImageType.CalendarRemind, 0);

                        settings.Save(myModEntry);
                    }
                    else
                    {
                        Singleton <TipsMgr> .Instance.SendSystemTip("Time already at slowest speed!", SystemTipType.warning);
                    }
                }
                else if (KeyDown(settings.SpeedTimeKey))
                {
                    if (settings.TimeScaleModifier < 10.0f)
                    {
                        if (Input.GetKey("left shift"))
                        {
                            settings.TimeScaleModifier = Math.Min(10f, (float)Math.Round(settings.TimeScaleModifier + 1f));
                        }
                        else
                        {
                            settings.TimeScaleModifier = (float)Math.Round(settings.TimeScaleModifier + 0.1f, 1);
                        }
                        Singleton <TipsMgr> .Instance.SendImageTip($"Time speed set to {TimeSpeedString()} speed", MessageUITipImageAssets.ImageType.CalendarRemind, 0);

                        settings.Save(myModEntry);
                    }
                    else
                    {
                        Singleton <TipsMgr> .Instance.SendSystemTip("Time already at fastest speed!", SystemTipType.warning);
                    }
                }
            }
Esempio n. 6
0
        private static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Run command:", new GUILayoutOption[0]);
            command = GUILayout.TextField(command, new GUILayoutOption[0]);
            if (GUILayout.Button("Run", new GUILayoutOption[0]))
            {
                typeof(CCC_Cmd).GetMethod(command, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(new CCC_Cmd(), new object[0]);
            }
            GUILayout.EndHorizontal();

            UnityEngine.Event e = UnityEngine.Event.current;


            string ts   = $"Pathea.FavorSystemNs.FavorManagerDebuger, {typeof(TransRoot).Assembly}";
            Type   type = Type.GetType(ts);

            type.GetMethod("OnGUI", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Activator.CreateInstance(type), new object[] { });


            if (GUILayout.Button("FavorDebugger", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                if (TransRoot.self.GetComponent(type) == null)
                {
                    TransRoot.self.gameObject.AddComponent(type);
                }
                else
                {
                    UnityEngine.Object.Destroy(TransRoot.self.GetComponent(type));
                }
            }

            if (GUILayout.Button("ScriptDebugger", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                if (TransRoot.self.GetComponent <CCScriptDebugger>() == null)
                {
                    TransRoot.self.gameObject.AddComponent <CCScriptDebugger>();
                }
                else
                {
                    UnityEngine.Object.Destroy(TransRoot.self.GetComponent <CCScriptDebugger>());
                }
            }

            if (GUILayout.Button("Starlight", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                Module <ScenarioModule> .Self.TransferToScenario("StarlightIsland");
            }
            if (GUILayout.Button("Teleport", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                Teleport();
            }
            if (GUILayout.Button("New Game+", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                NewGamePlus();
            }


            if (GUILayout.Button("Relationship++", new GUILayoutOption[]
            {
                GUILayout.Width(150f)
            }))
            {
                FavorObject[] fa = FavorManager.Self.GetAllFavorObjects();
                foreach (FavorObject f in fa)
                {
                    if (!f.IsDebut || f.RelationshipType == FavorRelationshipType.Couple)
                    {
                        FavorManager.Self.GainFavorValue(f.ID, -1, 100);
                    }
                }
            }

            if (GUILayout.Button("Time--", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                GameDateTime dt = TimeManager.Self.DateTime.AddSeconds(-60 * 60);
                GameTimeSpan t  = dt - TimeManager.Self.DateTime;
                TimeManager.Self.SetDateTime(dt, true, TimeManager.JumpingType.Max);
            }
            if (GUILayout.Button("Time++", new GUILayoutOption[] {
                GUILayout.Width(150f)
            }))
            {
                TimeManager.Self.JumpTimeByGameTime(60 * 60);
            }
        }
Esempio n. 7
0
        public override void onSwitchTo(Room previous_room, Dictionary <string, object> args)
        {
            Engine.SpawnInstance <LoadingSplash>();

            var    timer      = new GameTimeSpan();
            Action initialize = () => {
#if ADS
#if ANDROID
#if AMAZON
                Engine.SpawnInstance <AmazonUpgrade>();
#endif
#endif
#endif

#if XBOX_LIVE
                // Wait for Xbox Live login to complete if attempting
                const int xbox_live_timeout = 5000;
                while (XboxLiveObject.CurrentlyAttemptingSignIn && timer.TotalMilliseconds <= xbox_live_timeout)
                {
                    System.Threading.Thread.Sleep(10);
                }
#endif

                // Load all game data to initialize the SaveDataHandler cache
                Debug.WriteLine("########### Loading Save Files In To Cache ##########");
                foreach (GameRooms game_room in Enum.GetValues(typeof(GameRooms)))
                {
                    foreach (GameplaySpeeds gameplay_speed in Enum.GetValues(typeof(GameplaySpeeds)))
                    {
                        string data = SaveDataHandler.LoadData(Settings.GetSaveFilePath(game_room, gameplay_speed));
                        Debug.WriteLine(game_room + " - " + gameplay_speed + ": " + data);
                    }
                }
                Debug.WriteLine("########### Loading Save Files In To Cache ##########");

                // Wait until initial data loading occurs to spawn persistent stat tracker entity
                Engine.SpawnInstance <StatTracker>();

                // Preload in game assemblies
                for (int i = 0; i < this.AssembliesToPreload.Length; i++)
                {
                    try {
                        System.Reflection.Assembly.Load(this.AssembliesToPreload[i]);
                    } catch {
                        Debug.WriteLine("Unable to preload: " + this.AssembliesToPreload[i]);
                    }
                }

                // If time remains after doing these operations set the time to allow splash screen to remain
                int remaining_time_to_wait = RoomInit.MinimumSplashDuration - (int)timer.TotalMilliseconds;
                if (remaining_time_to_wait < 0)
                {
                    remaining_time_to_wait = 0;
                }

                // Setup switching to RoomMain after timeout
                Engine.SpawnInstance(new TimedExecution(remaining_time_to_wait, () => Engine.ChangeRoom <RoomMain>()));
            };

            Engine.SpawnInstance(new TimedExecution(500, initialize));
        }
        public static void Initialize()
        {
            string trackpad_position = SaveDataHandler.LoadData(SavePaths.TrackpadPosition)?.Trim();

            if (!string.IsNullOrEmpty(trackpad_position))
            {
                string[] data = trackpad_position.Split('|');
                if (data != null && data.Length == 2)
                {
                    var previous_position = new Vector2();
                    previous_position.X = float.Parse(data[0]);
                    previous_position.Y = float.Parse(data[1]);
                    _trackpad_position  = previous_position;
                }
            }

            string trackpad_scale = SaveDataHandler.LoadData(SavePaths.TrackpadScale)?.Trim();

            if (!string.IsNullOrEmpty(trackpad_scale))
            {
                _trackpad_scale = float.Parse(trackpad_scale);
            }

            string name = SaveDataHandler.LoadData(SavePaths.PlayerName)?.Trim();

            if (!string.IsNullOrEmpty(name))
            {
                _player_name = name;
            }

            string color = SaveDataHandler.LoadData(SavePaths.PlayerColor)?.Trim();

            if (!string.IsNullOrEmpty(color))
            {
                bool success = int.TryParse(color, out int color_int);
                if (success)
                {
                    _player_color = (Colors)color_int;
                }
            }

            string face = SaveDataHandler.LoadData(SavePaths.PlayerFace)?.Trim();

            if (!string.IsNullOrEmpty(face))
            {
                bool success = int.TryParse(face, out int face_int);
                if (success)
                {
                    _player_face = (Faces)face_int;
                }
            }

            string roku_ip = SaveDataHandler.LoadData(SavePaths.RokuIP)?.Trim();

            if (!string.IsNullOrEmpty(roku_ip))
            {
                bool success = IPAddress.TryParse(roku_ip, out IPAddress roku_ip_address);
                if (success)
                {
                    _roku_ip = roku_ip_address;
                }
            }

            string roku_name = SaveDataHandler.LoadData(SavePaths.RokuName)?.Trim();

            if (!string.IsNullOrEmpty(roku_name))
            {
                _roku_name = roku_name;
            }

            if (_roku_ip != null)
            {
                Task.Run(async() => {
                    const int max_retry_time  = 2500;
                    const int min_retry_delay = 100;
                    var timer  = new GameTimeSpan();
                    bool alive = false;
                    while (!alive && timer.TotalMilliseconds < max_retry_time)
                    {
                        alive = await RokuECP.PingRoku(roku_ip);
                        Thread.Sleep(min_retry_delay);
                    }
                    if (!alive && !Settings.HasRokuIPChangedSinceLaunch)
                    {
                        RokuIP   = null;
                        RokuName = "";
                    }
                });
            }
        }