private IEnumerator Load() { while (ETHManager.Instance.IsGetBalance || ETHManager.Instance.IsGetAdventure || ETHManager.Instance.IsSetAdventure) { yield return(null); } yield return(null); Loading.SetActive(false); Balance.text = ETHUtils.TrimForDecimal(ETHManager.Instance.SaveData.Balance); ListContent.transform.DetachChildren(); AdventureModel adventure = ETHManager.Instance.SaveData.adventure; if (adventure == null || string.IsNullOrEmpty(adventure.address)) { BuyButton.gameObject.SetActive(true); MyAdventure.gameObject.SetActive(false); Name.text = ""; Score.text = ""; } else { BuyButton.gameObject.SetActive(false); MyAdventure.gameObject.SetActive(true); MyAdventure.runtimeAnimatorController = animators[adventure.charaId]; Name.text = adventure.name; Score.text = adventure.score.ToString(); } ListUpdate(); }
public virtual async Task <List <AdventureModel> > GetList() { List <AdventureModel> AdventureList = new List <AdventureModel>(); using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("Adventure_GetList", connection)) { command.CommandType = CommandType.StoredProcedure; await connection.OpenAsync(); using (SqlDataReader reader = await command.ExecuteReaderAsync()) { while (reader.Read()) { AdventureModel Adventure = new AdventureModel(); Adventure.ID = (int)reader["ID"]; Adventure.AName = reader["AName"].ToString(); Adventure.ADescription = reader["ADescription"].ToString(); Adventure.ARating = (int)reader["ARating"]; Adventure.PostedBy = reader["PostedBy"].ToString(); AdventureList.Add(Adventure); } } } } return(AdventureList); }
public virtual AdventureModel Get(int id) { AdventureModel Adventure = null; using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("Adventure_Get", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@ID", id); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { Adventure = new AdventureModel(); Adventure.ID = (int)reader["ID"]; Adventure.AName = reader["AName"].ToString(); Adventure.ADescription = reader["ADescription"].ToString(); Adventure.ARating = (int)reader["ARating"]; Adventure.PostedBy = reader["PostedBy"].ToString(); } } } } return(Adventure); }
private void RunCommandTest() { AdventureModel model = new AdventureModel(); model.RegisterDefaultAdventureComponents(); model.TheGameEngine.SytemActionBus.Signal <CommandSystem, string>("Hello world"); model.Tick(); }
public IActionResult PostBlog() { AdventureModel model = new AdventureModel(); model.AName = _Settings.DefaultName; model.ARating = _Settings.DefaultRating; model.PostedBy = _Settings.DefaultUser; return(View(model)); }
/// <summary> /// Adds an adventure /// </summary> public void AddAdventure(AdventureModel adventureModel) { if (!_adventures.Any(x => x.Id == adventureModel.Id)) { _adventures.Add(adventureModel); //UpdateTags(); } }
void RunSimple() { AdventureModel model = new AdventureModel(); model.RegisterDefaultAdventureComponents(); var room = model.TheGameEngine.ComponentFactory.Create(typeof(Room), null); Assert.IsInstanceOfType(room, typeof(Room)); }
public IActionResult PostBlog(AdventureModel model) { if (!ModelState.IsValid) { return(View(model)); //return RedirectToAction("Index"); } return(Create(model)); }
public void SetAdventure(AdventureModel adventure) { if (IsSetAdventure) { return; } IsSetAdventure = true; Debug.Log("SetAdventure"); StartCoroutine(_SetAdventure(adventure)); }
/// <summary> /// Updates the adventure with id matching the parameter's id /// </summary> public void UpdateAdventure(AdventureModel model) { AdventureModel currentModel = _adventures.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _adventures[_adventures.IndexOf(currentModel)] = model; UpdateTags(); } }
/// <summary> /// Creates a new instance of <see cref="AdventureEditViewModel"/> /// </summary> public AdventureEditViewModel(AdventureModel adventureModel) { _adventureModel = new AdventureModel(adventureModel); _name = _adventureModel.Name; if (_adventureModel.Tags.Any()) { _tags = String.Join(", ", _adventureModel.Tags); } _introduction = _adventureModel.Introduction; }
void RunBuildARoom() { AdventureModel model = new AdventureModel(); model.RegisterDefaultAdventureComponents(); GameEngine ge = model.TheGameEngine; IEntity e = ge.EntityFactory.CreateDefault(new object()); e.Components.Add(ge.ComponentFactory.Create(typeof(Room), new object())); e.Components.Add(new FakeComponent()); ge.AddRootEntity(e); }
public void OnBuyButton() { Loading.SetActive(true); AdventureModel adventure = new AdventureModel(); adventure.address = ETHManager.Instance.SaveData.Address; adventure.name = RandomName(); adventure.charaId = Random.Range(0, 3); adventure.score = 0; ETHManager.Instance.SetAdventure(adventure); StartCoroutine(Load()); }
public void OnEndGame(int score) { AdventureModel adventure = ETHManager.Instance.SaveData.adventure; if (adventure != null) { if (adventure.score < score) { Loading.SetActive(true); adventure.score = score; ETHManager.Instance.SetAdventure(adventure); StartCoroutine(Load()); } } }
void Start() { //Get reference to the Animator component attached to this GameObject. anim = GetComponent <Animator> (); //Get and store a reference to the Rigidbody2D attached to this GameObject. rb2d = GetComponent <Rigidbody2D>(); AdventureModel adventure = ETHManager.Instance.SaveData.adventure; if (adventure == null || string.IsNullOrEmpty(adventure.address)) { anim.runtimeAnimatorController = animators[0]; } else { anim.runtimeAnimatorController = animators[adventure.charaId]; } }
public virtual void Save(AdventureModel Adventure) { using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("Adventure_InsertUpdate", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.AddWithValue("@ID", Adventure.ID); command.Parameters.AddWithValue("@AName", Adventure.AName); command.Parameters.AddWithValue("@ADescription", Adventure.ADescription); command.Parameters.AddWithValue("@ARating", Adventure.ARating); command.Parameters.AddWithValue("@PostedBy", Adventure.PostedBy); int rows = command.ExecuteNonQuery(); if (rows <= 0) { Console.Error.WriteLine("Didn't Work"); } } } }
public IEnumerator _SetAdventure(AdventureModel adventure) { decimal amount = new decimal(0.00); decimal gasPrice = 10000000; decimal gasLimit = 300000; Contract contract = new Contract(null, ABI, ContractAddress); Function func = contract.GetFunction("setAdventure"); // TODO::なぜかアドレスが一位識別しない string data = func.GetData(adventure.address, adventure.score, adventure.name, adventure.charaId); TransactionSignedUnityRequest ethSend = new TransactionSignedUnityRequest(url, SaveData.PrivateKey, SaveData.Address); TransactionInput input = new TransactionInput(data, ContractAddress, SaveData.Address, new HexBigInteger(new BigInteger(gasPrice)), new HexBigInteger(new BigInteger(gasLimit)), new HexBigInteger(new BigInteger(amount))); yield return(ethSend.SignAndSendTransaction(input)); Debug.Log(ethSend.Result); Save(); yield return(new WaitForSeconds(3)); GetBalance(); IsSetAdventure = false; }
public IActionResult Edit(int id) { AdventureModel adventure = _AdventureRepo.Get(id); return(View(adventure)); }
public IEnumerator _GetAdventureAndTop100() { yield return(null); EthCallUnityRequest ethCallUserAdventures = new EthCallUnityRequest(url); Contract contract = new Contract(null, ABI, ContractAddress); Function userAdventures = contract.GetFunction("userAdventures"); CallInput callInputUserAdventures = userAdventures.CreateCallInput(); callInputUserAdventures.Data = userAdventures.GetData(SaveData.Address); // TODO::なぜかアドレスが一位識別しない yield return(ethCallUserAdventures.SendRequest(callInputUserAdventures, BlockParameter.CreateLatest())); Adventure adventure = userAdventures.DecodeDTOTypeOutput <Adventure>(ethCallUserAdventures.Result); if (!string.IsNullOrEmpty(adventure.Address) && !string.IsNullOrEmpty(adventure.Name)) { AdventureModel adventureModel = new AdventureModel(adventure); SaveData.adventure = adventureModel; } Debug.Log("_GetAdventureAndTop100 userAdventures:" + ethCallUserAdventures.Result); EthCallUnityRequest ethCallGetCountTopAdventures = new EthCallUnityRequest(url); Function getCountTopAdventures = contract.GetFunction("getCountTopAdventures"); CallInput callInputGetCountTopAdventures = getCountTopAdventures.CreateCallInput(); //callInputGetCountTopAdventures.Data = getCountTopAdventures.GetData(); yield return(ethCallGetCountTopAdventures.SendRequest(callInputGetCountTopAdventures, BlockParameter.CreateLatest())); string retCount = ethCallGetCountTopAdventures.Result; int count = int.Parse(retCount.Substring(2), System.Globalization.NumberStyles.HexNumber); Debug.Log("_GetAdventureAndTop100 getCountTopAdventures:" + count.ToString()); List <AdventureModel> list = new List <AdventureModel>(); for (int i = 0; i < count; i++) { // TODO::なぜか重複登録されてしまう。 EthCallUnityRequest ethCallTopAdventures = new EthCallUnityRequest(url); Function topAdventures = contract.GetFunction("topAdventures"); CallInput callInputTopAdventures = topAdventures.CreateCallInput(); callInputTopAdventures.Data = topAdventures.GetData(i); yield return(ethCallTopAdventures.SendRequest(callInputTopAdventures, BlockParameter.CreateLatest())); Debug.Log("_GetAdventureAndTop100 ethCallTopAdventures:" + ethCallTopAdventures.Result); Adventure topadventure = topAdventures.DecodeDTOTypeOutput <Adventure>(ethCallTopAdventures.Result); if (!string.IsNullOrEmpty(topadventure.Address) && !string.IsNullOrEmpty(topadventure.Name)) { AdventureModel adventureModel = new AdventureModel(topadventure); if (SaveData.Address.ToLower().Trim().Equals(adventureModel.address.ToLower().Trim())) { if (SaveData.adventure == null || string.IsNullOrEmpty(SaveData.adventure.name) || SaveData.adventure.score < adventureModel.score) { SaveData.adventure = adventureModel; } } bool unique = true; for (int index = 0; index < list.Count; index++) { AdventureModel item = list[index]; if (item.address.ToLower().Trim().Equals(adventureModel.address.ToLower().Trim())) { unique = false; if (adventureModel.score > item.score) { list[index] = adventureModel; } } } if (unique) { list.Add(adventureModel); } } list.Sort((a, b) => { if (a.score < b.score) { return(1); } else if (a.score > b.score) { return(-1); } else { return(0); } }); Debug.Log("_GetAdventureAndTop100 i:" + i.ToString()); } SaveData.topAdventures = list.ToArray(); Debug.Log("_GetAdventureAndTop100 list count:" + list.Count.ToString()); IsGetAdventure = false; Save(); }
/// <summary> /// Creates a new instance of <see cref="AdventureViewModel"/> /// </summary> public AdventureViewModel(AdventureModel adventureModel) { _adventureModel = adventureModel; }
Boolean ISerializer.Save(StreamWriter writer, AdventureModel engine) { throw new NotImplementedException(); }
Boolean ISerializer.Load(StreamReader reader, AdventureModel engine) { throw new NotImplementedException(); }
/// <summary> /// True if the search input applies to the model /// </summary> public bool SearchInputApplies(AdventureSearchInput searchInput, AdventureModel adventureModel) { return(HasSearchText(adventureModel, searchInput.SearchText) && HasTag(adventureModel, searchInput.Tag.Key)); }
private bool HasSearchText(AdventureModel adventureModel, string searchText) { return(String.IsNullOrWhiteSpace(searchText) || adventureModel.Name.ToLower().Contains(searchText.ToLower())); }
private bool HasTag(AdventureModel adventureModel, string tag) { return(tag == null || adventureModel.Tags.Any(x => x.Equals(tag, StringComparison.CurrentCultureIgnoreCase))); }
private void Copy() { if (_selectedAdventure != null) { bool copyAdventure = true; if (_adventureEditViewModel != null) { if (_editHasUnsavedChanges) { string body = String.Format("{0} has unsaved changes.{1}What would you like to do?", _selectedAdventure.Name, Environment.NewLine + Environment.NewLine); string accept = "Save and Continue"; string reject = "Discard Changes"; string cancel = "Cancel Navigation"; bool? result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel); if (result == true) { if (!SaveEditAdventure()) { copyAdventure = false; } } else if (result == false) { CancelEditAdventure(); } else { copyAdventure = false; } } else { CancelEditAdventure(); } } if (copyAdventure) { AdventureModel adventureModel = new AdventureModel(_selectedAdventure.AdventureModel); adventureModel.Name += " (copy)"; adventureModel.Id = Guid.NewGuid(); _compendium.AddAdventure(adventureModel); if (_adventureSearchService.SearchInputApplies(_adventureSearchInput, adventureModel)) { ListItemViewModel <AdventureModel> listItem = new ListItemViewModel <AdventureModel>(adventureModel); InitializeListItemDetails(listItem, adventureModel); _adventures.Add(listItem); foreach (ListItemViewModel <AdventureModel> item in _adventures) { item.IsSelected = false; } listItem.IsSelected = true; } _selectedAdventure = new AdventureViewModel(adventureModel); SortAdventures(); _compendium.SaveAdventures(); OnPropertyChanged(nameof(SelectedAdventure)); } } }
public override void Save(AdventureModel Adventure) { base.Save(Adventure); _Cache.Remove(_CacheListKey); }
public IActionResult View(int id) { AdventureModel a = _AdventureRepo.Get(id); return(View(a)); }
private void InitializeListItemDetails(ListItemViewModel <AdventureModel> listItem, AdventureModel adventureModel) { listItem.Model = adventureModel; if (!String.IsNullOrWhiteSpace(adventureModel.Name)) { listItem.Name = adventureModel.Name; } else { listItem.Name = "Unknown Name"; } if (!String.IsNullOrWhiteSpace(adventureModel.Introduction)) { listItem.Description = new String(adventureModel.Introduction.Take(50).ToArray()); } else { listItem.Description = "Unknown description"; } }
protected IActionResult Create(AdventureModel model) { _AdventureRepo.Save(model); return(RedirectToAction("Index")); }