Exemplo n.º 1
0
        private static void Init()
        {
            var player = map.Actors.Single(a => a is Player) as Player;

            var mapConsole     = new MapConsole(game, true, new AStarPathFinder());
            var logConsole     = new LogConsole();
            var messageConsole = new MessageConsole();
            var statusConsole  = new StatusConsole(player);
            var menuConsole    = new MenuConsole(Width, Height);

            var inventory = new InventoryConsole(player);

            var keyboardHandler = new KeyboardHandler(mapConsole, logConsole, messageConsole, player, inventory, menuConsole, game, () => StartGame(rnd));

            var mainConsole = new MainConsole(mapConsole, logConsole, messageConsole, statusConsole, keyboardHandler, inventory);

            mainConsole.Children.Add(mapConsole);
            mainConsole.Children.Add(logConsole);
            mainConsole.Children.Add(messageConsole);
            mainConsole.Children.Add(statusConsole);
            mainConsole.Children.Add(inventory);
            mainConsole.Children.Add(menuConsole);

            SadConsole.Game.Instance.Screen = mainConsole;
        }
Exemplo n.º 2
0
 public static bool VerifyCheckSumByjson(string masterKey, string json, string checkSum)
 {
     CheckSum.ValidateVerifyCheckSumInput(masterKey, checkSum);
     try
     {
         string str1 = Crypto.Decrypt(checkSum, masterKey);
         if (str1 == null || str1.Length < 4)
         {
             return(false);
         }
         string str2 = str1.Substring(str1.Length - 4, 4);
         MessageConsole.WriteLine("Salt:::: " + str2);
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("Input CheckSum:::: " + checkSum);
         string str3 = json;
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("GeneratedCheckSum String:::: " + str3);
         string inputValue = str3 + "|" + str2;
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("GeneratedCheckSum String with Salt:::: " + inputValue);
         string hashedString = SecurityUtils.GetHashedString(inputValue);
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("HashedGeneratedCheckSum String:::: " + hashedString);
         string str4 = hashedString + str2;
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("HashedGeneratedCheckSum String with Salt:::: " + str4);
         return(str4.Equals(str1));
     }
     catch (System.Exception ex)
     {
         throw new CryptoException("Exception occurred while verifying CheckSum. " + ex.Message);
     }
 }
Exemplo n.º 3
0
        public static string CreateCheckSumString(Dictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                return("");
            }
            MessageConsole.WriteLine();
            MessageConsole.WriteLine("Input Dict::::");
            SecurityUtils.PrintDictionary(parameters);
            SortedDictionary <string, string> dict = new SortedDictionary <string, string>((IDictionary <string, string>)parameters, (IComparer <string>)StringComparer.Ordinal);

            MessageConsole.WriteLine();
            MessageConsole.WriteLine("Sorted Dict::::");
            SecurityUtils.PrintSortedDictionary(dict);
            StringBuilder stringBuilder = new StringBuilder("");

            foreach (KeyValuePair <string, string> keyValuePair in dict)
            {
                string str = keyValuePair.Value;
                if (str == null || str.Trim().Equals("NULL"))
                {
                    str = "";
                }
                stringBuilder.Append(str).Append("|");
            }
            return(stringBuilder.ToString());
        }
Exemplo n.º 4
0
        public Screen(int width, int height)
        {
            MainConsole    = new MainConsole(width - MENU_WIDTH - 1, height - MESSAGES_HEIGHT);
            MessageConsole = new MessageConsole(1, height - MESSAGES_HEIGHT + 1, width, MESSAGES_HEIGHT);
            MenuConsole    = new MenuConsole(width - MENU_WIDTH, 1, MENU_WIDTH + 1, height - MESSAGES_HEIGHT + 1);

            StartScreen = new StartScreen(width + 2, height + 2);
        }
Exemplo n.º 5
0
        // private FightSceneLogic _scene;

        protected override void Awake()
        {
            base.Awake();
            _console = GetSceneLogic <FightSceneLogic>().Console;
            _player  = GetComponent <Player>();
            // _scene = GetSceneLogic<FightSceneLogic>();
            Debug.Assert(_console != null);
            Debug.Assert(_player != null);
        }
 public Message()
 {
     messageConsole = //new MessageConsole(LogMessage);
         //anonymous method syntax
         delegate(string message)
         {
             Console.WriteLine("{0}---->{1}", DateTime.Now, message);
         };
      messageConsole += Console.WriteLine;
 }
Exemplo n.º 7
0
 private static void PrintSortedDictionary(SortedDictionary <string, string> dict)
 {
     if (dict == null)
     {
         return;
     }
     foreach (KeyValuePair <string, string> keyValuePair in dict)
     {
         MessageConsole.WriteLine("{0}, {1}", (object)keyValuePair.Key, (object)keyValuePair.Value);
     }
 }
