Пример #1
0
 private void PopQueueEntrance(Decipher decipher)
 {
     Interaction.TurnOffAllInteractionWindow();
     ControllerManager.SyncActions = false;
     PopUpNotification.Push("Your queue is ready, do you want to join?", PopUpNotification.Type.Select);
     StartCoroutine(PopUpNotification.WaitForDecisionThenPerformAction(AcceptEntrance, DenyEntrance));
 }
Пример #2
0
        public void Decipher(string content, string keyPath, string filePath)
        {
            string   key      = File.ReadAllText(keyPath, _defaultEncoding);
            Decipher decipher = new Decipher(content, key);

            File.WriteAllText(filePath, decipher.CryptStr, _defaultEncoding);
        }
Пример #3
0
        private void UnEquipAction(Decipher decipher)
        {
            UnEquipActionData temp = JsonUtility.FromJson <UnEquipActionData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                CacheManager.Players[temp.ClientID].PC.UnEquip((EQUIPTYPE)temp.Slot);
            }
        }
Пример #4
0
        //Flag
        private void EquipAction(Decipher decipher)
        {
            EquipActionData temp = JsonUtility.FromJson <EquipActionData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                CacheManager.Players[temp.ClientID].PC.Equip(temp.E);
            }
        }
Пример #5
0
        private void DisconnectByServer(Decipher decipher)
        {
            byte error;

            NetworkTransport.Disconnect(decipher.tail, ClientID, out error);
            if (decipher.content != string.Empty)
            {
                PopUpNotification.Push(decipher.content, PopUpNotification.Type.Confirm);
            }
        }
Пример #6
0
        void Process()
        {
            //int HostID = 0;
            //int ClientID;
            //int rec_hostID = 0;
            int rec_connectionID;
            int rec_channelID;

            byte[] buffer = new byte[1024];
            int    buffer_length;
            byte   error;

            NetworkEventType networkEvent = NetworkEventType.DataEvent;

            do
            {
                networkEvent = NetworkTransport.ReceiveFromHost(HostID, out rec_connectionID, out rec_channelID, buffer, 1024, out buffer_length, out error);
                switch (networkEvent)
                {
                case NetworkEventType.ConnectEvent:    // Server received connect event
                    Connected = true;
                    Debug.Log("Connected.");
                    break;

                case NetworkEventType.DataEvent: // Server received data
                    try {                        //Try catch is super expensive, a data server will replace it later
                        Decipher d = Serializer.UnSeal(HostID, buffer);
                        SendMessage(d.protocol, d);
                    } catch {
                        AppendBuffer(buffer, buffer_length);
                    }
                    break;

                case NetworkEventType.DisconnectEvent: // Client received disconnect event
                    Connected = false;
                    if (error == 6)                    //Server down
                    {
                        StartCoroutine(Scene.LoadThenExecute(ID.StartMenu, PopUpNotification.Push, "Disconnected from server.", PopUpNotification.Type.Confirm));
                    }
                    Debug.Log("Disconnected.");
                    ClientID = -1;
                    break;

                case NetworkEventType.BroadcastEvent:    //This block should be removed for network version
                    if (Connected || ip != String.Empty)
                    {
                        return;
                    }
                    NetworkTransport.GetBroadcastConnectionMessage(HostID, buffer, 1024, out buffer_length, out error);
                    ip = Serializer.DeSerialize <string>(buffer);
                    RootButtons.cg.interactable = true;
                    break;
                }
            } while (networkEvent != NetworkEventType.Nothing);
        }
Пример #7
0
        public static void Main(string[] args)
        {
            var jsonData   = LoadEmbeddedResource("example.json");
            var testKey    = LoadEmbeddedResource("test-pkey.pub");
            var testKeySec = LoadEmbeddedResource("test-pkey.sec");

            Console.WriteLine($"Input: \n{jsonData}");
            Console.WriteLine("\n\n");
            var cipher = new Cipher(new List <string> {
                testKey
            });
            var skipFields = new List <string> {
                Tools.CipherPathCombine("data", "User_viewer", "me", "avatar"),
            };

            Console.WriteLine(skipFields[0]);
            var data = cipher.GenerateEncryptedPacket(JObject.Parse(jsonData), skipFields);

            Console.WriteLine($"Key: {data.EncryptedKey}");
            Console.WriteLine(data.EncryptedJSON);
            Console.WriteLine("--------------------------------------------------------------------------");

            var decipher = new Decipher(testKeySec);

            if (!decipher.Unlock("1234567890"))
            {
                Console.WriteLine("Error decrypting key!");
                return;
            }

            var dec = decipher.DecipherPacket(data);

            Console.WriteLine($"JSON Changed: {dec.JSONChanged}");
            Console.WriteLine("Changes: ");
            dec.UnmatchedFields.ForEach((c) => Console.WriteLine($"\t{c.Expected} => {c.Got}"));
            Console.WriteLine(dec.DecryptedData);
            Console.WriteLine("--------------------------------------------------------------------------");


            data.EncryptedJSON["data"]["User_viewer"]["me"]["baseName"] = data.EncryptedJSON["data"]["User_viewer"]["me"]["id"];
            var a = data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][0];
            var b = data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][1];

            data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][0] = b;
            data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][1] = a;

            dec = decipher.DecipherPacket(data);
            Console.WriteLine($"JSON Changed: {dec.JSONChanged}");
            Console.WriteLine("Changes: ");
            dec.UnmatchedFields.ForEach((c) => Console.WriteLine($"\t{c.Expected} => {c.Got}"));
            Console.WriteLine(dec.DecryptedData);
        }
