public async Task <IActionResult> BuildUserUnit([FromBody] int unitId) { var unit = await _context.Units.FirstOrDefaultAsync <Unit>(u => u.Id == unitId); var user = await _utilityService.GetUser(); if (user.Bananas < unit.BananaCost) { return(BadRequest("Not enough bananas")); } user.Bananas -= unit.BananaCost; UserUnit newUserUnit = new UserUnit { UnitId = unit.Id, UserId = user.Id, HitPoints = unit.HitPoints }; await _context.UserUnits.AddAsync(newUserUnit); await _context.SaveChangesAsync(); return(Ok(newUserUnit)); }
public Unit(UserUnit unit) { SystemName = unit.NumeratorName; ConversionMultiplier = unit.Multiplier; ConversionOffset = unit.Offset; DimensionVector = unit.DimensionVector; }
public bool Authenticate(UserUnit oUnit) { SqlCommand oCommand = new SqlCommand(); SqlDataAdapter oAdapter = new SqlDataAdapter(); DataTable dtUsers = new DataTable(); oCommand.Connection = this.Connection; oCommand.CommandText = "SELECT * FROM OUSR WHERE UserID=@UserID AND UserPassword=@UserPassword"; oCommand.Parameters.Add(new SqlParameter("@UserID", oUnit.UserID)); oCommand.Parameters.Add(new SqlParameter("@UserPassword", oUnit.UserPassword)); oAdapter.SelectCommand = oCommand; oAdapter.Fill(dtUsers); int iCount = dtUsers.Rows.Count; if (iCount <= 0) { return false; } else { return true; } }
// Function called when the player character acquire the item public void powerUp(UserUnit userUnit) { int change_number = (int)Mathf.Round(Random.Range(change_range[0], change_range[1])); switch (attribute) { case "health": userUnit.current_health += change_number; if (userUnit.current_health > userUnit.health) { userUnit.current_health = userUnit.health; } break; case "moveRange": userUnit.moveRange += change_number; userUnit.view_range += change_number; break; case "attack_damage": userUnit.attack_damage += change_number; break; case "skill_damage": userUnit.skill_damage += change_number; break; } }
public UserUnitViewModel(UserUnit userUnit, Action onUnSelect = null) { UserUnit = userUnit; Icon = new ReactiveProperty <BitmapImage>(UserUnit.Unit.Icon); IsSupport = new ReactiveProperty <bool>(UserUnit.IsSupport); Rank = new ReactiveProperty <UnitRank>(UserUnit.Rank); RankView = new ReactiveProperty <string>(string.Empty); IsShowRank = new ReactiveProperty <Visibility>(); Rarity = new ReactiveProperty <UnitRarity>(UserUnit.Rarity); IsDoubling = new ReactiveProperty <bool>(false); IsDoublingSupport = new ReactiveProperty <bool>(false); UnSelect = new ReactiveCommand(); IsSupport.Subscribe(x => UserUnit.IsSupport = x); Rank.Subscribe(x => { UserUnit.Rank = x; UpdateRankString(x); }); Rarity.Subscribe(x => UserUnit.Rarity = x); UnSelect.Subscribe(() => onUnSelect?.Invoke()); UpdateRankString(Rank.Value); }
private void btnLogin_Click(object sender, EventArgs e) { this.ConnectionString = "Server=vm-sqlsvr;Database=MEISIN;Uid=sa;Pwd=nidaros;"; UserManager oManager = new UserManager(); UserUnit oUnit = new UserUnit(); oUnit.UserID = txtUID.Text; oUnit.UserPassword = txtPassword.Text; oManager.ConnectionString = this.ConnectionString; oManager.Open(); bool isAuthenticated = oManager.Authenticate(oUnit); if (isAuthenticated) { eLoanMainMenu oForm = new eLoanMainMenu(); oForm.ConnectionString = this.ConnectionString; oForm.ActiveUserID = txtUID.Text.ToUpper(); this.Visible = false; oForm.Show(); } else { MessageBox.Show("User name and password is invalid!!! Please try again!!!", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
public void AddUserUnit(UserUnit oUnit) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = this.Connection; oCommand.CommandText = "INSERT INTO OUSR (UserID, UserPassword) values (@UserID, @UserPassword)"; oCommand.Parameters.Add(new SqlParameter("@UserID", oUnit.UserID)); oCommand.Parameters.Add(new SqlParameter("@UserPassword", oUnit.UserPassword)); oCommand.ExecuteNonQuery(); }
public void TestUserUnit() { var stopWatch = new Stopwatch(); stopWatch.Start(); //create dictionary var userUnitA = new UserUnit("myUserUnit1", "MU1"); userUnitA.UserUnitType = UserUnitName.User01; userUnitA.MassMonoIsotopic = 500; var userUnitB = new UserUnit("myUserUnit2", "MU2"); userUnitB.UserUnitType = UserUnitName.User02; userUnitB.MassMonoIsotopic = 600; var userUnitC = new UserUnit("myUserUnit3", "MU3"); userUnitC.UserUnitType = UserUnitName.User03; userUnitC.MassMonoIsotopic = 700; var myLibrary = new UserUnitLibrary(); myLibrary.SetLibrary(userUnitA, userUnitB, userUnitC); Constants.SetUserUnitLibrary(myLibrary); //using a String Key with a dictionary var userKey = Constants.UserUnits[UserUnitName.User01].Symbol;//="N-03X1"//"CRFNeu5Ac_03_X1"; var userMass = Constants.UserUnits[userKey].MassMonoIsotopic; var userSymbol = Constants.UserUnits[userKey].Symbol; var userName = Constants.UserUnits[userKey].Name; Assert.AreEqual(500, userMass); Assert.AreEqual("MU1", userSymbol); Assert.AreEqual("myUserUnit1", userName); //using a Select Key and Enum var userMass3 = Constants.UserUnits[UserUnitName.User02].MassMonoIsotopic; var userSymbol3 = Constants.UserUnits[UserUnitName.User02].Symbol; var userName3 = Constants.UserUnits[UserUnitName.User02].Name; Assert.AreEqual(600, userMass3); Assert.AreEqual("MU2", userSymbol3); Assert.AreEqual("myUserUnit2", userName3); stopWatch.Stop(); Console.WriteLine("This took " + stopWatch.Elapsed + "seconds to TestCrossRing"); }
public static Guid Push(int Id) { if (UsersMap.Exists(x => x.Id == Id)) { UserUnit UserUnit = UsersMap.Single(x => x.Id == Id); UsersMap.Remove(UserUnit); } UserUnit NewUserUnit = new UserUnit { Id = Id, Guid = Guid.NewGuid() }; UsersMap.Add(NewUserUnit); return(NewUserUnit.Guid); }
private void UnselectUserUnit(UserUnit userUnit) { var index = m_PartUnits.FindIndex(x => x.UnitId == userUnit.UnitId); if (index < 0) { return; } m_PartUnits.RemoveAt(index); m_PartyUnitsCollection.RemoveAt(index); foreach (var unitViewModel in UnitList) { if (unitViewModel.Unit.Id == userUnit.UnitId) { unitViewModel.SetSelect(false); return; } } }
/// <summary> /// Spawns a new unit into the game /// </summary> /// <param name="unit"></param> /// <param name="user"></param> protected void SpawnUnit(UnitRecord unit, GameSession owner) { // Create the unit var spawnedUnit = new UserUnit(this, unit, owner); // Add to dictionary _units.TryAdd(unit.Id, spawnedUnit); // Set the current unit to the user owner.CurrentUnit = spawnedUnit; // Set team spawnedUnit.Team = owner.User.Team; // Set state spawnedUnit.State = UnitState.Spawned; // Calculate stats spawnedUnit.CalculateStats(); // Set hp to max - auto clamps to max hp spawnedUnit.CurrentHealth = 9999; // Set unit Location spawnedUnit.WorldPosition = GetSpawnForUnit(spawnedUnit); // Notify //RoomInstance.MulticastPacket(new CodeList(spawnedUnit.Skills)); // Send unit info RoomInstance.MulticastPacketWithSession(session => new UnitInfo(spawnedUnit, session)); // Send spawn command RoomInstance.MulticastPacket(new SpawnUnit(spawnedUnit)); // Send status? RoomInstance.MulticastPacket(new StatusChanged(spawnedUnit, true, false, true)); // Call hook AfterUnitSpawned(spawnedUnit, owner); $"Unit Spawned ${unit} - ${unit.Id} - ${owner.User.Team}".Info(); }
/// <summary> /// Spawns a new unit into the game /// </summary> /// <param name="unit"></param> /// <param name="user"></param> protected void SpawnUnit(UnitRecord unit, GameSession owner) { // Create the unit var spawnedUnit = new UserUnit(this, unit, owner); // Add to dictionary _units.TryAdd(unit.Id, spawnedUnit); // Set the current unit to the user owner.CurrentUnit = spawnedUnit; // Set team spawnedUnit.Team = owner.User.Team; // Calculate stats spawnedUnit.CalculateStats(); // Set hp to max - auto clamps to max hp spawnedUnit.CurrentHealth = 9999; // Set unit Location // TODO: Spawn maps? spawnedUnit.WorldPosition = new Vector3(SpawnLocation.X, SpawnLocation.Y, SpawnLocation.Z); // Notify RoomInstance.MulticastPacket(new CodeList(spawnedUnit.Skills)); // Send unit info RoomInstance.MulticastPacket(new UnitInfo(spawnedUnit)); // Send spawn command RoomInstance.MulticastPacket(new SpawnUnit(spawnedUnit)); // Send status? RoomInstance.MulticastPacket(new StatusChanged(spawnedUnit, true, true, true)); // Call hook AfterUnitSpawned(spawnedUnit, owner); }
public static int GetIdByGuid(Guid Guid) { UserUnit UserUnit = UsersMap.Single(x => x.Guid.ToString() == Guid.ToString()); return(UserUnit.Id); }
protected override void AfterUnitSpawned(UserUnit unit, GameSession owner) { }
/// <summary> /// Called after a unit is spawned /// </summary> protected abstract void AfterUnitSpawned(UserUnit unit, GameSession owner);
internal Target(DimensionRecorder dimRec, Object targetObject) { //string[] possibleNames = ijbGeneral.COMInfoProvider.isAsignableToNames(targetObject,typeof(Dimension)); if (!(targetObject is Dimension || targetObject is SketchPoint || targetObject is Feature)) { throw new Exception("Invalid trace object type"); } this.dimRec = dimRec; values = new List<TargetValue>(); this.targetObject = targetObject; //model name string modelName = this.dimRec.iSwApp.IActiveDoc.GetTitle(); modelName = Path.GetFileNameWithoutExtension(modelName);//!!!SW adds '.Part' or '.Assembly' to the full name! //Unit of this value (User units) this.angUnit = (UserUnit)this.dimRec.iSwApp.IActiveDoc.GetUserUnit((int)swUserUnitsType_e.swAngleUnit); this.lengthUnit = (UserUnit)this.dimRec.iSwApp.IActiveDoc.GetUserUnit((int)swUserUnitsType_e.swLengthUnit); //string angUnitName = angUnit.GetFullUnitName(false); //This returns eg. 'Grad' string angUnitName = this.angUnit.GetUnitsString(false); //This returns eg. 'Grad' //string lengthUnitName = lengthUnit.GetFullUnitName(false); //This returns eg. Millimeter' string lengthUnitName = this.lengthUnit.GetUnitsString(false); //This returns eg. 'mm' this.targetComponent = null; if (this.targetObject is Dimension) { Dimension dimension = (Dimension)targetObject; //Unit unitName = (dimension.GetType() == (int)swDimensionParamType_e.swDimensionParamTypeDoubleAngular) ? angUnitName : lengthUnitName; //Name targetName = dimension.FullName; } else if (this.targetObject is SketchPoint) { //Unit //Name SketchPoint sketchPoint = (SketchPoint)targetObject; int[] id = (int[])sketchPoint.GetID(); Sketch sketch = sketchPoint.GetSketch(); string sketchName = this.dimRec.iSwApp.IActiveDoc2.GetEntityName(sketch); targetName = string.Format("{0}{1}@{2}@{3}", Lang.POINT, id[1], sketchName, modelName); } else if (this.targetObject is Feature) { Feature feature = (Feature)targetObject; if (this.dimRec.iSwApp.IActiveDoc is AssemblyDoc) { AssemblyDoc assy = (AssemblyDoc) this.dimRec.iSwApp.IActiveDoc; Entity entity = (Entity)feature; this.targetComponent = entity.IGetComponent2(); } Object specificFeature = feature.GetSpecificFeature2(); if (specificFeature != null && specificFeature is RefPoint) { this.targetObject = specificFeature; RefPoint refPoint = (RefPoint)this.targetObject; string refPointName = this.dimRec.iSwApp.IActiveDoc2.GetEntityName(refPoint); targetName = string.Format("{0}@{1}", refPointName, modelName); } else { throw new Exception("Invalid trace object type"); } //Unit unitName = lengthUnitName; } }
public string IconFor(UserUnit unit) { Dictionary <int, string> iconMap = new() { { 1, "icons/W_Sword006.png" }, { 2, "icons/S_Bow08.png" },