Example #1
0
 public void LoginIntoAccount()
 {
     if (SingleTon.GetAccessAPI().LoginIntoProfile(_Model.Username, _View.PBPassword.Password).Result)
     {
         MainWindow.WVM.ChangeView(Pages.MainScreen);
     }
 }
Example #2
0
        public void run()
        {
            SingleTon     singleTon  = SingleTon.GetInstance;
            List <string> stringList = singleTon.getThreadStringList();

            for (int i = 0; i < 10; i++)
            {
                ObjectData objectData = new ObjectData()
                {
                    StringList = stringList,
                    Counter    = i
                };
                new WorkerThread(true, this, objectData);
            }
            while (true)
            {
                if (stringList.Count == 10)
                {
                    break;
                }
                else
                {
                    Console.WriteLine(stringList.Count);
                }
            }
            foreach (string s in stringList)
            {
                Console.WriteLine(s);
            }
            Console.WriteLine("End of therad Process.");
        }
 private void DrawRooms() //limit map to 50*50 and move the "camera" around the map
 {
     for (int i = XDrawingStart; i < XDrawingEnd; i++)
     {
         Console.Write("        ");
         for (int x = YDrawingStart; x < YDrawingEnd; x++)
         {
             if ((SingleTon.GetCursor().GetCords()[0] == i && SingleTon.GetCursor().GetCords()[1] == x))
             {
                 Console.ForegroundColor = ConsoleColor.Blue;
                 Console.Write("O");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             else if (SingleTon.GetRooms()[i, x] == null)
             {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.Write("#");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Green;
                 Console.Write("@");
                 Console.ForegroundColor = ConsoleColor.White;
             }
             Console.Write("   ");
         }
         Console.WriteLine("\n");
     }
 }
        public async Task OnPostSavePicture()
        {
            if (Upload != null)
            {
                List <Links> linksSperated = new List <Links>();
                if (Name != null)
                {
                    if (links == "")
                    {
                        string[] SplitLinks = links.Split(',');
                        foreach (string element in SplitLinks)
                        {
                            string[] temp = element.Split(' ');
                            linksSperated.Add(new Links {
                                link = temp[1], name = temp[0]
                            });
                        }
                    }
                    try
                    {
                        await SingleTon.GetSQLConnector().AddNewItemToContainerAsync(new Entities.Project()
                        {
                            Name = this.Name, SmallDescriptiom = this.smallDescription, Description = this.Description, ImagePath = await BlobAccess.UploadImage(Upload.OpenReadStream(), Upload.FileName), TrelloLink = this.TrelloLink, GithubLink = this.Github, OtherLinks = linksSperated.ToArray(), Id = Name + Guid.NewGuid().ToString()
                        });
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                //testTextURI = await BlobAccess.UploadImage(Upload.OpenReadStream(), Upload.FileName);
            }
        }
Example #5
0
        public ActionResult <User> GetAuthToken(string username, string password)
        {
            User LoginData = new User()
            {
                username = username, password = password
            };
            List <User> Users = SingleTon.GetSQLAccessor().GetUser();

            foreach (User element in Users)
            {
                if (element.username == LoginData.username)
                {
                    User CurrentUser = element;
                    if (SingleTon.GetCryptoHashing().VerifyHash(LoginData.password, element.password))
                    {
                        Claim[] claims           = new[] { new Claim(JwtRegisteredClaimNames.Sub, element.userID) };
                        SymmetricSecurityKey key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SingleTon.readSetting("secret")));
                        string             Algo  = SecurityAlgorithms.HmacSha256;
                        SigningCredentials signingCredentials = new SigningCredentials(key, Algo);

                        JwtSecurityToken token = new JwtSecurityToken(SingleTon.readSetting("issuer"), SingleTon.readSetting("audiance"), claims, notBefore: DateTime.Now, expires: DateTime.Now.AddDays(1), signingCredentials);
                        CurrentUser.password = "";
                        CurrentUser.token    = new JwtSecurityTokenHandler().WriteToken(token);
                        return(Ok(CurrentUser));
                    }
                }
            }
            return(BadRequest());
        }
Example #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string temp = SingleTon.readSetting("secret");
            SymmetricSecurityKey key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(temp));

            services.AddAuthentication("OAuth").AddJwtBearer("OAuth", config =>
            {
                config.TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidIssuer      = SingleTon.readSetting("issuer"),
                    ValidAudience    = SingleTon.readSetting("audience"),
                    IssuerSigningKey = key,
                };
            });

            services.AddControllers();

            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder
                                  .AllowAnyMethod()
                                  .AllowAnyOrigin()
                                  .AllowAnyHeader());
            });
        }
