-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grid version os XY, follow and forward movement Animation support on Grid XY movement (needs to extend to normal XY movement) Added GridSystem and GridObject concepts, to allow for pushing, etc
- Loading branch information
1 parent
f71c510
commit 6082b22
Showing
90 changed files
with
7,234 additions
and
405 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using UnityEngine; | ||
using static OkapiKit.GridHelpers; | ||
|
||
namespace OkapiKit | ||
{ | ||
public static class GridHelpers | ||
{ | ||
|
||
|
||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace OkapiKit | ||
{ | ||
public static class Helpers | ||
{ | ||
public static void CheckErrorAnim(Animator anm, string logParameter, string parameterName, AnimatorControllerParameterType type, List<LogEntry> ret) | ||
{ | ||
if (parameterName == "") | ||
{ | ||
return; | ||
} | ||
for (int i = 0; i < anm.parameterCount; i++) | ||
{ | ||
var param = anm.GetParameter(i); | ||
if (param.name == parameterName) | ||
{ | ||
if (param.type != type) | ||
{ | ||
ret.Add(new LogEntry(LogEntry.Type.Error, $"Animation parameter type {parameterName} for {logParameter} is of wrong type (expected {type}, found {param.type})!", $"Animation parameter type {parameterName} for {logParameter} is of wrong type (expected {type}, found {param.type})!")); | ||
} | ||
return; | ||
} | ||
} | ||
|
||
ret.Add(new LogEntry(LogEntry.Type.Error, $"Animation parameter {parameterName} for {logParameter} not found!", "The given animator doesn't have this parameter. Either set it to empty (so we don't try to drive it), or add it on the animator.")); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace OkapiKit.Editor | ||
{ | ||
[CustomEditor(typeof(GridSystem))] | ||
public class GridSystemEditor : OkapiBaseEditor | ||
{ | ||
SerializedProperty propGridcolliders; | ||
|
||
protected override void OnEnable() | ||
{ | ||
base.OnEnable(); | ||
|
||
propGridcolliders = serializedObject.FindProperty("gridcolliders"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
if (WriteTitle()) | ||
{ | ||
EditorGUI.BeginChangeCheck(); | ||
|
||
EditorGUILayout.PropertyField(propGridcolliders, new GUIContent("Grid Colliders", "These colliders will be used when we detect if the children grid objects can move through the environment.\nNormally, this is a list of the Tilemap Colliders or Composite Colliders of the tilemap below.")); | ||
|
||
EditorGUI.EndChangeCheck(); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
(target as OkapiElement).UpdateExplanation(); | ||
} | ||
} | ||
|
||
protected override GUIStyle GetTitleSyle() | ||
{ | ||
return GUIUtils.GetActionTitleStyle(); | ||
} | ||
|
||
protected override GUIStyle GetExplanationStyle() | ||
{ | ||
return GUIUtils.GetActionExplanationStyle(); | ||
} | ||
|
||
protected override string GetTitle() | ||
{ | ||
return "Grid System"; | ||
} | ||
|
||
protected override Texture2D GetIcon() | ||
{ | ||
return GUIUtils.GetTexture("GridObject"); | ||
} | ||
|
||
protected override (Color, Color, Color) GetColors() => (GUIUtils.ColorFromHex("#93c08b"), GUIUtils.ColorFromHex("#2f4858"), GUIUtils.ColorFromHex("#527d4a")); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
Assets/OkapiKit/Scripts/Editor/MovementGridFollowEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace OkapiKit.Editor | ||
{ | ||
[CustomEditor(typeof(MovementGridFollow))] | ||
public class MovementGridFollowEditor : MovementEditor | ||
{ | ||
SerializedProperty propSpeed; | ||
SerializedProperty propTargetType; | ||
SerializedProperty propTargetTag; | ||
SerializedProperty propTargetObject; | ||
SerializedProperty propRelativeMovement; | ||
SerializedProperty propRotateTowardsDirection; | ||
SerializedProperty propAlignAxis; | ||
SerializedProperty propMaxRotationSpeed; | ||
SerializedProperty propCameraObject; | ||
SerializedProperty propCameraTag; | ||
SerializedProperty propCooldown; | ||
SerializedProperty propPushStrength; | ||
|
||
protected override void OnEnable() | ||
{ | ||
base.OnEnable(); | ||
|
||
propSpeed = serializedObject.FindProperty("speed"); | ||
propTargetType = serializedObject.FindProperty("targetType"); | ||
propTargetTag = serializedObject.FindProperty("targetTag"); | ||
propTargetObject = serializedObject.FindProperty("targetObject"); | ||
propRelativeMovement = serializedObject.FindProperty("relativeMovement"); | ||
propRotateTowardsDirection = serializedObject.FindProperty("rotateTowardsDirection"); | ||
propAlignAxis = serializedObject.FindProperty("alignAxis"); | ||
propMaxRotationSpeed = serializedObject.FindProperty("maxRotationSpeed"); | ||
propCameraObject = serializedObject.FindProperty("cameraObject"); | ||
propCameraTag = serializedObject.FindProperty("cameraTag"); | ||
propCooldown = serializedObject.FindProperty("cooldown"); | ||
propPushStrength = serializedObject.FindProperty("pushStrength"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
if (WriteTitle()) | ||
{ | ||
EditorGUI.BeginChangeCheck(); | ||
|
||
DefaultMovementEditor(); | ||
|
||
EditorGUILayout.PropertyField(propSpeed, new GUIContent("Speed", "Maximum follow speed")); | ||
EditorGUILayout.PropertyField(propCooldown, new GUIContent("Cooldown", "Time between grid movements")); | ||
EditorGUILayout.PropertyField(propTargetType, new GUIContent("Target Type", "Type of target to follow.\nTag: Find the closest object tagged with the given tag, and follow it\nObject: Follow the linked object\nMouse: Follow the mouse cursor")); | ||
|
||
MovementFollow.TargetType type = (MovementFollow.TargetType)propTargetType.intValue; | ||
switch (type) | ||
{ | ||
case MovementFollow.TargetType.Tag: | ||
EditorGUILayout.PropertyField(propTargetTag, new GUIContent("Target Tag", "Find objects with this tag, and follow the closest one.")); | ||
break; | ||
case MovementFollow.TargetType.Object: | ||
EditorGUILayout.PropertyField(propTargetObject, new GUIContent("Target Object", "Follow this object.")); | ||
break; | ||
case MovementFollow.TargetType.Mouse: | ||
if (propCameraTag.objectReferenceValue == null) | ||
{ | ||
if (propCameraObject.objectReferenceValue == null) | ||
{ | ||
EditorGUILayout.PropertyField(propCameraTag, new GUIContent("Camera Tag", "Tag on the camera.\nYou can select the camera either by tag or by linking it, but not both at the same time.\nBy tag is the prefered method.")); | ||
EditorGUILayout.PropertyField(propCameraObject, new GUIContent("Camera Object", "Camera object.\nYou can select the camera either by tag or by linking it, but not both at the same time.\nBy tag is the prefered method.")); | ||
} | ||
else | ||
{ | ||
EditorGUILayout.PropertyField(propCameraObject, new GUIContent("Camera Object", "Camera object.\nYou can select the camera either by tag or by linking it, but not both at the same time.\nBy tag is the prefered method.")); | ||
} | ||
} | ||
else | ||
{ | ||
EditorGUILayout.PropertyField(propCameraTag, new GUIContent("Camera Tag", "Tag on the camera.\nYou can select the camera either by tag or by linking it, but not both at the same time.\nBy tag is the prefered method.")); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
if (type != MovementFollow.TargetType.Mouse) | ||
{ | ||
EditorGUILayout.PropertyField(propRelativeMovement, new GUIContent("Relative Movement", "Is the follow movement relative?\nIf on, the object will preserve the relative position to the object being followed.")); | ||
} | ||
|
||
EditorGUILayout.PropertyField(propRotateTowardsDirection, new GUIContent("Align With Direction", "If on, the object will be turned towards the target object.")); | ||
if (propRotateTowardsDirection.boolValue) | ||
{ | ||
EditorGUILayout.PropertyField(propAlignAxis, new GUIContent("Alignment Axis", "Alignment axis (i.e. is the object pointing to the right or up?)")); | ||
EditorGUILayout.PropertyField(propMaxRotationSpeed, new GUIContent("Max Rotation Speed", "What's the maximum rotation speed (degrees per second)?")); | ||
} | ||
|
||
EditorGUILayout.PropertyField(propPushStrength, new GUIContent("Push Strength", "This is the strength which is used to push other objects.\nThis is matched with the mass of the objects, and can be accumulated (i.e. you need a strength of 2 to push two objects with 1 mass at the same time).\nA strenght of zero disables the push system.")); | ||
|
||
EditorGUILayout.PropertyField(propDescription, new GUIContent("Description", "This is for you to leave a comment for yourself or others.")); | ||
|
||
EditorGUI.EndChangeCheck(); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
(target as OkapiElement).UpdateExplanation(); | ||
|
||
StdEditor(false); | ||
} | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/OkapiKit/Scripts/Editor/MovementGridFollowEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
Assets/OkapiKit/Scripts/Editor/MovementGridForwardEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace OkapiKit.Editor | ||
{ | ||
[CustomEditor(typeof(MovementGridForward))] | ||
public class MovementGridForwardEditor : MovementEditor | ||
{ | ||
SerializedProperty propSpeed; | ||
SerializedProperty propAxis; | ||
SerializedProperty propCooldown; | ||
SerializedProperty propPushStrength; | ||
|
||
protected override void OnEnable() | ||
{ | ||
base.OnEnable(); | ||
|
||
propSpeed = serializedObject.FindProperty("speed"); | ||
propAxis = serializedObject.FindProperty("axis"); | ||
propCooldown = serializedObject.FindProperty("cooldown"); | ||
propPushStrength = serializedObject.FindProperty("pushStrength"); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
if (WriteTitle()) | ||
{ | ||
EditorGUI.BeginChangeCheck(); | ||
|
||
DefaultMovementEditor(); | ||
|
||
EditorGUILayout.PropertyField(propSpeed, new GUIContent("Speed", "What's the movement speed (pixels/second)?")); | ||
EditorGUILayout.PropertyField(propAxis, new GUIContent("Axis", "What is forward (i.e. is the object point to the right, or pointing up?)")); | ||
|
||
EditorGUILayout.PropertyField(propCooldown, new GUIContent("Cooldown", "Time between grid movements")); | ||
|
||
EditorGUILayout.PropertyField(propPushStrength, new GUIContent("Push Strength", "This is the strength which is used to push other objects.\nThis is matched with the mass of the objects, and can be accumulated (i.e. you need a strength of 2 to push two objects with 1 mass at the same time).\nA strenght of zero disables the push system.")); | ||
|
||
EditorGUILayout.PropertyField(propDescription, new GUIContent("Description", "This is for you to leave a comment for yourself or others.")); | ||
|
||
EditorGUI.EndChangeCheck(); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
(target as OkapiElement).UpdateExplanation(); | ||
|
||
StdEditor(false); | ||
} | ||
} | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/OkapiKit/Scripts/Editor/MovementGridForwardEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.