void Fight() { List <SkillModel> skillsUsable = new List <SkillModel>(); //create a list of skill with PP > 0 foreach (SkillModel skill in fightManager.currentEnemyPokemon.CurrentSkills) { if (skill.CurrentPP > 0) { skillsUsable.Add(skill); } } //if every skill has PP 0 then use baseSkill if (skillsUsable.Count < 1) { fightManager.UseSkill(new SkillModel(fightManager.baseSkill)); } //else select a random skill else { SkillModel skillToUse = skillsUsable[Random.Range(0, skillsUsable.Count)]; fightManager.UseSkill(skillToUse); } }
private void OnSkillUp(OperationResponse response) { int playerId = (int)response[0]; SkillModel data = JsonMapper.ToObject <SkillModel>(response[1].ToString()); //先获取控制器 BaseControl con = idControlDict[playerId]; HeroModel model = con.Model as HeroModel; //遍历英雄技能 for (int i = 0; i < model.Skills.Length; i++) { if (model.Skills[i].Id != data.Id) { continue; } model.Skills[i] = data; //刷新技能显示 if (con == GameData.myControl) { model.SkillPoints--; view.UpdateSkills(model); } break; } }
public void AddSkill_WhenDataIsValid_ShouldSaveInDatabase() { using (new TransactionScope()) { this.db.Users.Add(this.user); this.db.SaveChanges(); var skill = new SkillModel() { Name = "asd" }; var response = this.httpServer.CreatePostRequest( string.Format( "/api/skills/add?sessionKey={0}", this.user.SessionKey), skill); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); var data = this.GetSkillModelFromResponse(response); Assert.AreEqual("asd", data.Name); Assert.IsTrue(data.Id > 0); var skillEntity = this.db.Skills .All() .Where(s => s.Users.Any(u => u.Id == this.user.Id)) .FirstOrDefault(); Assert.IsNotNull(skillEntity); } }
/// <summary> /// 更新技能 /// </summary> /// <param name="hero"></param> public void UpdateSkills(HeroModel hero) { for (int i = 0; i < hero.Skills.Length; i++) { SkillModel skill = hero.Skills[i]; //当这个heromodel 达到了 一个技能可以加点的等级 我们就让这个升级按钮显示 if (hero.Level > skill.LearnLevel) { //要显示升级按钮 if (hero.Points > 0) { skills[i].UpInteractable = true; } else { skills[i].UpInteractable = false; } } else { skills[i].UpInteractable = false; } //保存这个技能的信息 skills[i].Skill = skill; //隐藏遮罩 重置技能 skills[i].Reset(); } }
public void RemoveSkill_WhenDataIsValid_ShouldRemoveSkillFromUser() { using (new TransactionScope()) { this.db.Users.Add(this.user); this.db.SaveChanges(); var skill = new Skill() { Name = "name" }; this.user.Skills.Add(skill); this.db.Users.Update(this.user); this.db.SaveChanges(); var skillModel = new SkillModel() { Id = skill.Id }; var response = this.httpServer.CreatePutRequest( string.Format("/api/skills/remove?sessionKey={0}", this.user.SessionKey), skillModel); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); var skillEntity = this.db.Skills .All() .Where(s => s.Users.Any(u => u.Id == this.user.Id)) .FirstOrDefault(); Assert.IsNull(skillEntity); } }
public void RemoveSkill_WhenSessionKeyIsInvalid_ShouldReturnBadRequest() { using (new TransactionScope()) { this.db.Users.Add(this.user); this.db.SaveChanges(); var skill = new Skill() { Name = "name" }; this.user.Skills.Add(skill); this.db.Users.Update(this.user); this.db.SaveChanges(); var skillModel = new SkillModel() { Id = skill.Id }; var response = this.httpServer.CreatePutRequest( string.Format("/api/skills/remove?sessionKey={0}", "invalid session key"), skillModel); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); } }
/// <summary> /// 分析技能效果 转换为处理对象 /// </summary> /// <param name="key"></param> /// <param name="skill"></param> private SkillHandler[] ParseSkill(SkillModel skill) { // 创建处理对象数组 保存不同的等级 SkillHandler[] skillHandlers = new SkillHandler[skill.LvData.Length]; for (int i = 0; i < skillHandlers.Length; i++) { // 创建每一级的处理对象 SkillHandler skillHandler = new SkillHandler(skill.Id); EffectModel[] effects = skill.LvData[i].EffectData; skillHandler.Effects = new EffectModel[effects.Length]; // 遍历技能效果 for (int j = 0; j < effects.Length; j++) { EffectModel effect = effects[j]; skillHandler.Effects[j] = effect; // 判断效果类型 将相应的处理添加到委托里 EffectHandler handler = SkillHandlerData.HandlerDict.ExTryGet(effect.Type); if (handler != null) { skillHandler.Handler += handler; } } skillHandlers[i] = skillHandler; } return(skillHandlers); }
public ActionResult DeleteSkill(SkillModel model) { try { #region " [ Declaration ] " SkillService _service = new SkillService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; model.DeleteBy = UserID; model.DeleteDate = DateTime.Now; #endregion //Call to service return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "DeleteSkill", UserID, ex); } }
public HttpResponseMessage AddSkill( [FromBody] SkillModel model, [FromUri] string sessionKey) { var responseMsg = this.PerformOperationAndHandleExceptions(() => { this.ValidateSkillName(model.Name); var user = this.GetUserBySessionKey(sessionKey); var skill = this.db.Skills.All() .FirstOrDefault(s => s.Name.ToLower() == model.Name.Trim().ToLower()); if (skill == null) { skill = new Skill() { Name = model.Name.Trim() }; } user.Skills.Add(skill); this.db.Users.Update(user); this.db.SaveChanges(); var returnData = new SkillModel() { Id = skill.Id, Name = skill.Name }; var response = this.Request.CreateResponse(HttpStatusCode.Created, returnData); return(response); }); return(responseMsg); }
private void Start() { photonView = GetComponent <PhotonView>(); Destroy(gameObject, float.Parse(photonView.InstantiationData[0].ToString())); model = (JsonMapper.ToObject <ActorModel>(photonView.Owner.CustomProperties["model"].ToString())).GetSkillModel(skill_id); }
public async Task <IHttpActionResult> UpdateSkill(int userId, int skillId, SkillModel model) { try { var profile = await _profileRepo.FirstOrDefaultAsync(p => p.UserId == userId, include : "Skills.Skill"); if (profile == null) { return(NotFound()); } var skill = profile.Skills.FirstOrDefault(s => s.SkillId == skillId); if (skill == null) { return(NotFound()); } skill.Rating = model.Rating; _userSkillRepo.Update(skill); await _userSkillRepo.SaveChangesAsync(); return(Ok(new UserSkillViewModel { SkillId = skill.SkillId, UserId = userId, Rating = skill.Rating, Name = skill.Skill.Name })); } catch (Exception) { return(InternalServerError()); } }
public void Setup() { _skillsService = A.Fake <ISkillsService>(); _autoMapper = A.Fake <IAutoMapper>(); _skillModel = new SkillModel(_skillsService, _autoMapper); }
public void UpdateModel() { model = ActorModel.Model.equip_skil[skill_joy_stick_id]; if (model == null) { isDisable = true; skill_image.gameObject.SetActive(false); } else { isDisable = false; skill_image.gameObject.SetActive(true); skill_image.sprite = model._config.GetSprite(); cool_timer = model.GetCoolTime(); if (model._config.skill_type == SkillType.点击) { isDrag = false; } else { isDrag = true; } } }
/// <summary> /// 更新技能 /// </summary> /// <param name="model"></param> public void UpdateSkills(HeroModel model) { //更新技能列表 for (int i = 0; i < model.Skills.Length; i++) { SkillModel skill = model.Skills[i]; if (model.Level >= skill.LearnLevel) { //要显示升级按钮 if (model.SkillPoints > 0) { skills[i].UpInteractable = true; } else { skills[i].UpInteractable = false; } } else { skills[i].UpInteractable = false; } //保存技能的信息 skills[i].Skill = skill; //隐藏遮罩 skills[i].Reset(); } }
public void AddSkillTest() { var request = new SkillModel { Skill_Id = 0, Skill_Name = "TestSkill", Associate_Skills = null }; var response = new SkillModel(); var skillController = new SkillController(_skillsService, _logManager) { Request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri(ServiceBaseURL + "skill/addSkill") } }; skillController.Configuration = new HttpConfiguration(); _response = skillController.AddSkill(request); response = JsonConvert.DeserializeObject <SkillModel>(_response.Content.ReadAsStringAsync().Result); Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK); Assert.AreEqual(response != null, true); Assert.Greater(response.Skill_Id, 0); }
/// <summary> /// Get item by id and owner /// </summary> /// <param name="model">skill model</param> /// <returns>MoneyAccountModel. Throw exception if not found or get some error</returns> public SkillModel GetItemByID(SkillModel model) { try { using (var _context = new TDHEntities()) { CM_SKILL _md = _context.CM_SKILL.FirstOrDefault(m => m.id == model.ID && !m.deleted && m.created_by == model.CreateBy); if (_md == null) { throw new DataAccessException(FILE_NAME, "GetItemByID", model.CreateBy); } var _return = new SkillModel() { ID = _md.id, Name = _md.name, Ordering = _md.ordering, Notes = _md.notes }; return(_return); } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "GetItemByID", model.CreateBy, ex); } }
public DtoHero(int id, int typeId, int team, int maxHp, int attack, int defense, double attackDistance, double attackInterval, string name, int maxMp, double speed, int[] skillIds) : base(id, typeId, team, maxHp, attack, defense, attackDistance, attackInterval, speed, name) { CurMp = MaxMp = maxMp; Level = 1; Exp = 0; Money = 500; SkillIds = skillIds; SP = 1; Kill = 0; Death = 0; // 初始化装备id为-1 Equipments = new int[ServerConfig.ItemMaxCount]; for (int i = 0; i < Equipments.Length; i++) { Equipments[i] = -1; } // 初始化技能 Skills = new DtoSkill[SkillIds.Length]; for (int i = 0; i < SkillIds.Length; i++) { SkillModel model = SkillData.GetSkill(SkillIds[i]); if (model != null) { Skills[i] = new DtoSkill(model, 0); } } }
/// <summary> /// Check Delete /// </summary> /// <param name="model">Skill model</param> /// <returns>ResponseStatusCodeHelper</returns> public ResponseStatusCodeHelper CheckDelete(SkillModel model) { try { using (var _context = new TDHEntities()) { CM_SKILL _md = _context.CM_SKILL.FirstOrDefault(m => m.id == model.ID && !m.deleted && m.created_by == model.CreateBy); if (_md == null) { throw new DataAccessException(FILE_NAME, "CheckDelete", model.CreateBy); } var _skills = _context.PN_SKILL.FirstOrDefault(m => m.skill_id == model.ID && !m.deleted); if (_skills != null) { Notifier.Notification(model.CreateBy, Message.CheckExists, Notifier.TYPE.Warning); return(ResponseStatusCodeHelper.NG); } } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "CheckDelete", model.CreateBy, ex); } return(ResponseStatusCodeHelper.OK); }
public ActionResult Create(SkillModel skill) { if (ModelState.IsValid) { var newSkill = new Skill { Name = skill.Name, Desc = skill.Desc, Min = skill.Min, Max = skill.Max }; // related skills foreach (var id in skill.SelectedSkillIds) { var relSkill = db.Skills.Single(x => x.Id == id); newSkill.AddSkillRelation(relSkill); } // related Labors foreach (var id in skill.SelectedLaborIds) { var relLab = db.Products.Single(x => x.Id == id); newSkill.ValidLabors.Add(relLab); relLab.Skills.Add(newSkill); } // do not connect to jobs here. Jobs should decide who they relate to. db.Skills.Add(newSkill); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(skill)); }
// Constructor public ActiveListedSkill(SkillModel skill) { SkillModel = skill; RankLevel = 0; TotalPoint = 0; switch (skill.Type.Difficulty) { case Difficulty.Easy: Modifier = -1; break; case Difficulty.Average: Modifier = -2; break; case Difficulty.Hard: Modifier = -3; break; } IncSkillRankCommand = new DelegateCommand((x) => IncRankExecute(), (x) => true); DecSkillRankCommand = new DelegateCommand((x) => DecRankExecute(), (x) => DecRankCanExecute()); //UpdateDescriptionCommand = new DelegateCommand(x => UpdateDescriptionExecute(x), x => true); }
// POST: api/Skills public GenericResponse <string> PostSkill(SkillModel skill) { //TODO: THIS VALIDATION CAN BE EXTRACTED INTO A VALIDATION METHOD FOR REUSABILITY if (!ModelState.IsValid) { return(new GenericResponse <string> { StatusCode = 400, Message = "BAD REQUEST" }); } if (service.AddSkill(skill) == 1) { return(new GenericResponse <string> { StatusCode = 200, Message = "NO CONTENT" }); } return(new GenericResponse <string> { StatusCode = 500, Message = "SERVER ERROR" }); }
public SkillRepository() { skillModels [0] = new SkillModel( 0, "LineSkill", "Line", new string[5] { "10", "9", "8", "7", "6" } ); skillModels [1] = new SkillModel( 1, "RangeSkill", "Range", new string[5] { "10", "9", "8", "7", "6" } ); skillModels [2] = new SkillModel( 2, "SummonSkill", "Summon", new string[5] { "10", "9", "8", "7", "6" } ); }
/// <summary> /// 同步技能动画(不计算伤害,就是显示动画的) /// </summary> /// <param name="target"></param> public override void SkillResponse(int skillId, Transform target, Vector3 targetPos) { switch (skillId) { case 1001: break; case 1002: break; case 1003: targetPos.y = transform.position.y; transform.LookAt(targetPos); //加载技能攻击特效 GameObject go = PoolManager.Instance.GetObject("E"); SkillModel model = ((HeroModel)this.Model).Skills[2]; go.GetComponent <LineSkill>().Init(transform, (float)model.Distance, 8f, skillId, this.Model.Id, this == GameData.myControl); break; case 1004: break; default: break; } }
public GenericResponse <string> PutSkill(int id, SkillModel skill) { if (!ModelState.IsValid) { return(new GenericResponse <string> { StatusCode = 400, Message = "BAD REQUEST" }); } if (id != skill.Id) { return(new GenericResponse <string> { StatusCode = 400, Message = "BAD REQUEST" }); } var result = new GenericResponse <string> { StatusCode = service.UpdateSkill(id, skill) }; return(result); }
/// <summary> /// 技能升级 /// </summary> /// <param name="playerId"></param> /// <param name="skillModel"></param> private void onSkillUp(int playerId, SkillModel skillModel) { //先获取控制器 BaseControl con = idControlDict[playerId]; //遍历英雄的技能 for (int i = 0; i < ((HeroModel)con.Model).Skills.Length; i++) { SkillModel skill = ((HeroModel)con.Model).Skills[i]; //如果不是我们要点的技能 直接下一次循环 if (skill.Id != skillModel.Id) { continue; } //如果是 直接赋值就行 ((HeroModel)con.Model).Skills[i] = skillModel; //刷新这个技能显示 if (con == GameData.MyControl) { view.UpdateSkills((HeroModel)con.Model); } break; } }
private void OnBattleStartMessage(NetworkMessage netMsg) { netMsg.reader.SeekZero(); BattleStartMessage msg = netMsg.ReadMessage <BattleStartMessage>(); PokemonModel pModel = PublicDataManager.instance.GetPokemonModel(msg.pokemonId); Debug.Log("Opp Pokemon" + pModel.name_ch); pModel.attack = msg.attackAv; pModel.defense = msg.defenceAv; pModel.hp = msg.hpAv; pModel.sp_attack = msg.sp_attackAv; pModel.sp_defense = msg.sp_defenceAv; pModel.speed = msg.speedAv; CharacterModel cModel = PublicDataManager.instance.GetCharacterModel(msg.charavterId); PersonalityModel perModel = PublicDataManager.instance.GetPersonalityModel(msg.personalityId); ItemModel iModel = PublicDataManager.instance.GetItemModel(msg.itemId); SkillModel[] sModel = new SkillModel[4]; for (int i = 0; i < msg.skillIds.Length; i++) { sModel[i] = PublicDataManager.instance.GetSkillModel(msg.skillIds[i]); } Pokemon p = new Pokemon(pModel, cModel, perModel, iModel, sModel); RuntimeData.SetCurrentOppIndex(msg.index); RuntimeData.SetCurrentOppPokemon(p); if (RuntimeData.IsOppPokemonsFull()) { UIManager.instance.ClosePage(PageCollection.StartPage); UIManager.instance.OpenPage(PageCollection.BattlePage); } }
public Task InsertSkill(SkillModel skill) { var sql = @"INSERT INTO KaydenMiller.dbo.Skills (SkillCategoryId, Name, Description, PersonalStarRating, Tooltip) VALUES (@SkillCategoryId, @Name, @Description, @PersonalStarRating, @Tooltip);"; return(_db.InsertData(sql, skill)); }
/// <summary> /// get damage and add effect (if skill has one) /// </summary> public void GetDamage(SkillModel skill, PokemonModel pokemonWhoAttack, out string efficiencyText) { int random = Random.Range(0, 100); int accuracy = Mathf.Min(CurrentMaxAccuracy, skill.skillData.Accuracy); //try to hit enemy if (random < accuracy) { //get attack and defense, based to the skill if special or physics float attack = skill.skillData.IsSpecial ? pokemonWhoAttack.SpecialAttack : pokemonWhoAttack.PhysicsAttack; float defense = skill.skillData.IsSpecial ? SpecialDefense : PhysicsDefense; //get multipliers -> out efficiencyText float efficiencyMultiplier = skill.EfficiencyMultiplier(pokemonData.PokemonType, out efficiencyText); float stab = skill.STAB(pokemonWhoAttack.pokemonData.PokemonType); float nRandom = skill.NRandom(); //((( (2 * Livello Pokemon + 10) * Attacco Pokemon * Potenza Mossa ) / (250 * Difesa Fisica o Difesa Speciale del Nemico)) +2 ) * Efficacia * STAB * N float damage = ((((2 * pokemonWhoAttack.CurrentLevel + 10) * attack * skill.skillData.Power) / (250 * defense)) + 2) * efficiencyMultiplier * stab * nRandom; //if the skill has one, add effect to the list AddEffect(skill.skillData.Effect); //apply effective damage CurrentHealth -= damage; return; } //else miss efficiencyText = "Ups, mancato!"; }
void skill_3002() { cur_3002_num++; Vector3 pos = cur_3002_pos + cur_3002_forward * 2f * cur_3002_num; float x = UnityEngine.Random.Range(0f, 1f); float z = UnityEngine.Random.Range(0f, 1f); pos.x = pos.x + x; pos.z = pos.z + z; GameObject fx_inst = GameObject.Instantiate(MAGE_S3002, pos, transform.rotation) as GameObject; fx_inst.transform.SetParent(U3DAPI.FX_POOL_TF, false); Destroy(fx_inst, 0.5f); HitData hd = m_monRole.Build_PRBullet(3002, 1.0f, SceneTFX.m_Bullet_Prefabs[3], pos, transform.rotation); hd.m_nDamage = 1088; // hd.m_Color_Main = Color.gray; hd.m_Color_Main = SkillModel.getskill_mcolor(3002); //hd.m_Color_Rim = Color.white; hd.m_Color_Rim = SkillModel.getskill_rcolor(3002); hd.m_nHurtFX = 1; if (cur_3002_num >= 6) { CancelInvoke("skill_3002"); } }
public void onBullet_3003(Vector3 pos, Quaternion rotation) { //冰雹术 pos.z += UnityEngine.Random.Range(-3f, 3f); pos.x += UnityEngine.Random.Range(-3f, 3f); pos.y = 16f + pos.y; GameObject bult = GameObject.Instantiate(P3Mage_Event.MAGE_B3, pos, rotation) as GameObject; bult.transform.SetParent(U3DAPI.FX_POOL_TF, false); Transform real_track = bult.transform.FindChild("t"); if (real_track != null) { HitData hd = Link_PRBullet(3003, 2f, bult, real_track); hd.m_nHurtSP_type = 11; hd.m_nHurtSP_pow = 1; hd.m_nDamage = 177; //hd.m_Color_Main = Color.blue; hd.m_Color_Main = SkillModel.getskill_mcolor(3003); // hd.m_Color_Rim = Color.white; hd.m_Color_Rim = SkillModel.getskill_rcolor(3003); hd.m_aniTrack = real_track.GetComponent <Animator>(); real_track.gameObject.layer = EnumLayer.LM_BT_FIGHT; Transform real_fx = real_track.FindChild("f"); if (real_fx != null) { hd.m_aniFx = real_fx.GetComponent <Animator>(); } } }
void Update() { if(Input.GetKeyDown(KeyCode.Alpha1)) { SkillModel model = new SkillModel(); model.type = (SkillType)Random.Range((int)SkillType.FIGHTER_ATTACK, (int)SkillType.MONK_KICK); model.level = Random.Range(1, 3); model.cost = Random.Range(1, 10); model.maxCool = Random.Range(1, 5); model.curCool = Random.Range(0, model.maxCool); SetSkillUI(model); } if(Input.GetKeyDown(KeyCode.Alpha2)) { Reset(); } }
public ActionResult Cadastrar(SkillModel skill) { try { if (ModelState.IsValid) { db.Skills.Add(skill); db.SaveChanges(); TempData.Add("success", "Skill criado com sucesso!"); return RedirectToAction("Index"); } } catch (Exception) { ModelState.AddModelError(string.Empty, "Não foi possível salvar as alterações. Tente novamente, se o problema persistir, procure o Administrador."); throw; } return View(skill); }
public void SetSkillUI(SkillModel model) { if (model.type == SkillType.NUM) { Reset(); return; } isUsing = true; skillSprite.sprite2D = uiManager.GetSkillSprite(model.type); description.text = uiManager.GetSkillDesc(model.type); skillLevel.SetLevel(model.level); skillCost.SetCost(model.cost); if(model.isAvailable) { skillCoolDown.SetCoolDown(model.curCool, model.maxCool); } else { skillCoolDown.CoolOff(); } }
public ActionResult Atualizar(SkillModel skill) { if (ModelState.IsValid) { db.Skills.Attach(skill); var entry = db.Entry(skill); entry.Property(p => p.Name).IsModified = !string.IsNullOrEmpty(skill.Name); try { db.SaveChanges(); TempData.Add("success", "Skill atualizado com sucesso!"); return RedirectToAction("Index"); } catch (DataException) { ModelState.AddModelError(string.Empty, "Não foi possível salvar as alterações. Tente novamente, se o problema persistir, procure o Administrador."); } } return View("Cadastrar", skill); }