Example #7
0
 public void ApplyBonus()
 {
     SingleTon.GetPlayerController().Skills.Power.AddPoint(PowBonus);
     SingleTon.GetPlayerController().Skills.Vitallity.AddPoint(VitBonus);
     SingleTon.GetPlayerController().Skills.Magic.AddPoint(MagBonus);
     SingleTon.GetPlayerController().Skills.Luck.AddPoint(LuckBonus);
 }
Example #8
0
        private string CalculateLevelProgress()
        {
            string ProgressionString = "";
            float  Percentage;

            try
            {
                Percentage = ((float)SingleTon.GetPlayerController().Xp / (float)SingleTon.GetPlayerController().NextLevelXP) * 100f;
            }
            catch
            {
                Percentage = 0;
            }

            for (int i = 0; i < ((int)Percentage / 5); i++)
            {
                ProgressionString += "=";
            }
            int lenght = ProgressionString.Length;

            for (int x = 0; x < 20 - lenght; x++)
            {
                ProgressionString += "-";
            }

            return(ProgressionString);
        }
Example #9
0
        public override void UnEquip()
        {
            switch (ArmorLocation)
            {
            case ArmorLocation.Chest:
                SingleTon.GetPlayerController().Inventory.ChestArmor = null;
                break;

            case ArmorLocation.Feet:
                SingleTon.GetPlayerController().Inventory.ShoesArmor = null;
                break;

            case ArmorLocation.Offhand:
                SingleTon.GetPlayerController().Inventory.OffHand = null;
                break;

            case ArmorLocation.Legs:
                SingleTon.GetPlayerController().Inventory.PantsArmor = null;
                break;

            case ArmorLocation.Head:
                SingleTon.GetPlayerController().Inventory.HeadArmor = null;
                break;
            }
            SingleTon.GetPlayerController().Armor -= AC;
        }
        public void WhenGetInstance_ShouldReturnNotNullInstance()
        {
            //act
            SingleTon sut = SingleTon.Instance;

            //assert
            Assert.NotNull(sut);
        }
Example #11
0
 public static SingleTon GrtInstance()
 {
     if (_singleTon == null)
     {
         _singleTon = new SingleTon();
     }
     return(_singleTon);
 }
Example #12
0
 public Map LoadMap()
 {
     if (DungeonMap == null)
     {
         DungeonMap = SingleTon.GetMapManagerInstance().Dungeons[SingleTon.GetRandomNum(0, SingleTon.GetMapManagerInstance().Dungeons.Count)];
     }
     return(DungeonMap);
 }
 private void DrawStats()
 {
     Console.WriteLine("World");
     Console.Write("X: " + SingleTon.GetRooms().GetLength(0) + "          ");
     Console.WriteLine("Y: " + SingleTon.GetRooms().GetLength(1));
     Console.WriteLine("Cursor X: " + SingleTon.GetCursor().GetX() + "     Y: " + SingleTon.GetCursor().GetY());
     Console.WriteLine("Rooms: " + (SingleTon.GetRooms().GetLength(0) * SingleTon.GetRooms().GetLength(1)));
 }
