3 Commits

43 changed files with 39 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="SinglePage" picking-mode="Ignore" style="background-color: rgba(204, 142, 84, 0.31); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border-left-color: rgba(255, 160, 61, 0.94); border-right-color: rgba(255, 160, 61, 0.94); border-top-color: rgba(255, 160, 61, 0.94); border-bottom-color: rgba(255, 160, 61, 0.94); border-top-width: 7px; border-right-width: 0.5px; border-bottom-width: 0.5px; border-left-width: 0.5px; width: auto; margin-right: 12px; max-width: 175px;"> <ui:VisualElement name="SinglePage" picking-mode="Ignore" style="background-color: rgba(204, 142, 84, 0.31); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border-left-color: rgba(255, 160, 61, 0.94); border-right-color: rgba(255, 160, 61, 0.94); border-top-color: rgba(255, 160, 61, 0.94); border-bottom-color: rgba(255, 160, 61, 0.94); border-top-width: 7px; border-right-width: 0.5px; border-bottom-width: 0.5px; border-left-width: 0.5px; width: auto; margin-right: 12px; max-width: 175px;">
<ui:Label text="Page Label" name="PageLabel" style="padding-right: 10px; padding-left: 10px; color: rgb(255, 255, 255); -unity-font-style: bold; padding-top: 10px; padding-bottom: 10px; flex-shrink: 1;" /> <ui:Label text="Page Label" name="PageLabel" picking-mode="Ignore" style="padding-right: 10px; padding-left: 10px; color: rgb(255, 255, 255); -unity-font-style: bold; padding-top: 10px; padding-bottom: 10px; flex-shrink: 1;" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -1,3 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="ValuesContainer" picking-mode="Ignore" style="flex-grow: 1; margin-top: 0; padding-top: 0; padding-right: 20px; padding-bottom: 20px; padding-left: 20px; flex-shrink: 0;" /> <ui:VisualElement name="ValuesContainer" picking-mode="Ignore" style="flex-grow: 1; margin-top: 0; padding-top: 0; padding-right: 20px; padding-bottom: 20px; padding-left: 20px; flex-shrink: 0; align-self: flex-start; align-items: flex-start;" />
</ui:UXML> </ui:UXML>

View File

@@ -1,5 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="StretchBG" picking-mode="Ignore" style="width: 100%; height: auto;"> <ui:VisualElement name="StretchBG" picking-mode="Ignore" style="width: auto; height: auto; align-items: flex-start; align-self: flex-start;">
<ui:VisualElement name="Pages" style="flex-direction: row; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px;" /> <ui:VisualElement name="Pages" style="flex-direction: row; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px;" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -1,6 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement picking-mode="Ignore" style="align-items: flex-start; margin-bottom: 10px;"> <ui:VisualElement picking-mode="Ignore" name="VisualElement" style="margin-bottom: 10px; align-items: auto; width: auto; justify-content: flex-start; align-self: flex-start;">
<ui:VisualElement name="VisualElement" style="max-width: 400px;"> <ui:VisualElement name="VisualElement" picking-mode="Ignore" style="max-width: 400px;">
<ui:VisualElement name="LabelBackground" style="background-color: rgba(255, 144, 55, 0.47); border-top-left-radius: 2px; border-top-right-radius: 2px; padding-right: 10px; padding-left: 10px;"> <ui:VisualElement name="LabelBackground" style="background-color: rgba(255, 144, 55, 0.47); border-top-left-radius: 2px; border-top-right-radius: 2px; padding-right: 10px; padding-left: 10px;">
<ui:Label text="Label" name="Label" style="font-size: 15px; -unity-font-style: bold; color: rgb(255, 255, 255); padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 8px;" /> <ui:Label text="Label" name="Label" style="font-size: 15px; -unity-font-style: bold; color: rgb(255, 255, 255); padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 8px;" />
</ui:VisualElement> </ui:VisualElement>

View File

