public async Task <IActionResult> Login(LoginViewModel loginViewModel) { if (ModelState.IsValid) { var sqliteCore = new SQLiteCore(); var usuario = new Usuario() { Login = loginViewModel.Usuario, Senha = loginViewModel.Senha }; if (await sqliteCore.ValidarLoginUsuarioAsync(usuario)) { HttpContext.Session.SetInt32("idUsuario", sqliteCore.IdUsuario); HttpContext.Session.SetInt32("idServidor", loginViewModel.Servidor ?? 0); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Usuário e/ou senha não encontrados."); await loginViewModel.CarregarServidoresAsync(); return(View("Index", loginViewModel)); } } else { ModelState.AddModelError("", "Ocorreu um erro ao tentar realizar o login."); await loginViewModel.CarregarServidoresAsync(); return(View("Index", loginViewModel)); } }
public void AddItem(Item itemToAdd, GameObject itemScript) { if ((int)itemToAdd.itemType != 0 && items.Count > 0) { for (int i = 0; i < items.Count; i++) { if (items[i].name == itemToAdd.name && items[i].icon == itemToAdd.icon && items[i].count < 99) { items[i].count += 1; if (SQLiteCore.UpdateItem(items[i])) { itemScript.SendMessage("DoInteraction"); return; } } } } if (items.Count >= space) { Debug.Log("Inventory Full!!"); return; } if (SQLiteCore.AddItemToInventory(itemToAdd) == -1) { Debug.Log("Save item ERROR"); return; } itemToAdd.id = SQLiteCore.LastAddedItem; items.Add(itemToAdd); itemScript.SendMessage("DoInteraction"); }
public void RemoveDatabaseFromHistory(string path) { if (SQLiteCore.RemoveDatabaseFromHistory(path)) { Refresh(); } }
public void Refresh() { List <string> dataBasePath = SQLiteCore.GetDataBasesPaths(); DataBases = new ObservableCollection <DataBaseViewModel>(); foreach (var path in dataBasePath) { DataBases.Add(DataBaseBuilder.BuildDataBaseObject(path, this)); } }
public void ChangeItemAt(Item item, int index) { item.isEquiping = false; items.Insert(index, item); SQLiteCore.UpdateEquipment(item); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } }
public void RemoveItem() { if (InventoryManager.instance.inventoryMode == InventoryManager.InventoryMode.Shop) { playerManager.player.Gold += ShowingItem.priceSell * ShowingItem.count; SQLiteCore.UpdatePlayer(playerManager.player); Inventory.instance.UpdateGold();; } ShowingItem.RemoveFromInventory(); ShowingItem = null; }
public int EquipItem(Item equipItem) { int index = items.IndexOf(equipItem); equipItem.isEquiping = true; items.Remove(equipItem); SQLiteCore.UpdateEquipment(equipItem); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } return(index); }
private void Init() { SQLiteCore.Init(CoreCommon.DBName); dv_Main.DoubleClick += Dv_Main_DoubleClick; if (string.IsNullOrWhiteSpace(AppCommon.CurrentUserId) || string.IsNullOrWhiteSpace(AppCommon.CurrentPassword)) { using (var fmLogin = new FMLogin()) { fmLogin.ShowDialog(); } } Refesh(); }
public ObjectExplorerViewModel() { _dataBases = new ObservableCollection <DataBaseViewModel>(); _openDataBaseCMD = new Command(o => OpenDataBase()); _refreshCMD = new Command(o => Refresh()); _openInFolderCMD = new Command(o => OpenInFolder(o.ToString())); _removeDataBaseFromHistoryCMD = new Command(o => RemoveDatabaseFromHistory(o.ToString())); List <string> dataBasePath = SQLiteCore.GetDataBasesPaths(); foreach (var path in dataBasePath) { _dataBases.Add(DataBaseBuilder.BuildDataBaseObject(path, this)); } }
public async Task <IActionResult> Gravar(UsuarioViewModel usuarioViewModel) { var sqliteCore = new SQLiteCore(); var usuario = new Usuario() { IdUsuario = usuarioViewModel.IdUsuario.HasValue ? usuarioViewModel.IdUsuario.Value : 0, Nome = usuarioViewModel.Nome, Login = usuarioViewModel.Login, Senha = usuarioViewModel.Senha }; await sqliteCore.GravarUsuarioAsync(usuario); return(RedirectToAction("Index")); }
public bool UnEquipitem(Item item) { if (items.Count >= space) { return(false); } item.isEquiping = false; items.Add(item); SQLiteCore.UpdateEquipment(item); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } return(true); }
private void Init() { txt_userid.TextChanged += txt_TextChanged; txt_password.TextChanged += txt_TextChanged; txt_userid.KeyDown += txt_KeyDown; txt_password.KeyDown += txt_KeyDown; if (!SQLiteCore.tabbleIsExist(CoreCommon.Table_User)) { this.Hide(); using (var register = new FmRegister()) { register.ShowDialog(); } } }
public void OpenDataBase() { var path = Hepler.OpenFile(); if (!string.IsNullOrEmpty(path)) { string connectionString = string.Format("Data source= {0} ;", path); if (SQLiteCore.CheckConnection(connectionString)) { if (SQLiteCore.AddDataBaseToHistory(path)) { DataBases.Add(DataBaseBuilder.BuildDataBaseObject(path, this)); } } } }
public void Remove(Item removeItem) { SQLiteCore.RemoveItem(removeItem.id); if ((int)removeItem.itemType == 0) { if (removeItem.options.Length > 0) { SQLiteCore.RemoveOptionItem(removeItem.id); } } items.Remove(removeItem); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } }
public void EquipItem(Item item, int index) { Item oldItem = null; int slotIndex = (int)item.equipSlot; item.isEquiping = true; SQLiteCore.UpdateEquipment(item); if (currentEquipment[slotIndex] != null) { oldItem = currentEquipment [slotIndex]; inventory.ChangeItemAt(oldItem, index); statManager.UpdateEquipItem(oldItem, false); } currentEquipment[slotIndex] = item; equipSlots[slotIndex].overrideSprite = item.icon; equipSlots[slotIndex].enabled = true; statManager.UpdateEquipItem(item, true); }
public void addExp(int exp) { currentExp += exp; if (currentExp >= ExpOfLevel) { CurrentLevel += 1; currentExp = 0; ExpOfLevel = SQLiteCore.levelManager[CurrentLevel - 1].Exp; txtLevel.text = CurrentLevel + ""; } PlayerManager.instance.player.Level = CurrentLevel; PlayerManager.instance.player.Exp = currentExp; SQLiteCore.UpdatePlayer(PlayerManager.instance.player); expBar.fillAmount = (float)currentExp / ExpOfLevel; float textExp = (float)Math.Round((double)currentExp * 100 / ExpOfLevel, 2); txtExp.text = textExp + "%"; txtLevel.text = CurrentLevel + ""; }
private void Start() { listCurrentItem = SQLiteCore.getEquipingitem(); inventory = Inventory.instance; statManager = StatManager.instance; int numSlots = System.Enum.GetNames(typeof(Item.EquipmentSlot)).Length; currentEquipment = new Item[numSlots]; for (int i = 0; i < equipSlots.Length; i++) { //equipSlots[i].sprite = Resources.Load <Sprite> ("root_"+i); equipSlots[i].enabled = false; } if (listCurrentItem.Count > 0) { for (int i = 0; i < listCurrentItem.Count; i++) { List <Option> list = SQLiteCore.getOptionItem(listCurrentItem[i].id); if (list.Count > 0) { listCurrentItem[i].options = new Option[list.Count]; listCurrentItem[i].points = new int[list.Count]; for (int j = 0; j < list.Count; j++) { Option o = ScriptableObject.CreateInstance <Option>(); o.title = list[j].title; o.tag = list[j].tag; o.unit = list[j].unit; listCurrentItem[i].options[j] = o; listCurrentItem[i].points[j] = list[j].point; } } else { listCurrentItem[i].options = new Option[0]; listCurrentItem[i].points = new int[0]; } LoadCurrentItem(listCurrentItem[i]); } } }
public async Task <IActionResult> Gravar(ServidorViewModel servidorViewModel) { var sqliteCore = new SQLiteCore(); var servidor = new Servidor() { IdServidor = servidorViewModel.IdServidor.HasValue ? servidorViewModel.IdServidor.Value : 0, Hostname = servidorViewModel.Hostname, Instancia = servidorViewModel.Instancia, Usuario = servidorViewModel.Usuario, Senha = servidorViewModel.Senha, GravarLog = servidorViewModel.GravarLog, UsarTransacao = servidorViewModel.UsarTransacao }; await sqliteCore.GravarServidorAsync(servidor); if (await sqliteCore.DeveGravarSessaoServidor()) { HttpContext.Session.SetInt32("idServidor", await sqliteCore.RetornaIdUnicoServidor()); } return(RedirectToAction("Index")); }
public bool UsePotion(int itemPotion) { Item usingItem = LookUpPotion(itemPotion); if (usingItem != null) { if (usingItem.count > 1) { usingItem.count--; SQLiteCore.UpdateItem(usingItem); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } } else { Remove(usingItem); } return(true); } return(false); }
public void LoadCurrentItem() { items = SQLiteCore.getItemInInvengory(); if (items.Count > 0) { for (int i = 0; i < items.Count; i++) { if ((int)items[i].itemType == 0) { List <Option> list = SQLiteCore.getOptionItem(items[i].id); if (list.Count > 0) { items[i].options = new Option[list.Count]; items[i].points = new int[list.Count]; for (int j = 0; j < list.Count; j++) { Option o = ScriptableObject.CreateInstance <Option>(); o.title = list[j].title; o.tag = list[j].tag; o.unit = list[j].unit; items[i].options[j] = o; items[i].points[j] = list[j].point; } } else { items[i].options = new Option[0]; items[i].points = new int[0]; } if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } } } } }
public void BuyItem(Item itemBuy) { if ((int)itemBuy.itemType != 0 && items.Count > 0) { for (int i = 0; i < items.Count; i++) { if (items[i].name == itemBuy.name && items[i].icon == itemBuy.icon && items[i].count < 99) { if (items[i].count + itemBuy.count < 100) { items[i].count += itemBuy.count; PlayerManager.instance.player.Gold = PlayerManager.instance.player.Gold - (itemBuy.count * itemBuy.priceBuy); UpdateGold(); SQLiteCore.UpdatePlayer(PlayerManager.instance.player); SQLiteCore.UpdateItem(items[i]); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } return; } else { if (items.Count >= space) { Debug.Log("Inventory Full!!"); return; } itemBuy.count = itemBuy.count - (99 - items[i].count); items[i].count = 99; PlayerManager.instance.player.Gold = PlayerManager.instance.player.Gold - (itemBuy.count * itemBuy.priceBuy); UpdateGold(); SQLiteCore.UpdatePlayer(PlayerManager.instance.player); SQLiteCore.UpdateItem(items[i]); if (SQLiteCore.AddItemToInventory(itemBuy) == -1) { Debug.Log("Save item ERROR"); return; } itemBuy.id = SQLiteCore.LastAddedItem; items.Add(itemBuy); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } return; } } } } if (items.Count >= space) { Debug.Log("Inventory Full!!"); return; } PlayerManager.instance.player.Gold = PlayerManager.instance.player.Gold - (itemBuy.count * itemBuy.priceBuy); UpdateGold(); SQLiteCore.UpdatePlayer(PlayerManager.instance.player); if (SQLiteCore.AddItemToInventory(itemBuy) == -1) { Debug.Log("Save item ERROR"); return; } itemBuy.id = SQLiteCore.LastAddedItem; items.Add(itemBuy); if (onItemChangedCallback != null) { onItemChangedCallback.Invoke(); } }
void Awake() { player = SQLiteCore.getPlayerInfor(); _instance = this; }