public ActionConnection AddConnection(ActionSkill ToSkill, ActionSkill FromSkill, double toValue, double fromValue) { ActionConnection newConnection = new ActionConnection(ToSkill, FromSkill, toValue, fromValue, this); bool alreadyExists = false; foreach (ActionConnection ac in connections) { if (ac.IsThereConnectionBetween(ToSkill, FromSkill)) { alreadyExists = true; break; } } if (alreadyExists) { Debug.Log("Editting existing connection"); } else { connections.Add(newConnection); } return(newConnection); }
public ActionConnection(ActionSkill toSkill, ActionSkill fromSkill, double toV, double fromV, ActionNetwork owner) { this.To = toSkill; this.From = fromSkill; this.toValue = toV; this.fromValue = fromV; }
public void DeleteSkill(ActionSkill skillToDelete) { if (skills.Contains(skillToDelete)) { DeleteConnection(skillToDelete); skills.Remove(skillToDelete); } }
public static async Task DoActionSkill(ActionSkill target) { await DoAutoCheckTiming(); await Player.UseActionSkill(target); await DoAutoCheckTiming(); }
public ActionSkill OtherEnd(ActionSkill oneEnd) { if (oneEnd == To) { return(From); } else { return(To); } }
public static void ShowSkillPreview(ActionSkill actS) { if (ActionSkillPreview.instance == null) { Debug.LogError("Failed to set up Action Skill Preview Window"); return; } ActionSkillPreview.instance.Show(); ActionSkillPreview.instance.Focus(); ActionSkillPreview.instance.Repaint(); ActionSkillPreview.instance.currentSkill = actS; }
/// <summary> /// 检查技能使用者的当前状态, 可否使用skill标识的技能, 并返回错误码. /// </summary> public static ErrorCode CheckUserSkillUsingState(BattleUnitActionCenter actionCenter, BattleUnitSkill skill) { ActionSkill currentAs = actionCenter.GetActionByType(ActionTypeDef.ActionTypeSkill) as ActionSkill; if (currentAs == null) { return(ErrorCode.Succeeded); } // 当前正在进行技能动作. // 执行相同的技能. if (currentAs.SameSkill(skill)) { // 正在使用阶段则无法被打断(因为是相同的技能, 不存在非普通攻击打断普通攻击的情况). if (currentAs.InUsingState) { return(ErrorCode.SkillAlreadyUsing); } // 当前技能正在准备, 如果不能切换, 那么返回错误. else if (!currentAs.Interruptable) { return(ErrorCode.SkillUninterruptable); } } else // 其他技能使用. { // 普通攻击, 在任何情况下都被打断. if (currentAs.IsRegularAttack) { } // 非普通攻击, 在准备阶段. 检查它可否被打断. else if (currentAs.InChargingState) { if (!currentAs.Interruptable) { return(ErrorCode.SkillUninterruptable); } } // 非普通攻击, 在使用阶段. else { return(ErrorCode.SkillAlreadyUsing); } // 当前的技能被打断. actionCenter.RemoveActionByType(ActionTypeDef.ActionTypeSkill); currentAs = null; } return(ErrorCode.Succeeded); }
public bool OnSubCollectionListItemGUI(object item, bool selected, ICollection list) { ActionSkill mySubItem = (ActionSkill)item; GUIStyle style = (!selected || highlightedItemType != ItemType.ActionSkill) ? ActionResources.listItem : ((!this.HasFocus) ? ActionResources.unfocusedSelectedListItem : ActionResources.selectedListItem); GUIStyle style2 = (!selected || highlightedItemType != ItemType.ActionSkill) ? ActionResources.list : ((!this.HasFocus) ? ActionResources.unfocusedSelectedList : ActionResources.selectedList); GUILayout.BeginHorizontal(style, new GUILayoutOption[0]); { GUILayout.Space(40f); if (editingNames && _highlightedItemType == ItemType.ActionSkill && selected) { editingString = GUILayout.TextField(editingString, EditorStyles.textField, new GUILayoutOption[] { GUILayout.Height(14f) }); } else if (GUILayout.Button(mySubItem.Name, style2, new GUILayoutOption[] { GUILayout.Height(14f) })) { editingNames = false; selected = true; if (highlightedItemType == ItemType.ActionNetwork) { ActionEditor.instance.currentLibraryNetwork.name = ActionEditor.instance.currentLibraryNetwork.name.Replace(" ", string.Empty); } else { highlightedSkill.Name = highlightedSkill.Name.Replace(" ", string.Empty); } highlightedSkill = mySubItem; ActionEditor.instance.currentLibraryNetwork = highlightedSkill.owner; ActionNetworkEditor.instance.selectedSkills.Clear(); highlightedItemType = ItemType.ActionSkill; ActionNetworkEditor.instance.selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(mySubItem)); ActionNetworkEditor.instance.CentreSkill(); //Debug.Log ("Point is " + new Vector2(highlightedSkill.Position.X + ActionNetworkEditor.instance.offset.X,highlightedSkill.Position.Y+ ActionNetworkEditor.instance.offset.Y)); } } GUILayout.EndHorizontal(); return(selected); }
public void DeleteConnection(ActionSkill deletedSkill) { List <ActionConnection> connectionsToDelete = new List <ActionConnection>(); foreach (ActionConnection ac in connections) { if (ac.Contains(deletedSkill)) { connectionsToDelete.Add(ac); } if (ActionNetworkEditor.instance.selectedConnection.HasValue && connections.IndexOf(ac) == ActionNetworkEditor.instance.selectedConnection.Value) { ActionNetworkEditor.instance.selectedConnection = null; } } connections.RemoveAll(n => connectionsToDelete.Contains(n)); }
void OnGUI() { GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), ActionResources.line, ScaleMode.StretchToFill); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUI.contentColor = Color.blue; GUILayout.Label(currentSkill.Name, new GUILayoutOption[] { }); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); DrawLine(new Vector2(offset.x, Screen.height - offset.y), new Vector2(Screen.width - offset.x, Screen.height - offset.y), Color.black, 2f, false); DrawLine(new Vector2(offset.x, Screen.height - offset.y), new Vector2(offset.x, offset.y), Color.black, 2f, false); Handles.color = Color.blue; if (ActionNetworkEditor.instance != null & ActionNetworkEditor.instance.selectedSkills.Count > 0) { ActionSkill curSkil = currentSkill; HandlesDrawCurve(curSkil.Q, curSkil.B, curSkil.v, 100); } int labelNo = (int)((Screen.width - 2f * offset.x) / 50f); Color curCol = GUI.skin.label.normal.textColor; GUI.skin.label.normal.textColor = Color.black; for (int i = 0; i < labelNo + 1; ++i) { GUI.Label(new Rect(offset.x + 50f * i - 5f, Screen.height - 22.5f, 25f, 20f), (50 * i).ToString()); } GUI.skin.label.normal.textColor = curCol; }
/// <summary> /// 创建技能Action. 开始向targetPosition使用技能. /// </summary> /// <remarks> /// <para>普通攻击可以被其他非普通攻击, 无条件打断</para> /// <para>非普通攻击只有在准备阶段, 且配置中指定了可被打断才可以被打断</para> /// <para>非普通攻击被相同的技能打断, 表示从使用阶段切换到使用阶段</para> /// 非普通攻击被其他技能打断, 直接停止当前技能, 开始新的技能. /// </remarks> public static ErrorCode StartSkillAction(BattleUnitActionCenter actionCenter, BattleUnitSkill skill, Vector3 targetPosition) { if (skill == null) { return(ErrorCode.InvalidParam); } ActionSkill currentAs = actionCenter.GetActionByType(ActionTypeDef.ActionTypeSkill) as ActionSkill; ErrorCode err = ErrorCode.Succeeded; if (currentAs == null) { ActionSkillInitParam param = new ActionSkillInitParam(); param.skill = skill; param.targetPosition = targetPosition; err = actionCenter.StartAction(param); if (err != ErrorCode.Succeeded) { return(err); } } else { // 如果此时的currentAs不为null, 那么它必然为一个正在准备状态的技能且可以切换状态. #if UNITY_EDITOR if (!(currentAs.InChargingState && currentAs.Interruptable)) { ErrorHandler.Parse(ErrorCode.LogicError, "技能处于错误的状态."); } #endif err = currentAs.EnterUseState(targetPosition); } return(err); }
void OnGUI() { if (!init) { int i = 0; string copy = "NewEmptySkill"; if (ActionEditor.instance.currentLibraryNetwork.Get(copy) != null) { while (ActionEditor.instance.currentLibraryNetwork.Get(copy + i) != null) { ++i; } copy += i; } newSkillName = copy; init = true; } EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Skill Name:"); newSkillName = EditorGUILayout.TextField(newSkillName); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Q:"); Q = EditorGUILayout.TextField(Q); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("B:"); B = EditorGUILayout.TextField(B); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("v:"); v = EditorGUILayout.TextField(v); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Create New Skill", GUILayout.ExpandWidth(false)) || Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) { double skillQ = 10; double skillB = 10; double skillV = 10; if (!double.TryParse(Q, out skillQ) || !double.TryParse(B, out skillB) || !double.TryParse(v, out skillV)) { EditorUtility.DisplayDialog("Error", "A skill parameter is incorrectly formatted.", "Okay"); } else if (ActionEditor.instance.currentLibraryNetwork.Get(newSkillName) != null) { EditorUtility.DisplayDialog("Error", ActionEditor.instance.currentLibraryNetwork.name + " already contains a skill called '" + newSkillName + "'" + ". Please choose a different name.", "Okay"); } else { ActionSkill newSkill = ActionNetworkEditor.instance.skillBeingDrawn = ActionEditor.instance.currentLibraryNetwork.AddSkill(newSkillName.Replace(" ", string.Empty), skillQ, skillB, skillV, new EditorTwoVector(Event.current.mousePosition.x, Event.current.mousePosition.y)); ActionLibraryExplorer.instance.highlightedItemType = ActionLibraryExplorer.ItemType.ActionSkill; ActionLibraryExplorer.instance.highlightedSkill = newSkill; ActionNetworkEditor.instance.positioningSkill = true; this.Close(); ActionEditor.instance.SaveLibrary(); ActionNetworkEditor.instance.creatingNewSkill = false; } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
public static string ClassString(ActionNetwork actionNetwork) { string text = "\n\tpublic sealed class " + actionNetwork.name.RemoveSpecialCharacters() + " : ACE.Runtime.Network \n" + "\t{\n" + "\t\tpublic enum Skill \n" + "\t\t{ \n"; string[] skillNames = new string[actionNetwork.skills.Count]; for (int i = 0; i < actionNetwork.skills.Count; ++i) { skillNames[i] = actionNetwork.skills[i].Name; text += "\t\t\t" + skillNames[i].RemoveSpecialCharacters().Replace(" ", string.Empty) + "=" + i + ",\n"; } text += "\t\t}\n\n"; text += "\t\tprivate void Init()\n" + "\t\t{\n" + "\t\t\tmodelNo = " + actionNetwork.skills.Count.ToString() + "; \n\n" + "\t\t\t_stren = new double[][]" + "\t{"; double[,] connectionMatrix = new double[actionNetwork.skills.Count, actionNetwork.skills.Count]; List <ActionConnection> alreadyCoveredConnections = new List <ActionConnection>(); for (int j = 0; j < actionNetwork.skills.Count; ++j) { foreach (ActionConnection actC in actionNetwork.connections) { if (!alreadyCoveredConnections.Contains(actC)) { ActionSkill actS = actionNetwork.skills[j]; if (actC.Contains(actS)) { alreadyCoveredConnections.Add(actC); if (actC.isTo(actS)) { int index = actionNetwork.skills.IndexOf(actC.From); if (index != -1) { connectionMatrix[j, index] = actC.toValue; connectionMatrix[index, j] = actC.fromValue; } } else { int index = actionNetwork.skills.IndexOf(actC.To); if (index != -1) { connectionMatrix[index, j] = actC.toValue; connectionMatrix[j, index] = actC.fromValue; } } } } } } for (int j = 0; j < actionNetwork.skills.Count; ++j) { text += "\t\n\t\t\t new double[] {"; for (int k = 0; k < actionNetwork.skills.Count - 1; ++k) { text += connectionMatrix[j, k].ToString() + ", "; } text += connectionMatrix[j, actionNetwork.skills.Count - 1].ToString(); text += " },"; } text += "\t};"; text += "\t\n\n"; text += "\t\t\t_l = new double[" + actionNetwork.skills.Count + "];\n"; text += "\t\t\t_exp = new double[" + actionNetwork.skills.Count + "];\n"; text += "\t\t\t_skills = new ACE.Runtime.Skill[" + actionNetwork.skills.Count + "]{\n"; for (int i = 0; i < actionNetwork.skills.Count; ++i) { if (i != 0) { text += "\t\n"; } text += "\t\t\t\tnew ACE.Runtime.Skill( \"" + skillNames[i] + "\", this, " + i.ToString() + ", " + actionNetwork.skills[i].Q.ToString() + ", " + actionNetwork.skills[i].B.ToString() + ", " + actionNetwork.skills[i].v.ToString() + "),"; } text = text.Remove(text.Length - 1); text += "\t};\n"; text += "\t\t}\n\n"; text += "\t\tpublic " + actionNetwork.name + "()\n" + "\t\t{\n" + "\t\t\tInit();\n" + "\t\t\tSetAllLevels(1);\n" + "\t\t}\n\n"; text += "\t\tpublic " + actionNetwork.name + "(double level)\n" + "\t\t{\n" + "\t\t\tInit();\n" + "\t\t\tSetAllLevels(level);\n" + "\t\t}\n\n"; text += "\t\tpublic " + actionNetwork.name + "(double[] levels)\n" + "\t\t{\n" + "\t\t\tif(levels.Length != " + actionNetwork.skills.Count + ")\n" + "\t\t\t{\n" + "\t\t\t\tUnityEngine.Debug.LogError(\"Double array input length does not equal \" + " + actionNetwork.skills.Count + " + \". Calling default constructor\");\n" + "\t\t\t\tInit();\n" + "\t\t\t\tSetAllLevels(1);\n\n" + "\t\t\t\treturn;\n" + "\t\t\t}\n" + "\t\t\telse\n" + "\t\t\t{\n" + "\t\t\t\tInit();\n\n" + "\t\t\t\tfor(int i = 0; i < " + actionNetwork.skills.Count + "; ++i)\n" + "\t\t\t\t{\n" + "\t\t\t\t\tSetLevel((Skill)i, levels[i]);\n" + "\t\t\t\t}\n" + "\t\t\t}\n" + "\t\t}\n\n" + "\t\tpublic void SetAllLevels(double level)\n" + "\t\t{\n" + "\t\t\tfor(int i = 0; i < " + actionNetwork.skills.Count + "; ++i)\n" + "\t\t\t{\n" + "\t\t\t\tSetLevel((Skill)i, level);\n" + "\t\t\t}\n" + "\t\t}\n\n" + "\t\tpublic void SetLevel(Skill skill, double val)\n" + "\t\t{\n" + "\t\t\tint model = (int)skill;\n\n" + "\t\t\tRemoveSkillFromQueue(model);\n\n" + "\t\t\t_exp[model] = ACE.Runtime.BrentSolver.Brent(new ACE.Runtime.BrentSolver.FunctionOfOneVariable(_skills[model].Level), 0, 1000, 1e-10, val);\n" + "\t\t\t_l[model] = _skills[model].Level(_exp[model]);\n" + "\t\t}\n\n" + "\t\tpublic double GetLevelAsDouble(Skill skill)\n \t\t{\n\t\t\tint model = (int)skill;\n\n\t\t\tlock(_skills[model].loc)\n\t\t\t{\n\t\t\t\treturn _l[model];\n" + "\t\t\t}\n\t\t}\n\n" + "\t\tpublic float GetLevelAsFloat(Skill skill)\n \t\t{\n \t\t\treturn (float)GetLevelAsDouble(skill);\n \t\t}\n\n" + "\t\tpublic double GetExperienceAsDouble(Skill skill)\n \t\t{\n \t\t\tint model = (int)skill;\n\n \t\t\tlock(_skills[model].loc)\n \t\t\t{\n \t\t\t\treturn _exp[model];\n \t\t\t}\n \t\t}\n\n" + "\t\tpublic float GetExperienceAsFloat(Skill skill)\n\t\t{\n\t\t\treturn (float)GetExperienceAsDouble(skill);\n\t\t}\n\n" + "\t\tpublic void LevelUp(Skill skill, double val)\n\t\t{\n\t\t\tint model = (int)skill;\n\n\t\t\tACE.Runtime.ThreadedActionScript.instance.Action(_skills[model],val);\n \t\t}\n\n" + "\t\tprivate void RemoveSkillFromQueue(Skill skill)\n \t\t{\n \t\t\tint model = (int)skill;\n\n \t\t\tRemoveSkillFromQueue(model);\n \t\t}\n\n" + "\t\tprivate void RemoveSkillFromQueue(int i)\n\t\t{\n \t\t\tlock(_skills[i].loc)\n \t\t\t{\n \t\t\t\t_skills[i].isBlockedFromQueue = true;\n\n \t\t\t\tif(_skills[i].isInQueue)\n \t\t\t\t{\n \t\t\t\t\tACE.Runtime.ThreadedActionScript.instance.RemoveFromQueue(_skills[i]);\n\t\t\t\t}\n\n\t\t\t\t_skills[i].isBlockedFromQueue = false;\n \t\t\t}\n \t\t}\n\n" + "\t\tpublic void Remove()\n\t\t{\n \t\t\tACE.Runtime.ThreadedActionScript.instance.ClearQueue();\n \t\t}\n"; return(text + "\t}"); }
private void DrawZoomArea() { _bezierTexture = _bezierTexture ?? Resources.Load("Internal/1x2AA", typeof(Texture2D)) as Texture2D; EditorZoomArea.Begin(_zoom, _networkRect); { if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null) { Handles.BeginGUI(); { Handles.color = Color.black; int i = 0; foreach (ActionConnection ac in ActionEditor.instance.currentLibraryNetwork.connections) { Vector2 toMiddle = ac.To.drawPos.Middle(); Vector2 fromMiddle = ac.From.drawPos.Middle(); Vector2 arrow1Pos = 0.5f * toMiddle + 0.5f * fromMiddle - new Vector2(5.5f, 5f); Vector2 arrow2Pos = 0.5f * toMiddle + 0.5f * fromMiddle - new Vector2(5.5f, 5f); ActionSkill top = ac.To.Position.Y > ac.From.Position.Y ? ac.From : ac.To; ActionSkill bottom = ac.OtherEnd(top); Vector3 start = new Vector3(top.drawPos.Middle().x, top.drawPos.Middle().y); Vector3 end = new Vector3(bottom.drawPos.Middle().x, bottom.drawPos.Middle().y); if (i == selectedConnection) { Handles.DrawBezier(start, end, start, end, new Color(1, 0f, 0f, 1f), _bezierTexture, 8f); } Handles.DrawBezier(start, end, start, end, new Color(1, 125f / 255f, 0f, 1f), _bezierTexture, 6f); Vector3 arrowDirection = new Vector3(toMiddle.x - fromMiddle.x, toMiddle.y - fromMiddle.y, 0f); float arrowDirectionLength = arrowDirection.magnitude; Handles.color = new Color(1f, 125f / 255f, 0f, 1f); float angle1 = Mathf.Atan2(toMiddle.y - fromMiddle.y, toMiddle.x - fromMiddle.x); Vector2 labelPos = RotatePoint(new Vector2(0, -25f), angle1); Rect arrow1box = new Rect(arrow1Pos.x + 35f * arrowDirection.x / arrowDirectionLength + labelPos.x + 5f, arrow1Pos.y + 35f * arrowDirection.y / arrowDirectionLength + labelPos.y + 5f, 7.5f + ac.fromValue.ToString().Length *7.5f, 18f); arrow1box.center -= new Vector2(arrow1box.width / 2, arrow1box.height / 2); Rect arrow2box = new Rect(arrow2Pos.x - 35f * arrowDirection.x / arrowDirectionLength - labelPos.x + 5f, arrow2Pos.y - 35f * arrowDirection.y / arrowDirectionLength - labelPos.y + 5f, 7.5f + ac.toValue.ToString().Length *7.5f, 18f); arrow2box.center -= new Vector2(arrow2box.width / 2, arrow2box.height / 2); Vector3 toVect3 = new Vector3(arrow1Pos.x + 5f + 20f * arrowDirection.x / arrowDirectionLength, arrow1Pos.y + 5f + 20f * arrowDirection.y / arrowDirectionLength, -10f); if (showNumbers) { if (ac.toValue != 0) { GUI.Label(arrow2box, ac.toValue.ToString(), GUI.skin.GetStyle("TextField")); //Handles.ArrowCap(0,toVect3,Quaternion.LookRotation(-arrowDirection),60f); } //Vector3 fromVec3 = new Vector3(arrow2Pos.x + 5f - 20f*arrowDirection.x/arrowDirectionLength,arrow2Pos.y + 5f - 20f*arrowDirection.y/arrowDirectionLength,-10f); if (ac.fromValue != 0) { GUI.Label(arrow1box, ac.fromValue.ToString(), GUI.skin.GetStyle("TextField")); //Handles.ArrowCap(0,fromVec3,Quaternion.LookRotation(arrowDirection),60f); } } if (showArrows) { if (ac.toValue != 0) { //GUI.Label(arrow2box,ac.toValue.ToString(),GUI.skin.GetStyle("TextField")); if (Mathf.Approximately(arrowDirection.sqrMagnitude, 0f)) { Handles.ArrowCap(0, toVect3, Quaternion.identity, 60f); } else { Handles.ArrowCap(0, toVect3, Quaternion.LookRotation(-arrowDirection), 60f); } } Vector3 fromVec3 = new Vector3(arrow2Pos.x + 5f - 20f * arrowDirection.x / arrowDirectionLength, arrow2Pos.y + 5f - 20f * arrowDirection.y / arrowDirectionLength, -10f); if (ac.fromValue != 0) { //GUI.Label(arrow1box,ac.fromValue.ToString (),GUI.skin.GetStyle("TextField")); if (!Mathf.Approximately(arrowDirection.sqrMagnitude, 0f)) { Handles.ArrowCap(0, fromVec3, Quaternion.LookRotation(arrowDirection), 60f); } else { Handles.ArrowCap(0, fromVec3, Quaternion.identity, 60f); } } } // if(ac.toValue == 0 && ac.fromValue == 0) // { // connectionToRemove.Add(ac); // } ++i; } if (isCreatingConnection && skillsToConnect.Count == 1) { Vector2 zoomMousePos = ConvertScreenCoordsToZoomCoords(new Vector2(_currentMousePosition.x, _currentMousePosition.y)) - new Vector2(offset.X, offset.Y); Vector2 mouseDirection = skillsToConnect[0].drawPos.Middle() - zoomMousePos; Handles.DrawBezier(new Vector3(skillsToConnect[0].drawPos.Middle().x, skillsToConnect[0].drawPos.Middle().y), new Vector3(zoomMousePos.x, zoomMousePos.y), new Vector3(skillsToConnect[0].drawPos.Middle().x - mouseDirection.x, skillsToConnect[0].drawPos.Middle().y - mouseDirection.y), new Vector3(zoomMousePos.x + mouseDirection.x, zoomMousePos.y + mouseDirection.y), new Color(1, 125f / 255f, 0f, 1f), _bezierTexture, 6f); this.Repaint(); } } Handles.EndGUI(); if (ActionEditor.instance.currentLibraryNetwork.skills != null) { int i = 0; foreach (ActionSkill actSkill in ActionEditor.instance.currentLibraryNetwork.skills) { actSkill.Draw(selectedSkills.Contains(i), actSkill == skillBeingDrawn); ++i; } } } } EditorZoomArea.End(); }
public bool IsThereConnectionBetween(ActionSkill skill1, ActionSkill skill2) { return((skill1 == To && skill2 == From) || (skill1 == From && skill2 == To)); }
public bool Contains(ActionSkill endpoint) { return(endpoint == To || endpoint == From); }
// Start is called before the first frame update void Start() { master = MasterController.instance; rb = gameObject.GetComponent <Rigidbody2D>(); col = gameObject.GetComponent <BoxCollider2D>(); //jumpSpeed = 16.5f; jumpTime = 0f; jumpTimeMax = 0.7f; grounded = false; moveSpeed = 3f; dashSpeed = 5f; moving = false; direction = 1; dashing = false; dashTimer = 0f; changeDirection = false; crouching = false; canStand = true; sliding = false; slideForce = 5f; slideTimer = 0f; slideTimerMax = 0.5f; weaponType = currWeapon.type; weaponTimerMax = weaponType.speed; weaponTimer = 0f; charging = false; chargeTimer = 0f; chargeTimeMax = 2f; shortCharge = 1f; underwater = false; waterDrag = 0.5f; terrainLayer = LayerMask.GetMask("Solid"); stats = new CharacterData.CharacterEntry(CharacterData.human, CharacterData.warrior, false, "Dummy"); //skill1 = (ActionSkill)(stats.GetSkill1().GetSkill()); skill2 = (ActionSkill)(stats.GetSkill2().GetSkill()); maxHP = stats.GetHP(true); maxMP = stats.GetMP(true); currentHP = maxHP; currentMP = maxMP; iframes = 1f; iframesTimer = 1f; hasDoubleJump = true; //stats.HasDoubleJump(); hasWallJump = true; //stats.HasWallJump(); hasRockBreaker = true; //stats.HasRockBreaker(); hasSlide = true; //stats.HasSlide(); hasSwim = true; //stats.HasSwim(); hasKey = stats.HasKey(); jumpAgain = false; againstWall = false; wallJumped = false; wallJumpFrames = 5; wallDirection = direction; height = col.bounds.size.y / 2; width = col.bounds.size.x / 2; gravity = 10f; CharacterData.currentChar = stats; }
public override void OnInspectorGUI() { if (ActionEditor.instance == null || ActionEditor.instance.currentAssetLibrary == null || ActionEditor.instance.currentLibraryNetwork == null) { GUILayout.Label("No Action Network currently loaded, please selected an Action Library from the project view" + " and press 'Edit Library' in the inspector.", ActionResources.inspectorLabel, new GUILayoutOption[0]); return; } else { GUILayout.Space(15f); GUILayout.BeginHorizontal("toolbar", new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); { GUILayout.Label("Action Skill Editor", ActionResources.boldLabel, new GUILayoutOption[0]); } GUILayout.EndHorizontal(); GUILayout.BeginVertical(); { if (ActionNetworkEditor.instance.selectedConnection.HasValue) { ActionConnection actC = ActionEditor.instance.currentLibraryNetwork.connections[ActionNetworkEditor.instance.selectedConnection.Value]; GUILayout.Space(2.5f); GUILayout.Label(actC.From.Name + "-" + actC.To.Name + " Connection", ActionResources.boldLabel, new GUILayoutOption[0]); GUILayout.Space(2.5f); GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(actC.From.Name + " to " + actC.To.Name + ":"); double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue); // if(actC.fromValue == 0 && actC.toValue == 0) // { // ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections // [ActionNetworkEditor.instance.selectedConnection.Value]; // // ActionNetworkEditor.instance.selectedConnection = null; // // ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete); // // ActionEditor.instance.SaveLibrary(); // } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(actC.To.Name + " to " + actC.From.Name + ":"); double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue); // if(actC.fromValue == 0 && actC.toValue == 0) // { // ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections // [ActionNetworkEditor.instance.selectedConnection.Value]; // // ActionNetworkEditor.instance.selectedConnection = null; // // ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete); // // ActionEditor.instance.SaveLibrary(); // } } GUILayout.EndHorizontal(); GUILayout.Space(2.5f); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Delete Connection")) { ActionConnection connectionToDelete = ActionEditor.instance.currentLibraryNetwork.connections [ActionNetworkEditor.instance.selectedConnection.Value]; ActionNetworkEditor.instance.selectedConnection = null; ActionEditor.instance.currentLibraryNetwork.connections.Remove(connectionToDelete); ActionEditor.instance.SaveLibrary(); } GUILayout.Space(10f); } GUILayout.EndHorizontal(); ActionResources.ActionSeparator(); } foreach (int i in ActionNetworkEditor.instance.selectedSkills) { ActionSkill actS = ActionEditor.instance.currentLibraryNetwork.skills[i]; GUILayout.Space(2.5f); GUILayout.Label(actS.Name, ActionResources.boldLabel, new GUILayoutOption[0]); GUILayout.Space(2.5f); GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Name: "); actS.Name = EditorGUILayout.TextField(actS.Name).Replace(" ", string.Empty); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("Q: "); double.TryParse(EditorGUILayout.TextField(actS.Q.ToString()), out actS.Q); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("B: "); double.TryParse(EditorGUILayout.TextField(actS.B.ToString()), out actS.B); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("v: "); double.TryParse(EditorGUILayout.TextField(actS.v.ToString()), out actS.v); } GUILayout.EndHorizontal(); GUILayout.Space(2.5f); GUILayout.Label("Connections", ActionResources.boldLabel, new GUILayoutOption[0]); GUILayout.Space(2.5f); foreach (ActionConnection actC in ActionEditor.instance.currentLibraryNetwork.connections) { if (actC.Contains(actS)) { ActionSkill otherEnd = actC.OtherEnd(actS); bool isToEnd = actC.isTo(actS); GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(actS.Name + " to " + otherEnd.Name + ":"); if (isToEnd) { double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue); } else { double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(otherEnd.Name + " to " + actS.Name + ":"); if (isToEnd) { double.TryParse(EditorGUILayout.TextField(actC.fromValue.ToString()), out actC.fromValue); } else { double.TryParse(EditorGUILayout.TextField(actC.toValue.ToString()), out actC.toValue); } } GUILayout.EndHorizontal(); GUILayout.Space(2.5f); } } GUILayout.Space(2.5f); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Preview skill", new GUILayoutOption[] { GUILayout.Width(125f) })) { ActionMenu.ShowSkillPreview(actS); } GUILayout.Space(10f); } GUILayout.EndHorizontal(); ActionResources.ActionSeparator(); } } GUILayout.EndVertical(); } HandleEvents(); }
private bool LeftMouseDown() { if (positioningSkill && skillBeingDrawn != null && !InsideReservedArea(new Vector2(Event.current.mousePosition.x, Event.current.mousePosition.y))) { positioningSkill = false; skillBeingDrawn.DeltaMove(new Vector2(-offset.X, -offset.Y)); skillBeingDrawn = null; ActionEditor.instance.SaveLibrary(); currentContent = empty; return(true); } //var clicked = SkillAt(new Vector2(Event.current.mousePosition.x,Event.current.mousePosition.y - 37.5f)); var clicked = SkillAt(ConvertScreenCoordsToZoomCoords(Event.current.mousePosition) - new Vector2(offset.X, offset.Y)); if (clicked != null) { selectedConnection = null; if (isCreatingConnection) { if (skillsToConnect.Count == 0) { skillsToConnect.Add(clicked); } else if (skillsToConnect.Count == 1) { if (clicked != skillsToConnect[0]) { skillsToConnect.Add(clicked); isCreatingConnection = false; currentContent = empty; GetWindow(typeof(ActionConnectionCreation), true); } else { currentContent = sameSkillForConnection; this.Repaint(); } } else { return(false); } return(true); } if (!selectedSkills.Contains(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(clicked))) { if (Event.current.modifiers != EventModifiers.Shift) { selectedSkills.Clear(); } selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(clicked)); inspectorNeedsRepaint = true; } else { if (Event.current.modifiers == EventModifiers.Shift) { selectedSkills.Remove(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(clicked)); } } return(true); } else if (clicked == null && Event.current.modifiers != EventModifiers.Alt) { var clickedConnection = ConnectionAt(ConvertScreenCoordsToZoomCoords(Event.current.mousePosition) - new Vector2(offset.X, offset.Y)); if (clickedConnection != null) { if (Event.current.clickCount == 2) { selectedSkills.Clear(); selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(clickedConnection.From)); selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(clickedConnection.To)); } selectedConnection = ActionEditor.instance.currentLibraryNetwork.connections.IndexOf(clickedConnection); return(true); } else { selectedConnection = null; } if (Event.current.modifiers != EventModifiers.Shift) { selectedSkills.Clear(); } selectBoxStart = Event.current.mousePosition; doingSelectionBox = true; return(true); } return(false); }
public bool isTo(ActionSkill skill) { return(skill == To); }
public void OnGUI() { GUILayout.BeginHorizontal("Toolbar", new GUILayoutOption[0]); { if (GUILayout.Button("Add", EditorStyles.toolbarButton, new GUILayoutOption[0])) { if (ActionEditor.instance != null) { ActionNetworkCreation.GetWindow(typeof(ActionNetworkCreation), true); } } if (GUILayout.Button("Duplicate", EditorStyles.toolbarButton, new GUILayoutOption[0])) { if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null) { if (highlightedItemType == ItemType.ActionNetwork) { int ind = 1; string copy = ActionEditor.instance.currentLibraryNetwork.name.Clone().ToString(); while (ActionEditor.instance.currentAssetLibrary.Get(copy + ind) != null) { ++ind; } copy += ind; ActionEditor.instance.currentLibraryNetwork = ActionEditor.instance.currentAssetLibrary.Add(new ActionNetwork(copy, ActionEditor.instance.currentLibraryNetwork)); ActionEditor.instance.SaveLibrary(); } else if (highlightedItemType == ItemType.ActionSkill) { int ind = 1; string copy = highlightedSkill.Name.Clone().ToString(); while (ActionEditor.instance.currentLibraryNetwork.Get(copy + ind) != null) { ++ind; } ActionSkill oldSkill = ActionEditor.instance.currentLibraryNetwork.Get(highlightedSkill.Name); copy += ind; highlightedSkill = ActionEditor.instance.currentLibraryNetwork.AddSkill(copy, highlightedSkill.Q, highlightedSkill.B, highlightedSkill.v, new EditorTwoVector(highlightedSkill.drawPos.TopLeft().x + 10f - ActionNetworkEditor.instance.offset.X, highlightedSkill.drawPos.TopLeft().y + 10f - ActionNetworkEditor.instance.offset.Y)); List <ActionConnection> newConnections = new List <ActionConnection>(); foreach (ActionConnection actC in ActionEditor.instance.currentLibraryNetwork.connections) { if (actC.Contains(oldSkill)) { if (actC.isTo(oldSkill)) { newConnections.Add(new ActionConnection(highlightedSkill, actC.From, actC.toValue, actC.fromValue, ActionEditor.instance.currentLibraryNetwork)); } else { newConnections.Add(new ActionConnection(actC.To, highlightedSkill, actC.toValue, actC.fromValue, ActionEditor.instance.currentLibraryNetwork)); } } } foreach (ActionConnection actC in newConnections) { ActionEditor.instance.currentLibraryNetwork.connections.Add(actC); } ActionNetworkEditor.instance.selectedSkills.Clear(); ActionNetworkEditor.instance.selectedSkills.Add(ActionEditor.instance.currentLibraryNetwork.skills.IndexOf(highlightedSkill)); ActionEditor.instance.SaveLibrary(); ActionNetworkEditor.instance.Repaint(); } } } if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null) { if (GUILayout.Button("Rename", EditorStyles.toolbarButton, new GUILayoutOption[0])) { editingNames = !editingNames; } } else { if (GUILayout.Button("Rename", EditorStyles.toolbarButton, new GUILayoutOption[0])) { } } if (GUILayout.Button("Delete", EditorStyles.toolbarButton, new GUILayoutOption[0])) { DeleteItems(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); if (ActionEditor.instance == null || ActionEditor.instance.currentAssetLibrary == null) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.Label("No library loaded.\n\nTo load an Action Library, select a library in the project folder then press edit in the Inspector panel", new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.EndHorizontal(); } else { this.explorerScroll = GUILayout.BeginScrollView(this.explorerScroll, new GUILayoutOption[0]); GUILayout.Label(new GUIContent(ActionEditor.instance.currentAsset.name), new GUILayoutOption[0]); ActionEditor.instance.currentLibraryNetwork = (ActionNetwork)ActionResources.SelectList(ActionEditor.instance.currentAssetLibrary.networks, ActionEditor.instance.currentLibraryNetwork, new ActionResources.OnListItemGUI(OnNetworkListItemGUI)); GUILayout.EndScrollView(); if (highlightedItemType == ItemType.ActionSkill) { ActionEditor.instance.currentLibraryNetwork = highlightedSkill.owner; } } HandleShortcutEvents(); }
public async Task UseActionSkill(ActionSkill skill) { await skill.Solve(); }