Example #14
0
        public void ReDrawStats()
        {
            LineHeightPos = 0;
            string        BigestText = "";
            List <string> StatTexts  = new List <string>();

            StatTexts.Add(" Health: " + SingleTon.GetPlayerController().Skills.Vitallity.HealthCurrent + "/" + SingleTon.GetPlayerController().Skills.Vitallity.Health + "  ");
            StatTexts.Add(" Mana: " + SingleTon.GetPlayerController().Skills.Magic.ManaCurrent + "/" + SingleTon.GetPlayerController().Skills.Magic.Mana + "  ");
            StatTexts.Add(" Damage: " + SingleTon.GetPlayerController().Skills.Power.ExtraAttack + " + " + SingleTon.GetPlayerController().Skills.Power.Buff + "  ");
            StatTexts.Add(" Armor: " + SingleTon.GetPlayerController().Armor + " ");
            foreach (string element in StatTexts)
            {
                if (element.Length > BigestText.Length)
                {
                    BigestText = element + " ";
                }
            }

            CW.FillOutStringBorder(BigestText, true, StatsPosStart.X, StatsPosStart.Y + LineHeightPos);
            LineHeightPos++;
            foreach (string element in StatTexts)
            {
                CW.Write(Side, StatsPosStart.X, StatsPosStart.Y + LineHeightPos);
                CW.Write(element, StatsPosStart.X + 1, StatsPosStart.Y + LineHeightPos);
                CW.Write(Side, StatsPosStart.X + (BigestText.Length - 1), StatsPosStart.Y + LineHeightPos);
                LineHeightPos++;
            }
            CW.FillOutStringBorder(BigestText, false, StatsPosStart.X, StatsPosStart.Y + LineHeightPos);

            //enemy

            LineHeightPos = 0;
            BigestText    = "";
            StatTexts.Clear();
            StatTexts.Add(" Health: " + SingleTon.GetPlayerController().CBM.enemyFighting.Health + "/" + SingleTon.GetPlayerController().CBM.enemyFighting.MaxHp + "  ");
            StatTexts.Add(" Damage: " + SingleTon.GetPlayerController().CBM.enemyFighting.Damage + "  ");
            StatTexts.Add(" ");
            StatTexts.Add(" ");
            foreach (string element in StatTexts)
            {
                if (element.Length > BigestText.Length)
                {
                    BigestText = element + " ";
                }
            }
            int Lenght = StatsPosStart.X + (Console.WindowWidth - (StatsPosStart.X + 1 + BigestText.Length));

            CW.FillOutStringBorder(BigestText, true, Lenght, StatsPosStart.Y + LineHeightPos);
            LineHeightPos++;
            foreach (string element in StatTexts)
            {
                CW.Write(Side, Lenght, StatsPosStart.Y + LineHeightPos);
                CW.Write(element, Lenght + 1, StatsPosStart.Y + LineHeightPos);
                CW.Write(Side, Lenght + (BigestText.Length - 1), StatsPosStart.Y + LineHeightPos);
                LineHeightPos++;
            }
            CW.FillOutStringBorder(BigestText, false, Lenght, StatsPosStart.Y + LineHeightPos);
        }
        public void WhenGetInstance_Twice_ShouldBeEquals()
        {
            //act
            SingleTon sut1 = SingleTon.Instance;
            SingleTon sut2 = SingleTon.Instance;

            //assert
            Assert.Equal(sut1, sut2);
        }
Example #16
0
 public override void Equip()
 {
     if (SingleTon.GetPlayerController().Inventory.MainHand != null)
     {
         SingleTon.GetPlayerController().Inventory.MainHand.UnEquip();
     }
     SingleTon.GetPlayerController().Inventory.MainHand = this;
     SingleTon.GetPlayerController().Skills.Power.AddWeaponDamage(Damage);
 }
        private void CalculateDrawPos()
        {
            XDrawingStart = 0;
            YDrawingStart = 0;
            XDrawingEnd   = 0;
            YDrawingEnd   = 0;
            if (SingleTon.GetRooms().GetLength(0) < ScreenRes && SingleTon.GetRooms().GetLength(1) < ScreenRes)
            {
                XDrawingStart = 0;
                YDrawingStart = 0;
                XDrawingEnd   = SingleTon.GetRooms().GetLength(0);
                YDrawingEnd   = SingleTon.GetRooms().GetLength(1);
            }
            else
            {
                if ((SingleTon.GetCursor().GetX() - (ScreenRes / 2)) > 0)
                {
                    XDrawingStart += SingleTon.GetCursor().GetX() - (ScreenRes / 2);
                }
                else
                {
                    XDrawingEnd   += (ScreenRes / 2) - SingleTon.GetCursor().GetX();
                    XDrawingStart += 0;
                }

                if ((SingleTon.GetCursor().GetX() + (ScreenRes / 2)) < SingleTon.GetRooms().GetLength(0))
                {
                    XDrawingEnd = SingleTon.GetCursor().GetX() + (ScreenRes / 2);
                }
                else
                {
                    XDrawingStart += (ScreenRes / 2) - (SingleTon.GetRooms().GetLength(0) - SingleTon.GetCursor().GetX());
                    XDrawingEnd   += SingleTon.GetCursor().GetX() + (SingleTon.GetRooms().GetLength(0) - SingleTon.GetCursor().GetX());
                }

                if ((SingleTon.GetCursor().GetY() - (ScreenRes / 2)) > 0)
                {
                    YDrawingStart += SingleTon.GetCursor().GetY() - (ScreenRes / 2);
                }
                else
                {
                    YDrawingEnd  += (ScreenRes / 2) - SingleTon.GetCursor().GetY();
                    YDrawingStart = 0;
                }

                if ((SingleTon.GetCursor().GetY() + (ScreenRes / 2)) < SingleTon.GetRooms().GetLength(1))
                {
                    YDrawingEnd += SingleTon.GetCursor().GetY() + (ScreenRes / 2);
                }
                else
                {
                    YDrawingStart += (ScreenRes / 2) - (SingleTon.GetRooms().GetLength(1) - SingleTon.GetCursor().GetY());;
                    YDrawingEnd   += SingleTon.GetCursor().GetY() + (SingleTon.GetRooms().GetLength(1) - SingleTon.GetCursor().GetY());
                }
            }
        }