Пример #8
0
        private void UpdatePlayerAttackVector(Decipher decipher)
        {
            AttackData temp = JsonUtility.FromJson <AttackData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                CacheManager.Players[temp.ClientID].PC.AttackVector = temp.AttackVector;
                if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP)
                {
                    CacheManager.MP.ExpectingAttackVector = false;
                }
            }
        }
Пример #9
0
        private void UpdatePlayerDirection(Decipher decipher)
        {
            DirectionData temp = JsonUtility.FromJson <DirectionData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                CacheManager.Players[temp.ClientID].PC.Direction = temp.Direction;
                if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP)
                {
                    CacheManager.MP.ExpectingDirection = false;
                }
            }
        }
Пример #10
0
        private void UpdatePlayerMoveVector(Decipher decipher)
        {
            MovementData temp = JsonUtility.FromJson <MovementData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                CacheManager.Players[temp.ClientID].PC.MoveVector = temp.MoveVector;
                if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP)
                {
                    CacheManager.MP.ExpectingMoveVector = false;
                }
            }
        }
Пример #11
0
        private void UpdatePlayerPosition(Decipher decipher)
        {
            PositionData temp = JsonUtility.FromJson <PositionData>(decipher.content);

            if (CacheManager.Players[temp.ClientID].PC)
            {
                //CacheManager.Players[temp.ClientID].PC.Lerps.Add(temp.Position);
                //CacheManager.Players[temp.ClientID].PC.Position = temp.Position;
                if (Mathf.Abs(Vector2.Distance(temp.Position, CacheManager.Players[temp.ClientID].PC.Position)) > 0.1f)
                {
                    //CacheManager.Players[temp.ClientID].PC.Position = Vector2.Lerp(CacheManager.Players[temp.ClientID].PC.Position, temp.Position, 1f);
                    CacheManager.Players[temp.ClientID].PC.Position = temp.Position;
                }
            }
        }
Пример #12
0
        static void Main(string[] args)
        {
            string backslash    = @"\";
            var    EditFileName = @"names-result.txt";
            string value        = Console.ReadLine();

            string[] array = new string[] {};

            array = value.Split(' ');
            var FilePath = (array[0]);

            //This is necessary if the user doesn't do a space after dragging a file in command prompt
            //Otherwise it causes an index out of exception
            if (array.Length == 1)
            {
                Array.Resize(ref array, array.Length + 1);
                array[1] = "";
            }

            var EditedFile = (array[1]);

            //If the user does a space and its empty, or if whats right above happens.
            //This would grab the directory that the file is being used to change
            //the homoglyphs to normal characters.
            if (array[1] == "")
            {
                EditedFile = "" + Path.GetDirectoryName(FilePath);
            }
            //This is necessary if you decide to have the edited file be created in C:\
            //Otherwise when placed in a folder there isn't a backslash.
            if (!EditedFile.EndsWith(backslash))
            {
                EditedFile += @"\";
            }

            using (var fixedFile = new StreamWriter($"{EditedFile}" + $"{EditFileName}"))
            {
                List <string> records           = File.ReadAllLines($"{FilePath}", Encoding.GetEncoding(1252)).ToList();
                Decipher      name              = new Decipher();
                string        correctFormatName = "";

                foreach (string NextLine in records)
                {
                    correctFormatName = name.ConvertString(NextLine);
                    fixedFile.WriteLine(correctFormatName);
                }
            }
        }
Пример #13
0
 //Client Protocols
 private void Identify(Decipher decipher)  //Any instance based action required Identify self first, and this will be done by server once login
 {
     ClientID = int.Parse(decipher.content);
 }
Пример #14
0
 private void CreateUsername(Decipher decipher)
 {
     DataManager.CreateUsernameProfile(decipher.content);
     PopUpNotification.Push("Successfully registered.", PopUpNotification.Type.Confirm);
 }
Пример #15
0
        private void TopNotify(Decipher decipher)
        {
            TopNotifyData temp = JsonUtility.FromJson <TopNotifyData>(decipher.content);

            TopNotification.Push(temp.message, temp.color, temp.period);
        }
Пример #16
0
 private void PopUpNotify(Decipher decipher)
 {
     PopUpNotification.Push(decipher.content, PopUpNotification.Type.Confirm);
 }
Пример #17
0
 private void Test(Decipher decipher)
 {
     Debug.Log("Got IP");
 }
Пример #18
0
 private void SyncLoadedScene(Decipher decipher)
 {
     Scene.ActiveScene(1f, CacheManager.InstantiatePlayers);
 }
Пример #19
0
 private void LoadSceneWithSync(Decipher decipher)
 {
     Scene.LoadWithManualActive(JsonUtility.FromJson <ID>(decipher.content));
 }
Пример #20
0
 private void LoadVillage(Decipher decipher)
 {
     CacheManager.CachePlayerData(ClientID, DataManager.UserData.PlayerDatas[CacheManager.CachedPlayerSlotIndex], ObjectIdentity.Main);//Cache Main Player Data
     Scene.LoadWithAction(ID.Village, CacheManager.InstantiatePlayers);
 }
Пример #21
0
 private void ListeningForPacakage(Decipher decipher)
 {
     Package = JsonUtility.FromJson <Package>(decipher.content);
     Package.Initialize();
 }
Пример #22
0
 public Cipher(Factory factory)
 {
     encrypt  = factory.createEncrypt();
     decipher = factory.createDecipher();
 }
Пример #23
0
 public Cipher(Factory factory, int i)
 {
     encrypt  = factory.createEncrypt(i);
     decipher = factory.createDecipher(i);
 }
Пример #24
0
 private void UpdateLoadingText(Decipher decipher)
 {
     LoadingUI.LoadingText = decipher.content;
 }