private void TryToUseSkill(ActionDisplay nearestEnemy) { SkillController skillController = MeController.SkillController; Vector3 mePos = MeController.transform.position; Vector3 enemyPos = nearestEnemy.Controller.transform.position; if (MeController.StatuController.CurrentStatu == Status.IDLE) { int dir = mePos.x < enemyPos.x ? Directions.Right : Directions.Left; //朝向最近的敌人 MeController.Me.ChangeDire(dir); } for (int i = SkillController.Skill1; i <= SkillController.Skill4; i++) { if (skillController.LearnedSkillList[i] == 0) { continue; //已学会的技能列表 } if (skillController.IsSkillCdReady(i)) { SysSkillBaseVo skillVo = BaseDataMgr.instance.GetSysSkillBaseVo(skillController.LearnedSkillList[i]); if (DamageCheck.Instance.IsSkillCovered(skillVo, mePos, mePos, nearestEnemy.Controller.transform.position, MeController.Me.CurDire, (MeController.Me as ActionDisplay).BoxCollider2D, nearestEnemy.BoxCollider2D)) { skillController.RequestUseSkill(i); // 请求使用技能 break; } } } }
/// <summary> /// Plays the sound for an <see cref="ActionDisplay"/> in a very basic way. /// This is intended to be called by the scripts for playing sound instead of handling sound manually. /// </summary> /// <param name="actionDisplay">The <see cref="ActionDisplay"/>.</param> /// <param name="source">The source of the sound.</param> static void PlaySoundSimple(ActionDisplay actionDisplay, ISpatial source) { // Check for valid parameters if (actionDisplay == null) { Debug.Fail("actionDisplay must not be null."); return; } if (source == null) { Debug.Fail("source must not be null."); return; } // Make sure there is a valid sound if (!actionDisplay.Sound.HasValue) { return; } // When possible, attach the sound to the source. Otherwise, just play it where the source is currently at var attackerAsAudioEmitter = source as IAudioEmitter; if (attackerAsAudioEmitter != null) { _audioManager.SoundManager.Play(actionDisplay.Sound.Value, attackerAsAudioEmitter); } else { _audioManager.SoundManager.Play(actionDisplay.Sound.Value, source.Center); } }
void IProjectView.ShowView(FilteredProject project) { _region.SwitchTo("project-view"); this.Sync(() => { _project = project.Info.ProjectId; _projectName.Text = string.Format("{0} ({1})", project.Info.Outcome, project.ActionCount); // TODO: smarter update for the case when we remove item if (_source.Count == project.FilteredActions.Count) { for (int i = 0; i < project.FilteredActions.Count; i++) { _source[i] = new ActionDisplay(project.FilteredActions[i], this); } return; } _source.Clear(); foreach (var action in project.FilteredActions) { _source.Add(new ActionDisplay(action, this)); } }); }
/// <summary> /// 计算和敌人的距离 /// </summary> /// <param name="enemyDisplay"></param> /// <returns></returns> private float GeteEnemyDistance(ActionDisplay enemyDisplay) { Vector3 mePos = _meTransform.position; Vector3 enemyPos = enemyDisplay.Controller.transform.position; return((mePos.x - enemyPos.x) * (mePos.x - enemyPos.x) + (mePos.y - enemyPos.y) * (mePos.y - enemyPos.y)); }
public void ActionMappingSucceeds() { var uri = new Uri("https://rprcorporate.blob.core.windows.net/media/sampletrophy.png?sp=rl&st=2021-03-28T19:06:34Z&se=2025-03-29T19:06:00Z&sv=2020-02-10&sr=b&sig=M3oKCysFeKGWw7jDnn1kCFNTFHdqxoOtKVzVFIYXXZs%3D"); var a = new Action().ToMock(uri); var ad = new ActionDisplay().Map(a); Assert.IsTrue(a.SimpleName == ad.SimpleName); Assert.IsTrue(a.ActionId == ad.ActionId); }
/// <summary> /// 移动和怪物同一Y值 /// </summary> /// <param name="enemyDisplay"></param> private void MoveToTheSameYWithEnemy(ActionDisplay enemyDisplay) { Vector3 targetPoint = _meTransform.position; targetPoint.y = enemyDisplay.Controller.transform.position.y; var actionVo = new ActionVo { RunDestination = targetPoint, ActionType = Actions.RUN }; MeController.AttackController.AddAttackList(actionVo); }
public static ActionDisplay ToMock(this ActionDisplay ad, Uri uri) { string rawText = Lipsums.LoremIpsum; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); return(new ActionDisplay() { SimpleName = $"{lipsum.GenerateWords(1)[0]}", NameTranslations = new StringTranslationsCore().Map(new StringTranslations().ToMock()), ActionId = Guid.NewGuid().ToString() }); }
public static ActionDisplay Map(this ActionDisplay to, Action from) { var config = new MapperConfiguration(cfg => { cfg.AddProfile <ActionProfile>(); }); IMapper mapper = new Mapper(config); mapper.Map(from, to); return(to); }
void Start() { this.tui = this.GetComponentInChildren <TimerUI>(); this.ad = this.GetComponentInChildren <ActionDisplay>(); this.lb = this.GetComponentInChildren <LockButton>(); this.dbp = this.GetComponentInChildren <DebugPanel>(); this.gsd = this.GetComponentInChildren <GameStateDisplay>(); this.asg = this.GetComponentInChildren <ActionSelectGroup>(); this.god = this.GetComponentInChildren <GameOverDisplay>(); this.GameOverDisplayHide(); // Hide this till needed. Todo Warning, may depend on script execution order this.lasb = new List <ActionSelectButton>(); this.hsd = this.GetComponentInChildren <HitSunkDisplay>(); }
public void TestActionMocking() { var uri = new Uri("https://rprcorporate.blob.core.windows.net/media/sampletrophy.png?sp=rl&st=2021-03-28T19:06:34Z&se=2025-03-29T19:06:00Z&sv=2020-02-10&sr=b&sig=M3oKCysFeKGWw7jDnn1kCFNTFHdqxoOtKVzVFIYXXZs%3D"); var ad = new ActionDisplay().ToMock(uri); Guid actionId; Assert.IsTrue(Guid.TryParse(ad.ActionId, out actionId)); var a1 = new ActionDisplay().ToMock(uri); Assert.IsTrue(!string.IsNullOrEmpty(a1.SimpleName)); }
/// <summary> /// 移动到攻击范围内 /// </summary> /// <param name="enemyDisplay"></param> private void MoveToAttackRange(ActionDisplay enemyDisplay) { Vector3 targetPoint = _meTransform.position; if (targetPoint.x < enemyDisplay.Controller.transform.position.x) { MeController.Me.ChangeDire(Directions.Right); } else { MeController.Me.ChangeDire(Directions.Left); } MeController.MoveByDir(MeController.Me.CurFaceDire); }
/// <summary> /// 移动到攻击范围内 /// </summary> /// <param name="enemyDisplay"></param> private void MoveToAttackRange(ActionDisplay enemyDisplay) { Vector3 mePoint = _meTransform.position; var pos = enemyDisplay.Controller.transform.position; if (mePoint.x < pos.x) { pos.x = pos.x - _talentSkillVo.cover_width * 0.001f + 0.1f; } else { pos.x = pos.x + _talentSkillVo.cover_width * 0.001f - 0.1f; } MeController.MoveTo(pos.x, pos.y); }
public static void AD_Projectile(ActionDisplay actionDisplay, IMap map, Entity source, Entity target) { var drawableMap = map as IDrawableMap; var sourceAsCharacter = source as Character; // Play the sound PlaySoundSimple(actionDisplay, source); // Show the attack animation on the attacker if (sourceAsCharacter != null) { sourceAsCharacter.Attack(); } // Check if we can properly display the effect if (drawableMap != null && target != null && source != target) { // Show the graphic going from the attacker to attacked if (actionDisplay.GrhIndex != GrhIndex.Invalid) { var gd = GrhInfo.GetData(actionDisplay.GrhIndex); if (gd != null) { var grh = new Grh(gd, AnimType.Loop, TickCount.Now); var effect = new MapGrhEffectSeekPosition(grh, source.Center, target.Center, 750f) { MapRenderLayer = MapRenderLayer.SpriteForeground }; drawableMap.AddTemporaryMapEffect(effect); } } // Show the particle effect var pe = ParticleEffectManager.Instance.TryCreateEffect(actionDisplay.ParticleEffect); if (pe != null) { // Effect that just takes place on the target and dies very quickly pe.Position = target.Center; pe.Life = 100; var effect = new TemporaryMapParticleEffect(pe) { MapRenderLayer = MapRenderLayer.SpriteForeground }; drawableMap.AddTemporaryMapEffect(effect); } } }
private PDamage GetSkillPDamage(BaseRoleVo enemyVo, ActionDisplay enemyDisplay, uint cutHp, bool isDodge, bool isCrit) { var pdamage = new PDamage { id = enemyVo.Id, type = (byte)GetSynType(enemyDisplay.Type), x = 0, y = 0, dmg = cutHp, hp = enemyVo.CurHp, dmgType = (byte)GetDamageType(isDodge, isCrit), stateType = 0 }; return(pdamage); }
private void DoAttackLogic() { if (_talentSkillVo.target_type == TargetEnemy && MeController.StatuController.CurrentStatu == Status.IDLE) { bool isSkillCdReady = MeController.TalentSkillController.IsSkillCdReady(); if (isSkillCdReady) { var result = TryAttack(); if (!result) { ActionDisplay nearestEnemy = FindNearestEnemyInMapRange(); if (nearestEnemy != null) { MoveToAttackRange(nearestEnemy); } } } } }
/// <summary> /// 找到在当前副本阶段行走区域范围内最近的怪物 /// </summary> /// <returns></returns> private ActionDisplay FindNearestEnemyInMapRange() { ActionDisplay result = null; float dis = 1000000; IList <ActionDisplay> tempList = AppMap.Instance.monsterList.Cast <ActionDisplay>().ToList(); if (MeController.GetMeVo().Id == AppMap.Instance.me.GetVo().Id) { foreach (PlayerDisplay display in AppMap.Instance.playerList) { if (display != AppMap.Instance.me) { tempList.Add(display); } } } else { tempList.Add(AppMap.Instance.me); } foreach (ActionDisplay actionDisplay in tempList) { float x = actionDisplay.GoBase.transform.position.x; float y = actionDisplay.GoBase.transform.position.y; MapRange mapRange = AppMap.Instance.mapParser.CurrentMapRange; if (x < mapRange.MinX || x > mapRange.MaxX || y < mapRange.MinY || y > mapRange.MaxY) { continue; } if (actionDisplay.GetMeVoByType <BaseRoleVo>().CurHp == 0) { continue; } float curDis = GeteEnemyDistance(actionDisplay); if (curDis < dis) { result = actionDisplay; dis = curDis; } } return(result); }
public static Action ConverterActionDisplayIDToActionID( ActionDisplay actionid ) { Action tempAciton = CutsceneStep.Action.NoOp; if( actionid == CutsceneStep.ActionDisplay.EndCutscene ) tempAciton= CutsceneStep.Action.EndCutscene; else if(actionid == CutsceneStep.ActionDisplay.LoadScene) tempAciton= CutsceneStep.Action.LoadScene; else if(actionid == CutsceneStep.ActionDisplay.NoOp) tempAciton= CutsceneStep.Action.NoOp; else if(actionid == CutsceneStep.ActionDisplay.MoveTo) tempAciton= CutsceneStep.Action.MoveTo; else if(actionid == CutsceneStep.ActionDisplay.JumpTo) tempAciton= CutsceneStep.Action.JumpTo; else if(actionid == CutsceneStep.ActionDisplay.Action) tempAciton= CutsceneStep.Action.Action; else if(actionid == CutsceneStep.ActionDisplay.TalkTo) tempAciton= CutsceneStep.Action.TalkTo; else if(actionid == CutsceneStep.ActionDisplay.LookAt) tempAciton= CutsceneStep.Action.LookAt; else if(actionid == CutsceneStep.ActionDisplay.Rotate) tempAciton= CutsceneStep.Action.Rotate; else if(actionid == CutsceneStep.ActionDisplay.Follow) tempAciton= CutsceneStep.Action.Follow; else if(actionid == CutsceneStep.ActionDisplay.WaitFor) tempAciton= CutsceneStep.Action.WaitFor; else if(actionid == CutsceneStep.ActionDisplay.WaitTouch) tempAciton= CutsceneStep.Action.WaitTouch; else if(actionid == CutsceneStep.ActionDisplay.GoBack) tempAciton= CutsceneStep.Action.GoBack; else if(actionid == CutsceneStep.ActionDisplay.Activate) tempAciton= CutsceneStep.Action.Activate; else if(actionid == CutsceneStep.ActionDisplay.Setup) tempAciton= CutsceneStep.Action.Setup; else if(actionid == CutsceneStep.ActionDisplay.Stop) tempAciton= CutsceneStep.Action.Stop; else if(actionid == CutsceneStep.ActionDisplay.SpeechTo) tempAciton= CutsceneStep.Action.SpeechTo; else if(actionid == CutsceneStep.ActionDisplay.LoopAction) tempAciton= CutsceneStep.Action.LoopAction; else if(actionid == CutsceneStep.ActionDisplay.Proc) tempAciton= CutsceneStep.Action.Proc; else if(actionid == CutsceneStep.ActionDisplay.Sound) tempAciton= CutsceneStep.Action.Sound; else if(actionid == CutsceneStep.ActionDisplay.ChangeInto) tempAciton= CutsceneStep.Action.ChangeInto; else if(actionid == CutsceneStep.ActionDisplay.Mood) tempAciton= CutsceneStep.Action.Mood; else if(actionid == CutsceneStep.ActionDisplay.PlayMovie) tempAciton= CutsceneStep.Action.PlayMovie; else if(actionid == CutsceneStep.ActionDisplay.UniqueAction) tempAciton= CutsceneStep.Action.UniqueAction; else if(actionid == CutsceneStep.ActionDisplay.WaitSound) tempAciton= CutsceneStep.Action.WaitSound; else if(actionid == CutsceneStep.ActionDisplay.ScaleTo) tempAciton= CutsceneStep.Action.ScaleTo; else if(actionid == CutsceneStep.ActionDisplay.Caption) tempAciton= CutsceneStep.Action.Caption; else if(actionid == CutsceneStep.ActionDisplay.GameLog) tempAciton= CutsceneStep.Action.GameLog; return tempAciton; }
public static void AD_CastingSkill(ActionDisplay actionDisplay, IMap map, Entity source, Entity target) { // The maximum life the effects will have. This way, if the entity gets stuck with IsCastingSkill set to true, // the effects will at least go away eventually. Make sure that this is not greater than the longest possible // time to cast a skill. const int maxEffectLife = 1000 * 20; var drawableMap = map as IDrawableMap; var sourceAsCharacter = source as Character; var castingEffects = new List <ITemporaryMapEffect>(); // Make sure we have a valid source if (sourceAsCharacter == null) { const string errmsg = "AD_CastingSkill requires a Character as the source, but the source ({0}) is type `{1}`."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, sourceAsCharacter, source.GetType()); } Debug.Fail(string.Format(errmsg, sourceAsCharacter, source.GetType())); return; } // Play the sound PlaySoundSimple(actionDisplay, source); // Check if we can properly display the effect if (drawableMap != null) { // Show the graphic going from the source to target if (actionDisplay.GrhIndex != GrhIndex.Invalid) { var gd = GrhInfo.GetData(actionDisplay.GrhIndex); if (gd != null) { // Make the effect loop indefinitely var grh = new Grh(gd, AnimType.Loop, TickCount.Now); var effect = new MapGrhEffectTimed(grh, source.Center, true, maxEffectLife); drawableMap.AddTemporaryMapEffect(effect); castingEffects.Add(effect); } } // Show the particle effect var pe = ParticleEffectManager.Instance.TryCreateEffect(actionDisplay.ParticleEffect); if (pe != null) { // Effect that just takes place on the caster pe.Position = source.Center; pe.Life = maxEffectLife; var effect = new TemporaryMapParticleEffect(pe, true); drawableMap.AddTemporaryMapEffect(effect); castingEffects.Add(effect); } } // Make sure we have at least one valid effect. If not, there is nothing more to do. if (castingEffects.Count <= 0) { return; } // Add the list of effects to our local dictionary lock (_activeCastingSkillEffectsSync) { // Make sure they don't already have effects in the dictionary RemoveFromActiveCastingSkillEffects(sourceAsCharacter); // Add to the dictionary _activeCastingSkillEffects.Add(sourceAsCharacter, castingEffects); } // Attach the listener for the IsCastingSkill sourceAsCharacter.IsCastingSkillChanged += AD_CastingSkill_Character_IsCastingSkillChanged; // If the source already finished casting the skill, destroy them now since we probably missed the event if (!sourceAsCharacter.IsCastingSkill) { RemoveFromActiveCastingSkillEffects(sourceAsCharacter); } }
/// <summary> /// 获取技能攻击后的目标表现Vo /// </summary> /// <param name="skillVo"></param> /// <param name="excutePos"></param> /// <param name="dir"></param> /// <param name="enemyDisplay"></param> /// <param name="checkedTime"></param> /// <param name="moveRatio"></param> /// <returns></returns> private ActionVo GetSkillActionVo(SysSkillBaseVo skillVo, Vector3 excutePos, int dir, ActionDisplay enemyDisplay, int index, int checkedTime = 0, float moveRatio = 1) { var attackVo = new ActionVo { ActionType = Actions.INJURED, SkillUsePoint = excutePos, SkillId = skillVo.unikey }; /* * Vector3 moveToPoint = enemyDisplay.GoBase.transform.position; * if (skillVo.target_dir != 2 && checkedTime == 0) * { * if (dir == Directions.Left) * { * moveToPoint.x -= skillVo.back_dis*0.001f*moveRatio; * } * else * { * moveToPoint.x += skillVo.back_dis*0.001f*moveRatio; * } * } * if (MeVo.instance.mapId != MapTypeConst.WORLD_BOSS) //世界BOSS的位置不受影响 * { * moveToPoint.x = AppMap.Instance.mapParser.GetFinalMonsterX(moveToPoint.x); //限制怪物被攻击后不要出屏幕 * } * moveToPoint.y = enemyDisplay.GoBase.transform.position.y; //后退时保持高度不变 * attackVo.HurtDestination = moveToPoint;*/ attackVo.FloatingValue = skillVo.Floating_Value; if (MeVo.instance.mapId != MapTypeConst.WORLD_BOSS) //世界BOSS的位置不受影响 { //获取当前攻击点的攻击数据 int[][] atkList = StringUtils.Get2DArrayStringToInt(skillVo.Per_Atk_Data); if (atkList != null) { if (index < atkList.Length) { attackVo.Velocity_Origin = atkList[index][Actions.VELOCITY_ORIGIN] * 0.001f; attackVo.Angle = atkList[index][Actions.ANGLE]; attackVo.ProtectValue = atkList[index][Actions.PROTECTVALUE]; attackVo.ForceFeedBack = atkList[index][Actions.FORCEFEEDBACK]; attackVo.HitRecover = atkList[index][Actions.HITRECOVER]; attackVo.HurtAnimation = atkList[index][Actions.HURTANIMATION]; attackVo.FaceDirection = (dir == Directions.Left ? -1 : 1); } } } return(attackVo); }
public static void AD_SkillCasted(ActionDisplay actionDisplay, IMap map, Entity source, Entity target) { var drawableMap = map as IDrawableMap; // Play the sound PlaySoundSimple(actionDisplay, source); // Check if we can properly display the effect if (drawableMap != null && source != null) { if (actionDisplay.GrhIndex != GrhIndex.Invalid) { if (target != null && target != source) { // Show the graphic going from the source to target var gd = GrhInfo.GetData(actionDisplay.GrhIndex); if (gd != null) { var grh = new Grh(gd, AnimType.Loop, TickCount.Now); var effect = new MapGrhEffectSeekPosition(grh, source.Center, true, target.Center, 750f); drawableMap.AddTemporaryMapEffect(effect); } } else { // Show the graphic at the source var gd = GrhInfo.GetData(actionDisplay.GrhIndex); if (gd != null) { var grh = new Grh(gd, AnimType.Loop, TickCount.Now); var effect = new MapGrhEffectLoopOnce(grh, source.Center, true); drawableMap.AddTemporaryMapEffect(effect); } } } // Show the particle effect var pe = ParticleEffectManager.Instance.TryCreateEffect(actionDisplay.ParticleEffect); if (pe != null) { pe.Position = source.Center; ITemporaryMapEffect effect; if (target != null && target != source) { // Effect that seeks out the position of the target effect = new TemporaryMapParticleEffectSeekPosition(pe, true, target.Center, 250f); } else { // Effect that takes place at the source effect = new TemporaryMapParticleEffect(pe, true); } // Add the effect to the map if (effect != null) { drawableMap.AddTemporaryMapEffect(effect); } } } }
public static void Test(ActionDisplay actionDisplay, IMap map, Entity source, Entity target) { i = 50; }
/// <summary> /// 执行器(每帧执行) /// </summary> private void Update() { // 获取animator的信息并根据animator信息进行相应的业务处理 if (_animator == null) { _animator = MeController.Me.Animator; return; } //1. 如果有AI任务或者AI不在待机状态或者死亡的情况下,则不往下走,节省性能消耗 if (!CanUseAi()) { if (!DangJiTester.role_use_ai) // 根据该变得来设置主角是是否使用AI { return; } } //2. 找到最近的敌人 ActionDisplay nearestEnemy = FindNearestEnemyInMapRange(); //3. 如果没有敌人,则在场景内左右移动 if (nearestEnemy == null) { AiMoveBehaviourNoEnemy(); return; } //如果自动切图阶段,则不执行后面的AI if (MapMode.StartAutoMove) { return; } //4. 尝试使用技能 TryToUseSkill(nearestEnemy); //5. 判断最近敌人和AI的Y值差,若Y值差大于0.5个Unity单位,则纵向移动到同一Y值 if (Mathf.Abs(nearestEnemy.Controller.transform.position.y - _meTransform.position.y) > 0.5f) { MoveToTheSameYWithEnemy(nearestEnemy); return; } float disX = Mathf.Abs(nearestEnemy.Controller.transform.position.x - _meTransform.position.x); //6. 若AI和最近敌人的距离大于6个Unity单位,则横向移动到离敌人的6个单位内 if (disX >= 6) { MoveToAttackRange(nearestEnemy); return; } //7. 若在瞬移范围内,则使用瞬移 if ((disX < 6 && disX > 5) || (disX < 2.5f && disX > 1.8f)) { if (MeController.SkillController.LearnedSkillList[SkillController.Roll] != 0 && MeController.SkillController.IsSkillCdReady(SkillController.Roll)) { MeController.SkillController.RequestUseSkill(SkillController.Roll); return; } } //8. 若在普通攻击范围内,则使用普通攻击 if (disX < _normalAttackRange && _mePlayerVo.CurHp > 0) { if (_meTransform.position.x < nearestEnemy.GoBase.transform.position.x) { MeController.Me.ChangeDire(Directions.Right); } else { MeController.Me.ChangeDire(Directions.Left); } var attackVo = new ActionVo { ActionType = Actions.ATTACK, TargetPoint = nearestEnemy.GoBase.transform.position }; StartCoroutine(YieldSecordsAutoAttack(0.5f, attackVo)); return; } //10. 若以上情况都不是,则继续移动到攻击范围内 MoveToAttackRange(nearestEnemy); }