Example #18
0
        public bool CheckForEnemy(BaseTile Tile)
        {
            List <Enemy> enemiesToPick = SingleTon.GetEnemies().enemies.Where(x => x.SpawnableTiles.Any(y => y.TileName == Tile.TileName)).Where(x => x.MinLevel <SingleTon.GetPlayerController().Level&& x.MaxLevel> SingleTon.GetPlayerController().Level).ToList();

            if (enemiesToPick.Count != 0)
            {
                enemyFighting = new Enemy().Copy(enemiesToPick[SingleTon.GetRandomNum(0, enemiesToPick.Count)]);
            }
            return(true);
        }
 public void TryCreateAccount()
 {
     if (_Model.Username != "" && _Model.Username != null && _Model.Password != "" && _Model.Password != null)
     {
         if (SingleTon.GetAccessAPI().CreateAccount(_Model.Username, _Model.Password).Result)
         {
             _Model.ShowText = true;
         }
     }
 }
Example #20
0
 public virtual BaseTile CopyOf(BaseTile _base)
 {
     MyType           = _base.MyType;
     Description      = _base.Description;
     TileName         = _base.TileName;
     Walkable         = _base.Walkable;
     Pos              = _base.Pos;
     ChanceAtMonsters = SingleTon.PercentChanceBetween(_base.MinChanceMonster, _base.MaxChanceMonster);
     return(this);
 }
Example #21
0
        public void DrawGold()
        {
            lineheight = 0;
            string GoldText = "║ Gold: " + SingleTon.GetPlayerController().Inventory.Gold + " ║";

            CW.FillOutStringBorder(GoldText, true, GoldHeight.X, GoldHeight.Y + lineheight);
            lineheight++;
            CW.Write(GoldText, GoldHeight.X, GoldHeight.Y + lineheight);
            lineheight++;
            CW.FillOutStringBorder(GoldText, false, GoldHeight.X, GoldHeight.Y + lineheight);
        }
Example #22
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #23
0
 public WeaponItem(string _name, string _description, ItemType _itemType, int _value, bool _usedInCombat, int _damage)
 {
     name        = _name;
     describtion = _description;
     Id          = SingleTon.GetItemManager().AllItems.Count;
     itemType    = _itemType;
     Value       = _value;
     UseInCombat = _usedInCombat;
     Damage      = _damage;
     Effect      = "Attack +" + Damage;
 }
Example #24
0
 public ArmorItem(string _name, string _description, ItemType _itemType, int _value, bool _usedInCombat, int _AC, ArmorLocation _armorLocation)
 {
     name          = _name;
     Id            = SingleTon.GetItemManager().AllItems.Count;
     describtion   = _description;
     itemType      = _itemType;
     Value         = _value;
     UseInCombat   = _usedInCombat;
     AC            = _AC;
     ArmorLocation = _armorLocation;
     Effect        = "Def +" + AC;
 }
