private void OnButtonClick(int cellPos) { var skillContext = new SkillContext(_player, 0, null); if (!_useThingSkill.ReadyToUse(skillContext)) { return; } var bagCell = _bag.Cells.Skip(cellPos).FirstOrDefault(); if (bagCell != null) { var thing = bagCell.Item; if (thing is IStack stack) { thing = stack.Prototype.CreateInstance(); } _lastClickedCell = bagCell; _useThingSkill.OnEndCast += OnUseThingEndCast; _useThingSkill.Thing = thing; _player.Use(_useThingSkill, skillContext); } }
public object Execute(SkillContext c) { double val = 0; double l = Convert.ToDouble(left.Execute(c)); double r = Convert.ToDouble(right.Execute(c)); switch (Operation) { case SkillType.PLUS: val = l + r; break; case SkillType.MINUS: val = l - r; break; case SkillType.MULTI: val = l * r; break; case SkillType.DIVIDE: val = l / r; break; case SkillType.POWER: val = Math.Pow(l, r); break; } return(val); }
public Skill(int id, SkillContext context) { mSkillInfo = excel_skill_list.Find(id); mSkillContext = context; mSkillState = SkillState.Failed; }
//启动一个Action public bool StartAction(Action config, EventPart ep, bool high, SkillContext context = null) { ZWAction zwaction = new ZWAction(config, this, ep, high, context); this.actionList_.AddTail(zwaction); return(true); }
public static SkillResult UseSkill(SkillHandle handle) { if (handle.caster == null || handle.caster.IsCannotFlag(CannotFlag.CannotSkill)) { return(SkillResult.InvalidCaster); } SkillContext context = new SkillContext(); context.mOwner = handle.caster; context.SkillTargetID = handle.skillTargetID; if (handle.autoTargetPos) { Character target = context.mOwner.GetTarget(); if (target == null) { context.TargetPos = context.mOwner.Position; } else { context.TargetPos = target.Position; } } else { context.TargetPos = handle.targetPos; } Skill skill = new Skill(handle.skillID, context); handle.caster.SetSkill(skill); return(SkillResult.Success); }
public override void Effect(SkillContext Context) { if (curOnOff == true) { Context.curTargetStack.AddModifier(new Modifier(Baff.Defence, 0, ValueType.Percent, -1, Context.curTargetStack.curTurnCounter)); } }
static bool IsMayHit(Character cha, SkillContext context, excel_skill_hit hitExcel) { Dictionary <Character, int> hitmap; if (!context.mChaHitCount.TryGetValue(hitExcel.id, out hitmap)) { return(true); } int hitCount = 0; if (!hitmap.TryGetValue(cha, out hitCount)) { return(true); } int maxHitCount = (int)hitExcel.targetMaxHitCnt; if (maxHitCount <= 0) { return(true); } if (hitCount > maxHitCount) { return(false); } return(true); }
public async Task SkillMiddlewarePopulatesSkillContextDifferentDatatypes() { string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json"); var skillBeginEvent = JsonConvert.DeserializeObject <Activity>(jsonSkillBeginActivity); var skillContextData = new SkillContext(); skillContextData.Add("PARAM1", DateTime.Now); skillContextData.Add("PARAM2", 3); skillContextData.Add("PARAM3", null); // Ensure we have a copy skillBeginEvent.Value = new SkillContext(skillContextData); TestAdapter adapter = new TestAdapter() .Use(new SkillMiddleware(_userState, _conversationState, _dialogStateAccessor)); var testFlow = new TestFlow(adapter, async(context, cancellationToken) => { // Validate that SkillContext has been populated by the SKillMiddleware correctly await ValidateSkillContextData(context, skillContextData); }); await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync(); }
private string CreateCollectionMismatchMessage(SkillContext context, Dictionary <string, object> test) { var contextData = string.Join(",", context.Select(x => x.Key + "=" + x.Value)); var testData = string.Join(",", test.Select(x => x.Key + "=" + x.Value)); return($"Expected: {testData}, Actual: {contextData}"); }
SkillContext createNewSkillContext(FBActor actor, NodeMapInfo nodeMapInfo) { var context = new SkillContext(this, nodeMapInfo); context.globalData.add(actor != null ? actor.skillActor : null); return(context); }
public bool doSkill(FBActor actor, int id) { if (actor != null) { } NodeMapInfo map; if (!m_skills.TryGetValue(id, out map)) { string[] skills = new string[] { "test" }; //临时 UnityEngine.TextAsset ta = UnityEngine.Resources.Load <UnityEngine.TextAsset>("Skill/" + skills[id]); System.IO.MemoryStream ms = new System.IO.MemoryStream(ta.bytes); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); map = (NodeMapInfo)formatter.Deserialize(ms); m_skills.Add(id, map); } SkillContext context = createNewSkillContext(actor, map); context.startup(); if (context.activedObjectCount != 0) { skillContexts.AddLast(context.updater); } return(true); }
public override void Effect(SkillContext Context) { if (curOnOff == true) { Context.curTargetStack.AddModifier(new Modifier(Baff.Attack, 2, ValueType.Value, 12, Context.curTargetStack.curTurnCounter)); } }
static void SkillMove(Character cha, ChildObject childObj, SkillContext context, excel_skill_event e) { if (cha == null) { return; } SkillMoveDataType type = (SkillMoveDataType)e.evnetParam1; if (type == SkillMoveDataType.MoveType1) { float time = (float)e.evnetParam2 * 0.001f; SkillMove skillMove = IAction.CreateAction <SkillMove>(); skillMove.Init1(cha, context.TargetPos, time); cha.AddAction(skillMove); } else if (type == SkillMoveDataType.MoveType2) { float time = (float)e.evnetParam2 * 0.001f; float speed = (float)e.evnetParam3 * 0.001f; Vector3 dir = context.TargetPos - cha.Position; SkillMove skillMove = IAction.CreateAction <SkillMove>(); skillMove.Init2(cha, dir, speed, time); cha.AddAction(skillMove); } context.SetSkillContextFlag(SkillContextFlag.SyncPosOnSkillEnd, true); }
static void TowardTargetPos(Character cha, ChildObject childObject, SkillContext context, excel_skill_event e) { Vector3 ownerPos = Vector3.zero; if (cha != null) { ownerPos = cha.Position; } else if (childObject != null) { ownerPos = childObject.Position; } else { return; } Vector3 dir = context.TargetPos - ownerPos; if (cha != null) { cha.Direction = dir; } else if (childObject != null) { childObject.Direction = dir; } }
private void PlayAction(bool high) { for (int i = 0; i < Action_.ActionEvents.Length; i++) { Action.ActionEvent ae = Action_.ActionEvents[i]; if (ae.EventType == ActionEventType.ANIMATION && ae.RigorTime == 0) { EditorUtility.DisplayDialog("错误", "请填写动作不可打断时间", "OK"); return; } } if (!EditorApplication.isPlaying) { EditorUtility.DisplayDialog("Error", "需要在运行状态下才能进行该操作", "OK"); return; } if (!ModelLoader.self) { return; } ModelLoader.self.ResetTime(); ModelLoader.self.transform.position = Vector3.zero; SkillContext context = new SkillContext(); context.Wave = 1; for (int i = 0; i < 10; i++) { SkillContext.FireBoll fireBoll = new SkillContext.FireBoll(); fireBoll.limit = 3; if (ModelLoader.targetList.Count > 0) { fireBoll.ro = ModelLoader.targetList[Random.Range(0, ModelLoader.targetList.Count - 1)]; } context.targets.Add(fireBoll); } bool hasbuff = false; for (int i = 0; i < Action_.ActionEvents.Length; i++) { Action.ActionEvent ae = Action_.ActionEvents[i]; if (ae.EventPart == EventPart.BUFF) { hasbuff = true; break; } } if (hasbuff) { ModelLoader.self.mActionPerformer.StartAction(Action_, EventPart.BUFF, high, null); ModelLoader.self.mActionPerformer.StartCoroutine(PlayAction(context, 2, high)); } else { ModelLoader.self.mActionPerformer.StartCoroutine(PlayAction(context, 0, high)); } }
public SkillStage(Skill skill, int stageID, SkillContext context) { mSkill = skill; mStageInfo = excel_skill_stage.Find(stageID); mSkillContext = context; mBreak = 0; }
static void AddHitCount(Character cha, SkillContext context, excel_skill_hit hitExcel) { Dictionary <Character, int> hitmap; if (!context.mChaHitCount.TryGetValue(hitExcel.id, out hitmap)) { hitmap = new Dictionary <Character, int>(); context.mChaHitCount.Add(hitExcel.id, hitmap); hitmap.Add(cha, 1); return; } int hitCount = 0; if (!hitmap.TryGetValue(cha, out hitCount)) { hitmap.Add(cha, 1); return; } int maxHitCount = (int)hitExcel.targetMaxHitCnt; if (maxHitCount > 0 && hitCount > maxHitCount) { return; } ++hitCount; hitmap[cha] = hitCount; }
void Update() { Player.Update(); if (Input.GetKeyDown(KeyCode.F)) { var thing = ThingsBehaviour.Instance.SearchNearly(PlayerGameObject); if (thing != null) { var gameObj = ThingsBehaviour.Instance.Things[thing]; var distance = Utils.Distance(gameObj, PlayerGameObject); var skillContext = new SkillContext(Player, distance, null); if (!_useThingSkill.ReadyToUse(skillContext)) { return; } _usableThing = thing; _useThingSkill.Thing = thing; Player.Use(_useThingSkill, skillContext); } } }
public void TestSkillLanguage_StatsRetrieval() { List <string> statement = new List <string>(); List <double> expected = new List <double>(); List <SkillContext> context = new List <SkillContext>(); SkillLexer lex; SkillParser parser; SkillContext baseContext = new SkillContext() { Caster = new Fighter("", new Stats(new int[] { 1, 2, 3, 4, 5, 6, 7 }), false, null), Target = new Fighter("", new Stats(new int[] { 7, 6, 5, 4, 3, 2, 1 }), false, null) }; statement.Add("C.HP;"); expected.Add(3); context.Add(baseContext); statement.Add("T.LVL;"); expected.Add(7); context.Add(baseContext); statement.Add("T.DEF-C.ATK;"); expected.Add(-5); context.Add(baseContext); for (int i = 0; i < statement.Count; i++) { lex = new SkillLexer(statement[i]); parser = new SkillParser(lex); double actual = Convert.ToDouble(((List <object>)parser.getTree().Execute(context[i]))[0]); Assert.AreEqual(expected[i], actual); } }
static void ResetTargePos(Character cha, ChildObject childObject, SkillContext context, excel_skill_event e) { SkillSelectCharactorType selType = (SkillSelectCharactorType)e.evnetParam1; Character selTarget = context.SelectCharactorByType(selType); if (selTarget == null) { return; } float fAngle = (float)e.evnetParam2; if (e.evnetParam3 > 0) { float fAngleR = (float)e.evnetParam3 * 2.0f; float fPct = UnityEngine.Random.Range(0.0f, 1.0f); fAngle += fPct * fAngleR - fAngleR; } Quaternion q = Quaternion.AngleAxis(fAngle, Vector3.up); Vector3 dir = selTarget.Direction; if (e.evnetParam4 > 0 && context.mOwner != selTarget) { dir = selTarget.Position - context.mOwner.Position; dir.y = 0.0f; dir.Normalize(); } dir = q * dir; float dist = (float)e.evnetParam5 * 0.001f; Vector3 targetPos = selTarget.Position + dir * dist; TargetPosTestType testType = (TargetPosTestType)e.evnetParam6; switch (testType) { case TargetPosTestType.None: break; case TargetPosTestType.LineTest: { uint layer = NavigationSystem.GetLayer(context.mOwner.Position); if (NavigationSystem.LineCast(context.mOwner.Position, targetPos, layer, out targetPos)) { break; } break; } case TargetPosTestType.TargetInNav: { if (!NavigationSystem.IsInNavigation(targetPos)) { targetPos = selTarget.Position; } break; } } context.TargetPos = targetPos; }
public override void Effect(SkillContext Context) { if (curOnOff == true) { Context.curTargetStack.AddModifier(new Modifier(Baff.Skill, 0, Context.curTargetStack.curTurnCounter, Context.curTargetStack.PassiveSkills[0], 0)); } }
public object Execute(SkillContext c) { List <object> res = new List <object>(); foreach (ISkillNode i in statements) { res.Add(i.Execute(c)); } return(res); }
protected SkillBaseEventArgs(SkillContext context, MapObject sender, MapObject target) { this.context = context; this.sender = sender; this.target = target; if (!(this is SkillUsageEventArgs || this is ItemSkillUsageEventArgs || this is SkillToggleEventArgs)) { throw new SystemException("Class inheritance by other classes than the default are not allowed"); } }
public object Execute(SkillContext c) { if (fighterReferance == SkillType.C) { return(c.Caster.Stats[Stat]); } else { return(c.Target.Stats[Stat]); } }
public object Execute(SkillContext c) { if (left.fighterReferance == SkillType.C) { c.Caster.Stats[left.Stat] = Convert.ToInt32(right.Execute(c)); } else { c.Target.Stats[left.Stat] = Convert.ToInt32(right.Execute(c)); } return(null); }
public ZWAction(Action config, ActionPerformer af, EventPart ep, bool high, SkillContext context = null) { this.High = high; this.startTime = GameTimer.time; this.config = config; this.LifeTime = this.config.LifeTime; this.eventpart = ep; this.ActionPerformer_ = af; this.actionEvents = new PList(); this.context = context; this.Initialize(af.owerObject); }
public void Use(SkillContext context) { if (!ReadyToUse(context)) { return; } _skillContext = context; _lastUsedThing = null; _startCastTime = DateTime.Now; OnBeginCast?.Invoke(this); }
public static ChildObject CreateChildObject(int id, SkillContext context, Transform parentObj) { ChildObject skillObject = CreateChildObject(id, context.mOwner, parentObj, context.TargetPos, context.SkillTarget); if (skillObject == null) { Debug.LogError("未找到ID为" + id + "的子物体,请确认技能物体表配置有该子物体"); return(null); } skillObject.mContext.mSkillID = context.mSkillID; return(skillObject); }
public void Use(SkillContext context) { if (!ReadyToUse(context)) { return; } _lastUseTime = DateTime.Now; var ratio = _source.GetSkillPower(this, context); context.Target.ChangeHP(-ratio * _weapon.Power, _source, this); OnSuccessUsed?.Invoke(this, context); }
IEnumerator PlayAction(SkillContext context, float time, bool high) { yield return(new WaitForSeconds(time)); ModelLoader.self.mActionPerformer.StartAction(Action_, EventPart.FIRE, high, context); GameObject[] targets = GameObject.FindGameObjectsWithTag("target"); for (int i = 0; i < targets.Length; i++) { RoleObject target = targets[i].GetComponent <RoleObject>(); if (target) { target.mActionPerformer.StartAction(Action_, EventPart.HIT, high); } } }