public async Task <IActionResult> Edit(int id, [Bind("SkillId,CharacterId,SkillName,AreaOfEffect,HasAttributePrereq")] CharacterSkill characterSkill) { if (id != characterSkill.SkillId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(characterSkill); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CharacterSkillExists(characterSkill.SkillId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(characterSkill)); }
private void skillSelected(CharacterSkill skill, int selectedIndex) { CharacterAttribute attribute = NeverdawnDatabase.GetAttribute(skill.baseAttribute); UIQuickMenuSkillUp skillUp = Instantiate(skillUpPrefab); int level = avatarController.character.GetSkillLevel(skill.type); skillUp.label = skill.label; skillUp.description = skill.description; skillUp.baseValue = level; skillUp.attributeValue = avatarController.character.GetAttributeLevel(attribute.type); skillUp.equipmentValue = avatarController.character.mannequin ? avatarController.character.mannequin.GetSkillBonus(skill.type) : 0; skillUp.foodValue = avatarController.character.GetFoodBonus(skill.type); skillUp.cost = NeverdawnDatabase.GetUpgradeCost(skill.type, level); skillUp.learningPoints = avatarController.character.skillable.learningPoints; skillUp.showAttributes = true; skillUp.attributeColor = attribute.color; skillUp.attributeLabel = attribute.label; skillUp.confirm.interactable = avatarController.character.skillable.learningPoints >= NeverdawnDatabase.GetUpgradeCost(skill.type, level); skillUp.confirm.onClick.AddListener(() => skillUpSkill(skillUp, skill.type)); this.selectedIndex = selectedIndex; menu.NavigateInto(skillUp); }
private void FillOutCharacterSkillControls(CharacterSkill objCharSkill, int intArmorProfPenalty) { if (csc1.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc1, intArmorProfPenalty); } else if (csc2.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc2, intArmorProfPenalty); } else if (csc3.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc3, intArmorProfPenalty); } else if (csc4.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc4, intArmorProfPenalty); } else if (csc5.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc5, intArmorProfPenalty); } else if (csc6.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc6, intArmorProfPenalty); } else if (csc7.SkillName == "") { FillOutCharacterSkillControl(objCharSkill, csc7, intArmorProfPenalty); } }
public async Task <ServiceWrapper <GetCharacterDTO> > AddSkill(AddSkillDTO skill) { ServiceWrapper <GetCharacterDTO> response = new ServiceWrapper <GetCharacterDTO>(); try{ Character character = await _context.Characters.Include(w => w.Weapon) .Include(c => c.CharacterSkills).ThenInclude(cs => cs.Skill) .FirstOrDefaultAsync(c => c.Id == skill.CharacterId && c.User.id == GetUserId()); if (character == null) { response.DidSend = false; response.Message = "Character not found."; return(response); } Skill skillToAdd = await _context.Abilities.FirstOrDefaultAsync(s => s.Id == skill.SkillId); CharacterSkill CharSkill = new CharacterSkill { Skill = skillToAdd, Character = character, }; await _context.CharactersSkills.AddAsync(CharSkill); await _context.SaveChangesAsync(); response.Data = _mapper.Map <GetCharacterDTO>(character); }catch (Exception ex) { response.DidSend = false; response.Message = ex.Message; } return(response); }
public async Task HandleAsync(LearnSkillCommand command) { var character = await _unitOfWork.Characters.Query .Where(x => x.UserId == command.UserId) .Where(x => x.Id == command.CharacterId) .SingleAsync(); if (character.CharacterSkills.Count >= 3) { throw new ServiceException("Character must unlearn a skill before learning another"); } if (character.CharacterSkills.Any(x => x.SkillId == command.SkillId)) { throw new ServiceException("Character has already learned this skill"); } var skill = await _unitOfWork.Skills.Query .Where(x => x.UserId == command.UserId) .Where(x => x.Id == command.SkillId) .SingleAsync(); var characterSkill = new CharacterSkill { CharacterId = character.Id, Character = character, SkillId = skill.Id, Skill = skill }; _unitOfWork.CharacterSkills.Create(characterSkill); }
public SkillSlot(CharacterSkill skill) { this.skill = skill; hasRecovered = true; fadingSpeed = 1 / skill.Cooldown; }
/// <summary> /// When a skill is casted this function is called. /// </summary> /// <param name="order">Order of the skill in the skill set.</param> /// <param name="characterSkill">Skill data</param> public void CastSkill(int order, CharacterSkill characterSkill) { ISkillStrategy skillStrategy = null; switch (characterSkill.Code) { case SkillCode.TripleShot: skillStrategy = new UpgradeToTripleShot(); break; case SkillCode.DoubleShot: skillStrategy = new UpgradeToDoubleShot(); break; case SkillCode.Haste: skillStrategy = new UpgradeAttackSpeed(new AdditionModifier(-1f, characterSkill.Name)); break; case SkillCode.UberBolt: skillStrategy = new UpgradeProjectileSpeed(new MultiplicationModifier(0.5f, characterSkill.Name)); break; case SkillCode.Clone: skillStrategy = new CloneTheCharacterRandomly(); break; } Skill skill = new Skill(skillStrategy); skill.Perform(); OnSkillCast?.Invoke(order, ++_skillsCastedSoFar); }
public override void CopyValues(ScrObjLibraryEntry other) { base.CopyValues(other); CharacterSkill cs = (CharacterSkill)other; icon = cs.icon; description = cs.description; activationType = cs.activationType; chance = cs.chance; percent = cs.percent; value = cs.value; boost = new Boost(); boost.AddBoost(cs.boost); includeSelf = cs.includeSelf; range = cs.range; rangeMax = cs.rangeMax; enemyCanAttack = cs.enemyCanAttack; weaponReq = cs.weaponReq; terrainReq = new List <TerrainTile>(); for (int i = 0; i < cs.terrainReq.Count; i++) { terrainReq.Add(cs.terrainReq[i]); } }
private void ZoneHit(int Castingid, short x, short y) { List <CharacterSkill> skills = Session.Character.UseSp ? Session.Character.SkillsSp.GetAllItems() : Session.Character.Skills.GetAllItems(); CharacterSkill characterSkill = skills.FirstOrDefault(s => s.Skill.CastId == Castingid); if (!Session.Character.WeaponLoaded(characterSkill) || !Session.HasCurrentMap) { Session.SendPacket("cancel 2 0"); return; } if (characterSkill != null && characterSkill.CanBeUsed()) { if (Session.Character.Mp >= characterSkill.Skill.MpCost) { Session.CurrentMap?.Broadcast($"ct_n 1 {Session.Character.CharacterId} 3 -1 {characterSkill.Skill.CastAnimation} {characterSkill.Skill.CastEffect} {characterSkill.Skill.SkillVNum}"); characterSkill.LastUse = DateTime.Now; if (!Session.Character.HasGodMode) { Session.Character.Mp -= characterSkill.Skill.MpCost; } Session.SendPacket(Session.Character.GenerateStat()); characterSkill.LastUse = DateTime.Now; Observable.Timer(TimeSpan.FromMilliseconds(characterSkill.Skill.CastTime * 100)) .Subscribe( o => { Session.Character.LastSkillUse = DateTime.Now; Session.CurrentMap?.Broadcast($"bs 1 {Session.Character.CharacterId} {x} {y} {characterSkill.Skill.SkillVNum} {characterSkill.Skill.Cooldown} {characterSkill.Skill.AttackAnimation} {characterSkill.Skill.Effect} 0 0 1 1 0 0 0"); IEnumerable <MapMonster> monstersInRange = Session.CurrentMap?.GetListMonsterInRange(x, y, characterSkill.Skill.TargetRange).ToList(); if (monstersInRange != null) { foreach (MapMonster mon in monstersInRange.Where(s => s.CurrentHp > 0)) { mon.HitQueue.Enqueue(new GameObject.Networking.HitRequest(TargetHitType.ZoneHit, Session, characterSkill.Skill, x, y)); } } }); Observable.Timer(TimeSpan.FromMilliseconds(characterSkill.Skill.CastTime * 100)) .Subscribe( o => { Session.SendPacket($"sr {Castingid}"); }); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MP"), 10)); Session.SendPacket("cancel 2 0"); } } else { Session.SendPacket("cancel 2 0"); } }
public void AddSkill(CharacterSkill skill) { if (!skill.Name.ContainsIgnoreCase("perform")) { throw new System.ArgumentException("Must be a perform skill for versatile performance"); } skills.Add(skill); }
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context) { CharacterSkill data = (CharacterSkill)obj; info.AddValue("dataId", data.dataId); info.AddValue("level", data.level); }
public BookRecordData(System.IO.BinaryReader reader) { weight = reader.ReadSingle(); value = reader.ReadInt32(); flags = (BookFlags)reader.ReadInt32(); skillID = (CharacterSkill)reader.ReadInt32(); enchantPoints = reader.ReadInt32(); }
public static CharacterSkill Create(Skill skill, short level) { CharacterSkill newSkill = new CharacterSkill(); newSkill.dataId = skill.DataId; newSkill.level = level; return(newSkill); }
private void PlayHitEffects(Vector2 position, CharacterSkill skill) { /*VisualEffectManager.Instance.CreateEffect("VisualEffects/hitTest", position, 100); if (Globals.GoreEnabled) { VisualEffectManager.Instance.CreateEffect("VisualEffects/blood2", position, 200); }*/ if (skill.HitSoundEffect != null) { SoundEffectManager.Instance.PlaySoundFromPosition(position, skill.HitSoundEffect); } }
private void InflictDebuffs(Character subject, CharacterSkill skill, Constants.DirectionX direction) { //if (skill.InflictForce != Vector2.Zero) //{ mass.X = skill.InflictForce.X > 0 ? subject.Mass * 0.033f : 0; mass.Y = skill.InflictForce.Y != 0 ? subject.Mass * 0.033f : 0; force.X = direction == Constants.DirectionX.Left ? -skill.InflictForce.X + mass.X : skill.InflictForce.X - mass.X; force.Y = skill.InflictForce.Y + mass.Y; subject.ChangeVelocity(force.X, force.Y, "Character Skill Force"); //if(CollisionHandler.CollisionOccursWithMap(subject, force) != subject.BoundingBox.Top) //subject.AdjustPosition(new Vector2(0, force.Y)); if (skill.InflictForce.Length() >= subject.KnockBackTreshold) { subject.state = Constants.CharacterState.Knocked; //textManager.AddText(new FloatingText("Knocked!", Constants.FloatingTextType.Emphasised, subject.Position - new Vector2(0, subject.BoundingBox.Height / 2))); } if (subject.ActiveSkill != null && force.Length() >= subject.ActiveSkill.ForceInterruptTreshold && subject.ActiveSkill.ForceInterruptTreshold != -1) { subject.ActiveSkill.Cancel(); CombatLog.Add(subject.Name + " was interrupted!"); textManager.AddText(new FloatingText("Interrupted!", Constants.FloatingTextType.Emphasised, subject.Position - new Vector2(0, subject.BoundingBox.Height / 2))); subject.state = Constants.CharacterState.Knocked; } //} }
private void InflictDamage(Character subject, CharacterSkill skill) { float damage = skill.Damage; if (damage < skill.Damage) { CombatLog.Add(subject.Name + " resisted " + (int)(skill.Damage - damage) + " damage."); } else if (damage > skill.Damage) { CombatLog.Add("Critical hit!"); } subject.TakeDamage(damage); textManager.AddText(new FloatingText("-" + damage, Constants.FloatingTextType.Normal, subject.Position - new Vector2(0, subject.BoundingBox.Height / 2))); }
private void ApplyHealing(Character subject, CharacterSkill skill) { subject.ApplyHealing(skill.Healing); }
private void AdjustResources(Character subject, CharacterSkill skill) { subject.CurrentSkillResource -= player.ActiveSkill.Cost; }