@@ -1,10 +1,11 @@
using NodeCanvas.Editor; #if UNITY_EDITOR
using NodeCanvas.Editor;
using ParadoxNotion.Design; using ParadoxNotion.Design;
using Reset.Core; using Reset.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
#if UNITY_EDITOR
public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> { public class BoolValueGroupDrawer : ObjectDrawer<BoolValueGroup> {
public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){ public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){
// Remove label for floats // Remove label for floats

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Reset.Core.Tools; using Reset.Core.Tools;
using Reset.Units; using Reset.Units;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random;
public class UnitCombat : MonoBehaviour{ public class UnitCombat : MonoBehaviour{
public List<Collider> draggedUnits = new List<Collider>(); public List<Collider> draggedUnits = new List<Collider>();
@@ -14,6 +15,8 @@ public class UnitCombat : MonoBehaviour{
private float lastSpeed; private float lastSpeed;
private float speedDelta; private float speedDelta;
private float sinAmplitude;
private float sinOffset;
void Awake(){ void Awake(){
movement = GetComponent<UnitMovementHandler>(); movement = GetComponent<UnitMovementHandler>();
@@ -21,24 +24,39 @@ public class UnitCombat : MonoBehaviour{
void Start(){ void Start(){
lastPosition = transform.position; lastPosition = transform.position;
sinOffset = Random.value;
sinAmplitude = 1 + Random.value / 4f;
} }
// Update is called once per frame // Update is called once per frame
void Update(){ void Update(){
positionDelta = lastPosition.DirectionTo(transform.position); DragAttackedUnits();
}
void DragAttackedUnits(){
// Get the original difference in position for speed and direction
positionDelta = Vector3.Lerp(positionDelta, lastPosition.DirectionTo(transform.position), 5f * Time.deltaTime);
speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime; speedDelta = Vector3.Distance(lastPosition, transform.position) / Time.deltaTime;
// Add some randomness to the movements based on small offsets
float sinVal = Mathf.Sin(2f + sinOffset) * sinAmplitude;
speedDelta += sinVal;
// Test // Set a floor to prevent them from not moving enough
speedDelta *= 1.0f;
speedDelta = Mathf.Max(3f, speedDelta); speedDelta = Mathf.Max(3f, speedDelta);
// Multiply the speed to be lower when further, and faster when close
float speedDiff = Mathf.Lerp(.2f, 1.4f, speedDelta); float speedDiff = Mathf.Lerp(.2f, 1.4f, speedDelta);
speedDelta *= speedDiff; speedDelta *= speedDiff;
// Debug
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Position Delta", positionDelta); DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Position Delta", positionDelta);
DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Speed Delta", speedDelta); DebugOverlayDrawer.ChangeValue($"Combat - {name}", "Speed Delta", speedDelta);
// Update last known position
lastPosition = transform.position; lastPosition = transform.position;
// Apply the speed, direction, and rotation to each unit
foreach (Collider draggedUnit in draggedUnits) { foreach (Collider draggedUnit in draggedUnits) {
UnitMovementHandler draggedUnitMovement = draggedUnit.GetComponent<UnitMovementHandler>(); UnitMovementHandler draggedUnitMovement = draggedUnit.GetComponent<UnitMovementHandler>();
if (!draggedUnitMovement) { if (!draggedUnitMovement) {

View File

@@ -10,9 +10,8 @@ using Sirenix.OdinInspector;
using Sirenix.Serialization; using Sirenix.Serialization;
using Unity.Netcode; using Unity.Netcode;
public class Player : NetworkBehaviour, IKillable{ public class Player : Unit, IKillable{
[HideInInspector] public PlayerControls controls; [HideInInspector] public PlayerControls controls;
[HideInInspector] public new PlayerCamera camera;
float IKillable.maxHealth{ get; set; } float IKillable.maxHealth{ get; set; }
float IKillable.currentHealth{ get; set; } float IKillable.currentHealth{ get; set; }
@@ -89,4 +88,4 @@ public class Player : NetworkBehaviour, IKillable{
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }

View File

@@ -0,0 +1,4 @@
using Unity.Netcode;
public class Unit : NetworkBehaviour{
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d9f5c0c9bf384882925c15b3c93fff1b
timeCreated: 1759554015