Exemplo n.º 8
0
 public KeyboardHandler(MapConsole mapConsole, LogConsole logConsole, MessageConsole messageConsole, Player player, InventoryConsole inventory, MenuConsole menuConsole, Game game, Action startGame)
 {
     this.mapConsole     = mapConsole;
     this.logConsole     = logConsole;
     this.messageConsole = messageConsole;
     this.player         = player;
     this.inventory      = inventory;
     this.menuConsole    = menuConsole;
     this.game           = game;
     this.startGame      = startGame;
     state = InputState.Idle;
     mapConsole.IsFocused = true;
     actions = new List <Action>();
 }
Exemplo n.º 9
0
        //private void btnDeleteFeature_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        //{
        //    if (isDelete)
        //    {
        //        isDelete = false;
        //        this.btnDeleteFeature.Down = false;
        //        this.btnDrawLine.Enabled = true;
        //        this.btnDrawPoint.Enabled = true;
        //        this.btnDrawRegion.Enabled = true;
        //    }
        //    else
        //    {
        //        isDelete = true;
        //        this.btnDeleteFeature.Down = true;
        //        this.btnDeleteFeature.ButtonStyle = DevExpress.XtraBars.BarButtonStyle.Check;
        //        this.btnDrawLine.Enabled = false;
        //        this.btnDrawPoint.Enabled = false;
        //        this.btnDrawRegion.Enabled = false;
        //    }
        //}

        public void OutputLog(string msg)
        {
            if (this.IsHandleCreated)
            {
                this.tbMsg.Invoke((MethodInvoker) delegate()
                {
                    lock (this.tbMsg)
                    {
                        DateTime dtime = DateTime.Now;
                        msg            = string.Format("[{0}] {1}\r\n", dtime, msg);
                        this.tbMsg.AppendText(msg);
                        MessageConsole.Write(msg);
                    }
                });
            }
        }
Exemplo n.º 10
0
 public static string GenerateCheckSumForRefund(string masterKey, Dictionary <string, string> parameters)
 {
     CheckSum.ValidateGenerateCheckSumInput(masterKey);
     try
     {
         string checkSumString = SecurityUtils.CreateCheckSumString(parameters);
         string randomString   = StringUtils.GenerateRandomString(4);
         string inputValue     = checkSumString + randomString;
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("Final CheckSum String:::: " + inputValue);
         string hashedString = SecurityUtils.GetHashedString(inputValue);
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("HashedCheckSum String:::: " + hashedString);
         string clearText = hashedString + randomString;
         MessageConsole.WriteLine();
         MessageConsole.WriteLine("HashedCheckSum String with Salt:::: " + clearText);
         return(Crypto.Encrypt(clearText, masterKey));
     }
     catch (System.Exception ex)
     {
         throw new CryptoException("Exception occurred while generating CheckSum. " + ex.Message);
     }
 }
Exemplo n.º 11
0
        public static string GenerateCheckSum(string masterKey, Dictionary <string, string> parameters)
        {
            CheckSum.ValidateGenerateCheckSumInput(masterKey);
            Dictionary <string, string> parameters1 = new Dictionary <string, string>();

            try
            {
                foreach (string key in parameters.Keys)
                {
                    if (parameters[key].Trim().ToUpper().Contains("REFUND") || parameters[key].Trim().Contains("|"))
                    {
                        parameters1.Add(key.Trim(), "");
                    }
                    else
                    {
                        parameters1.Add(key.Trim(), parameters[key].Trim());
                    }
                }
                string checkSumString = SecurityUtils.CreateCheckSumString(parameters1);
                string randomString   = StringUtils.GenerateRandomString(4);
                string inputValue     = checkSumString + randomString;
                MessageConsole.WriteLine();
                MessageConsole.WriteLine("Final CheckSum String:::: " + inputValue);
                string hashedString = SecurityUtils.GetHashedString(inputValue);
                MessageConsole.WriteLine();
                MessageConsole.WriteLine("HashedCheckSum String:::: " + hashedString);
                string clearText = hashedString + randomString;
                MessageConsole.WriteLine();
                MessageConsole.WriteLine("HashedCheckSum String with Salt:::: " + clearText);
                return(Crypto.Encrypt(clearText, masterKey));
            }
            catch (System.Exception ex)
            {
                throw new CryptoException("Exception occurred while generating CheckSum. " + ex.Message);
            }
        }
Exemplo n.º 12
0
        public override string ToConsole()
        {
            string returnStr = MessageConsole.PadLeft(0).PadRight(0);

            return(returnStr);
        }