Skip to content

Commit

Permalink
Grid system WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoDeAndrade committed Oct 31, 2024
1 parent 37ea313 commit f71c510
Show file tree
Hide file tree
Showing 151 changed files with 161,308 additions and 846 deletions.
Binary file added Art/GridObject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
795 changes: 795 additions & 0 deletions Assets/DefaultVolumeProfile.asset

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Assets/DefaultVolumeProfile.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Assets/OkapiKit/Scripts/Actions/ActionChangeMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public override void Execute()
}
else if (rb)
{
velocity = rb.velocity;
velocity = rb.linearVelocity;
}

float r = Random.Range(percentageValue.x, percentageValue.y);
Expand All @@ -352,7 +352,7 @@ public override void Execute()
}
else if (rb)
{
velocity = rb.velocity;
velocity = rb.linearVelocity;
}

float r = Random.Range(value.x, value.y);
Expand Down Expand Up @@ -410,7 +410,7 @@ public override void Execute()
}
else if (rb)
{
rb.velocity = velocity;
rb.linearVelocity = velocity;
}
}
else if (changeType == ChangeType.GravityScale)
Expand Down
4 changes: 2 additions & 2 deletions Assets/OkapiKit/Scripts/Actions/ActionChangeRigidBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public override void Execute()
rb.mass = value;
break;
case ChangeType.LinearDrag:
rb.drag = value;
rb.linearDamping = value;
break;
case ChangeType.AngularDrag:
rb.angularDrag = value;
rb.angularDamping = value;
break;
case ChangeType.GravityScale:
rb.gravityScale = value;
Expand Down
2 changes: 1 addition & 1 deletion Assets/OkapiKit/Scripts/Actions/ActionTagged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void RefreshActions()
{
if (searchType == SearchType.Global)
{
targetActions = new List<Action>(GameObject.FindObjectsOfType<Action>());
targetActions = new List<Action>(GameObject.FindObjectsByType<Action>(FindObjectsSortMode.None));

targetActions.RemoveAll((action) => !action.HasTag(triggerTags));
}
Expand Down
3 changes: 0 additions & 3 deletions Assets/OkapiKit/Scripts/Base/OkapiValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public struct OkapiValue
{
public enum Type { Float = 0, Integer = 1, VariableInstance = 2, Variable = 3 };

[SerializeField] private bool init;
[SerializeField] private Type type;
[SerializeField] private VariableInstance variableInstance;
[SerializeField] private Variable variable;
Expand All @@ -20,14 +19,12 @@ public enum Type { Float = 0, Integer = 1, VariableInstance = 2, Variable = 3 };

public OkapiValue(float v) : this()
{
this.init = true;
this.type = Type.Float;
this.floatValue = v;
}

public OkapiValue(int v) : this()
{
this.init = true;
this.type = Type.Integer;
this.intValue = v;
}
Expand Down
53 changes: 53 additions & 0 deletions Assets/OkapiKit/Scripts/Editor/GridObjectEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace OkapiKit.Editor
{
[CustomEditor(typeof(GridObject))]
public class GridObjectEditor : OkapiBaseEditor
{
protected override void OnEnable()
{
base.OnEnable();
}

public override void OnInspectorGUI()
{
serializedObject.Update();

if (WriteTitle())
{
EditorGUI.BeginChangeCheck();

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 Object";
}

protected override Texture2D GetIcon()
{
return GUIUtils.GetTexture("GridObject");
}

protected override (Color, Color, Color) GetColors() => (GUIUtils.ColorFromHex("#d1d283"), GUIUtils.ColorFromHex("#2f4858"), GUIUtils.ColorFromHex("#969721"));
}
}
11 changes: 11 additions & 0 deletions Assets/OkapiKit/Scripts/Editor/GridObjectEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/OkapiKit/Scripts/Hypertag/HypertaggedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static List<T> FindObjectsByHypertag<T>(Hypertag tag, List<T> ret) where
{
if (!UnityEditor.EditorApplication.isPlaying)
{
var hos = FindObjectsOfType<HypertaggedObject>(tag);
var hos = FindObjectsByType<HypertaggedObject>(FindObjectsSortMode.None);
foreach (var ho in hos)
{
if (ho.Has(tag))
Expand Down
4 changes: 2 additions & 2 deletions Assets/OkapiKit/Scripts/Movement/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected void MoveDelta(Vector3 delta)
{
if (rb != null)
{
rb.velocity = delta / Time.deltaTime;
rb.linearVelocity = delta / Time.deltaTime;
}
else
{
Expand All @@ -44,7 +44,7 @@ protected void StopMovement()
{
if (rb != null)
{
rb.velocity = Vector2.zero;
rb.linearVelocity = Vector2.zero;
}
}

Expand Down
8 changes: 8 additions & 0 deletions Assets/OkapiKit/Scripts/Movement/MovementGrid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using UnityEngine;

namespace OkapiKit
{
public abstract class MovementGrid : Movement
{
}
}
11 changes: 11 additions & 0 deletions Assets/OkapiKit/Scripts/Movement/MovementGrid.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Assets/OkapiKit/Scripts/Movement/MovementPlatformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void FixedUpdate()
}
else if ((Time.time - jumpTime) < jumpHoldMaxTime)
{
rb.velocity = new Vector2(rb.velocity.x, speed.y);
rb.linearVelocity = new Vector2(rb.linearVelocity.x, speed.y);
}
}
else
Expand Down Expand Up @@ -545,18 +545,18 @@ void FixedUpdate()

if (limitFallSpeed)
{
var currentVelocity = rb.velocity;
var currentVelocity = rb.linearVelocity;
if (currentVelocity.y < -maxFallSpeed)
{
currentVelocity.y = -maxFallSpeed;
rb.velocity = currentVelocity;
rb.linearVelocity = currentVelocity;
}
}
}

void Jump()
{
rb.velocity = new Vector2(rb.velocity.x, speed.y);
rb.linearVelocity = new Vector2(rb.linearVelocity.x, speed.y);
jumpBufferingTimer = 0.0f;
coyoteTimer = 0;
jumpTime = Time.time;
Expand Down Expand Up @@ -634,7 +634,7 @@ void Update()
break;
}

rb.velocity = new Vector2(deltaX, rb.velocity.y);
rb.linearVelocity = new Vector2(deltaX, rb.linearVelocity.y);
}

// Need to check with actual is grounded or else coyote time will make the jump count reset immediately after flying off
Expand All @@ -653,7 +653,7 @@ void Update()
if (groundCollider) groundCollider.enabled = false;
}

var currentVelocity = rb.velocity;
var currentVelocity = rb.linearVelocity;

if ((useAnimator) && (animator))
{
Expand Down Expand Up @@ -718,7 +718,7 @@ void UpdateGroundState()
else
{
actualIsGrounded = false;
if (rb.velocity.y > 0)
if (rb.linearVelocity.y > 0)
{
coyoteTimer = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/OkapiKit/Scripts/Movement/MovementRotate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void FixedUpdate()
else if (mode == RotateMode.Movement)
{
Vector3 dir = Vector3.zero;
if (rb) dir = rb.velocity;
if (rb) dir = rb.linearVelocity;
if (dir.sqrMagnitude < 1e-6)
{
dir = transform.position - prevPosition;
Expand Down
3 changes: 0 additions & 3 deletions Assets/OkapiKit/Scripts/Movement/MovementXY.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyAttributes;
using static OkapiKit.MovementRotate;

namespace OkapiKit
{
Expand Down
Loading

0 comments on commit f71c510

Please sign in to comment.