Example #25
0
 public ActionResult SendMessage(string userID, string message)
 {
     try
     {
         SingleTon.GetSQLAccessor().AddNewMessage(userID, message);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
Example #26
0
        private void GenerateTown(object MD)
        {
            AllNPCs = new List <TileNPC>();
            MapData         Temp  = (MapData)MD;
            List <BaseTile> tiles = Temp.tiles;

            NPCS = Temp.SpawnAbleEnemies.Select(x => (BaseNPC)x).ToList();

            for (int y = 0; y < MapSize.Y; y++)
            {
                for (int x = 0; x < MapSize.X; x++)
                {
                    Tiles[x, y]     = new BaseTile().CopyOf(tiles[1]);
                    Tiles[x, y].Pos = new Cord {
                        X = x, Y = y
                    };
                }
            }
            for (int i = 0; i < Temp.AmountOfDungeonOrHouses; i++)
            {
                if (CheckHouse())
                {
                    CreateHouse(Location, Temp.tiles[0]);
                }
                else
                {
                    i--;
                }
            }
            while (true)
            {
                bool foutain = false;
                while (foutain == false)
                {
                    Location = new Cord {
                        X = SingleTon.GetRandomNum(0, MapSize.X), Y = SingleTon.GetRandomNum(0, MapSize.Y)
                    };
                    if (Tiles[Location.X, Location.Y].MyType == TileType.Normal)
                    {
                        Tiles[Location.X, Location.Y] = new BaseTile().CopyOf(tiles[2]);
                    }
                }
                Location = new Cord {
                    X = SingleTon.GetRandomNum(0, MapSize.X), Y = SingleTon.GetRandomNum(0, MapSize.Y)
                };
                if (Tiles[Location.X, Location.Y].MyType == TileType.Normal)
                {
                    SpawnPoint = Tiles[Location.X, Location.Y];
                    return;
                }
            }
        }
Example #27
0
        private bool CheckHouse()
        {
            Location = new Cord {
                X = SingleTon.GetRandomNum(0, MapSize.X), Y = SingleTon.GetRandomNum(0, MapSize.Y)
            };
            List <Cord> CheckList = new List <Cord> {
                new Cord {
                    X = Location.X - 1, Y = Location.Y
                }, new Cord {
                    X = Location.X - 2, Y = Location.Y
                }, new Cord {
                    X = Location.X - 2, Y = Location.Y - 1
                }, new Cord {
                    X = Location.X - 2, Y = Location.Y - 2
                }, new Cord {
                    X = Location.X - 2, Y = Location.Y - 3
                }, new Cord {
                    X = Location.X - 2, Y = Location.Y - 4
                }, new Cord {
                    X = Location.X - 1, Y = Location.Y - 4
                }, new Cord {
                    X = Location.X, Y = Location.Y - 4
                }, new Cord {
                    X = Location.X + 1, Y = Location.Y - 4
                }, new Cord {
                    X = Location.X + 2, Y = Location.Y - 4
                }, new Cord {
                    X = Location.X + 2, Y = Location.Y - 3
                }, new Cord {
                    X = Location.X + 2, Y = Location.Y - 2
                }, new Cord {
                    X = Location.X + 2, Y = Location.Y - 1
                }, new Cord {
                    X = Location.X + 2, Y = Location.Y
                }, new Cord {
                    X = Location.X + 1, Y = Location.Y
                }
            };

            foreach (Cord element in CheckList)
            {
                if (MapSize.X <= element.X || 0 > element.X || MapSize.Y <= element.Y || 0 > element.Y)
                {
                    return(false);
                }
                if (Tiles[element.X, element.Y].MyType != TileType.Normal)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #28
0
        private void CheckRoomConnection() //check where there is unreachable areas
        {
            Room LastusedRoom;

            AllRooms       = SingleTon.GetRooms();
            RoomsConnected = new Room[SingleTon.GetRooms().GetLength(0), SingleTon.GetRooms().GetLength(1)];
            LastusedRoom   = AllRooms[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()];
            RoomsConnected[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()] = AllRooms[SingleTon.GetCursor().GetX(), SingleTon.GetCursor().GetY()];
            for (int i = 0; i < 50; i++)//maybe make it all rooms as amount of times to check or do a while loop to check for when some bool get's check for being stuck
            {
                LastusedRoom = CheckNeightboors(LastusedRoom);
            }
        }
Example #29
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Example #30
0
 public static SingleTon GetInstance()
 {
     if (Instance == null)
     {
         mutex.WaitOne();
         if (Instance == null)
         {
             Instance = new SingleTon();
         }
         mutex.ReleaseMutex();
     }
     return Instance;
 }
Example #31
0
        private Cord SetRelativeRoom()
        {
            Cord NewCord;

            while (true)
            {
                NewCord = SetRooms[SingleTon.GetRandomNum(0, SetRooms.Count)].Pos;
                if (Tiles[NewCord.X, NewCord.Y].MyType == TileType.Normal)
                {
                    return(NewCord);
                }
            }
        }
Example #32
0
 public static SingleTon GetInstance()
 {
     if (Instance == null)
     {
         mutex.WaitOne();
         if (Instance == null)
         {
             Instance = new SingleTon();
             //just for testing ////////////////////////////////
             System.Console.WriteLine("Current Task ID:{0}",Task.CurrentId);
              //////////////////////////////////////////////////
         }
         mutex.ReleaseMutex();
     }
     return Instance;
 }
Example #33
0
 public static void SingletonDP()
 {
     var sdp = new SingleTon();
     sdp.Demonstrate();
 }