feat: more combat tweaks
shuriken can now be thrown jumping animtions jumping animations timing state machine changes start of online integration
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using Reset.Units;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unity.Cinemachine;
|
||||
using Unity.Services.Matchmaker.Models;
|
||||
|
||||
// This class receives input from a PlayerInput component and disptaches it
|
||||
// to the appropriate Cinemachine InputAxis. The playerInput component should
|
||||
@@ -32,7 +34,7 @@ class CustomInputHandler : InputAxisControllerBase<CustomInputHandler.Reader>
|
||||
// We process user input on the Update clock
|
||||
void Update()
|
||||
{
|
||||
if (Application.isPlaying){
|
||||
if (Application.isPlaying && PlayerManager.Player){
|
||||
UpdateControllers();
|
||||
Controllers[0].Input.ProcessInput(PlayerInput);
|
||||
Controllers[1].Input.ProcessInput(PlayerInput);
|
||||
|
||||
@@ -26,6 +26,11 @@ public class EnvironmentObserver{
|
||||
BoxCast,
|
||||
SphereCast
|
||||
}
|
||||
|
||||
public enum CastOrigin{
|
||||
Owner,
|
||||
Location
|
||||
}
|
||||
|
||||
[PropertySpace(0, 5), LabelWidth(60)]
|
||||
public string label;
|
||||
@@ -40,6 +45,8 @@ public class EnvironmentObserver{
|
||||
[HideInInspector]
|
||||
public bool active;
|
||||
|
||||
public CastOrigin castOrigin;
|
||||
|
||||
// Parameters for Cast cast types
|
||||
[FoldoutGroup("Settings")] [HideIf("@castType == CastType.BoxOverlap || castType == CastType.SphereOverlap")]
|
||||
public float length;
|
||||
|
||||
60
Assets/Scripts/Units/Graph Tasks/CheckWeaponActorVariable.cs
Normal file
60
Assets/Scripts/Units/Graph Tasks/CheckWeaponActorVariable.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Items{
|
||||
|
||||
[Category("Reset/Combat")]
|
||||
[Description("Check if the provided value matches the weapon actor's variable")]
|
||||
public class CheckWeaponActorVariable<T> : ConditionTask<Transform> where T : class{
|
||||
public BBParameter<string> variable;
|
||||
public BBParameter<T> value;
|
||||
|
||||
WeaponActor actor;
|
||||
|
||||
protected override string info{
|
||||
get{ return $"weapon actor variable <b>{variable.value}</b> is <b><i>{value.value}</b></i>"; }
|
||||
}
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit(){
|
||||
return null;
|
||||
}
|
||||
|
||||
//Called whenever the condition gets enabled.
|
||||
protected override void OnEnable(){
|
||||
actor = agent.GetComponent<WeaponActor>();
|
||||
}
|
||||
|
||||
//Called whenever the condition gets disabled.
|
||||
protected override void OnDisable(){
|
||||
|
||||
}
|
||||
|
||||
//Called once per frame while the condition is active.
|
||||
//Return whether the condition is success or failure.
|
||||
protected override bool OnCheck(){
|
||||
if (!actor) {
|
||||
Debug.LogError(
|
||||
$"No weapon actor variable found on this player. Cannot check for value of {variable.value}.",
|
||||
agent);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (actor.weaponVariables.ContainsKey(variable.value)) {
|
||||
T valueAsType = value.value;
|
||||
|
||||
Debug.Log((T)actor.weaponVariables[variable.value]);
|
||||
Debug.Log(valueAsType);
|
||||
return ((T)actor.weaponVariables[variable.value]).Equals(valueAsType);
|
||||
|
||||
} else {
|
||||
Debug.LogError($"No variable found by name {variable.value} on the weapon actor", agent);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33a915cdda8127941aa56ed4e845d813
|
||||
57
Assets/Scripts/Units/Graph Tasks/GetCurrentTarget.cs
Normal file
57
Assets/Scripts/Units/Graph Tasks/GetCurrentTarget.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset")]
|
||||
[Description("Get the current target and save it to a graph variable")]
|
||||
public class GetCurrentTarget : ActionTask<LockOnManager>{
|
||||
public BBParameter<Transform> target;
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
if (agent.mainTarget == null) {
|
||||
Debug.LogWarning("There is no LockOnTarget to save as current target");
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
target.value = agent.mainTarget.gameObject.transform;
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed to save the current LockOnTarget target: {e.Message}");
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13713276d513eea4186f28ea39cbf302
|
||||
50
Assets/Scripts/Units/Graph Tasks/GetWeaponActorVariable.cs
Normal file
50
Assets/Scripts/Units/Graph Tasks/GetWeaponActorVariable.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Items {
|
||||
|
||||
[Category("Reset/Combat")]
|
||||
[Description("Retrieve the valule of a weapon actor variable")]
|
||||
public class GetWeaponActorVariable<T> : ActionTask<Transform>{
|
||||
public BBParameter<string> variable;
|
||||
public BBParameter<T> saveValueTo;
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
WeaponActor actor = agent.GetComponent<WeaponActor>();
|
||||
|
||||
if (!actor) {
|
||||
Debug.LogError($"No weapon actor variable found on this player. Cannot check for value of {variable.value}.", agent);
|
||||
EndAction(false);
|
||||
}
|
||||
|
||||
saveValueTo.value = (T)actor.weaponVariables[variable.value];
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f379bc09216af524290d9b72067031d5
|
||||
56
Assets/Scripts/Units/Graph Tasks/SendWeaponActorEvent.cs
Normal file
56
Assets/Scripts/Units/Graph Tasks/SendWeaponActorEvent.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Items;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items {
|
||||
|
||||
[Category("Reset/Combat")]
|
||||
[Description("Sends a named event as a string to the current weapon's WeaponActor.")]
|
||||
public class SendWeaponActorEvent : ActionTask<Transform>{
|
||||
|
||||
public BBParameter<string> weaponEvent;
|
||||
|
||||
protected override string info{
|
||||
get{ return $"Send weapon event <b>{weaponEvent.value}</b>"; }
|
||||
}
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
WeaponActor actor = agent.GetComponent<WeaponActor>();
|
||||
|
||||
if (actor == null) {
|
||||
Debug.LogError("No WeaponActor was found on this player.");
|
||||
EndAction(false);
|
||||
}
|
||||
|
||||
actor.DoWeaponEvent(weaponEvent.value);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 567e649f23e3ba44ea1339e928d17b83
|
||||
61
Assets/Scripts/Units/Graph Tasks/SetWeaponActorVariable.cs
Normal file
61
Assets/Scripts/Units/Graph Tasks/SetWeaponActorVariable.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Items {
|
||||
|
||||
[Category("Reset/Combat")]
|
||||
[Description("Set an existing or new weapon actor variable to the defined value.")]
|
||||
public class SetWeaponActorVariable : ActionTask<Transform>{
|
||||
public BBParameter<string> variable;
|
||||
public BBParameter<object> value;
|
||||
|
||||
protected override string info{
|
||||
get{ return $"Set weapon variable <b>{variable.value}</b> == <i>{value.name}</i>"; }
|
||||
}
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
WeaponActor actor = agent.GetComponent<WeaponActor>();
|
||||
|
||||
if (actor == null) {
|
||||
Debug.LogError("No WeaponActor was found on this player.");
|
||||
EndAction(false);
|
||||
}
|
||||
|
||||
try {
|
||||
actor.RegisterWeaponVariable(variable.value, value.value);
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed to set weapon variable '{variable.value}': {e.Message} ");
|
||||
EndAction(false);
|
||||
}
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is disabled.
|
||||
protected override void OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//Called when the task is paused.
|
||||
protected override void OnPause() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff6862d725648584c89631637986f89c
|
||||
@@ -1,7 +1,75 @@
|
||||
using Reset.Core;
|
||||
using Reset.Items;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class PlayerCombat : UnitCombat{
|
||||
public CombatType currentCombatType;
|
||||
|
||||
private IEquipable currentWeapon;
|
||||
private GameObject currentWeaponItem;
|
||||
|
||||
public void OnDrawWeapon(){
|
||||
if (Unit.UnitIsNetworked()) {
|
||||
CreatePlayerWeaponRpc();
|
||||
} else {
|
||||
CreatePlayerWeapon();
|
||||
}
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Everyone)]
|
||||
public void CreatePlayerWeaponRpc(){
|
||||
CreatePlayerWeapon();
|
||||
}
|
||||
|
||||
public void CreatePlayerWeapon(){
|
||||
// Remove a current weapon
|
||||
DisposeCurrentWeapon();
|
||||
|
||||
// Reference inventory and inventory
|
||||
PlayerInventory playerInventory = Unit.Inventory as PlayerInventory;
|
||||
PlayerAnimation playerAnimation = Unit.Animation as PlayerAnimation;
|
||||
|
||||
// Add weapon to status and hand
|
||||
currentWeapon = playerInventory.meleeWeapon;
|
||||
currentWeaponItem = playerInventory.meleeWeapon.InstantiateItemObject();
|
||||
|
||||
// Move item to hand
|
||||
currentWeaponItem.transform.SetParent(playerAnimation.rightHand);
|
||||
currentWeaponItem.transform.localPosition = playerInventory.meleeWeapon.handPositionOffset;
|
||||
currentWeaponItem.transform.rotation = playerAnimation.rightHand.rotation * Quaternion.Euler(playerInventory.meleeWeapon.handRotationOffset);
|
||||
|
||||
// Add related weapon's actor script
|
||||
(currentWeapon as Weapon).AddActorScript();
|
||||
}
|
||||
|
||||
public GameObject GetCurrentWeaponItem(){
|
||||
return currentWeaponItem;
|
||||
}
|
||||
|
||||
public void OnHolsterWeapon(){
|
||||
DisposeCurrentWeapon();
|
||||
}
|
||||
|
||||
public void DisposeCurrentWeapon(){
|
||||
// Return if no weapon active
|
||||
if (currentWeapon == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy physical mesh
|
||||
Destroy(currentWeaponItem);
|
||||
|
||||
// Destroy weapon actor
|
||||
if ((GetComponent<WeaponActor>()) != null) {
|
||||
Destroy(GetComponent<WeaponActor>());
|
||||
}
|
||||
|
||||
// Remove references
|
||||
currentWeaponItem = null;
|
||||
currentWeapon = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Tasks.Actions;
|
||||
using Reset.Items;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class PlayerInventory : UnitComponent, IInventory {
|
||||
public class PlayerInventory : UnitComponent, IInventory{
|
||||
public Weapon rangedWeapon;
|
||||
public Weapon meleeWeapon;
|
||||
|
||||
@@ -14,49 +13,7 @@ namespace Reset.Units{
|
||||
public Ability toolAbility1;
|
||||
public Ability toolAbility2;
|
||||
|
||||
public List<Item> storedItems { get; set; }
|
||||
|
||||
private IEquipable currentWeapon;
|
||||
private GameObject currentWeaponItem;
|
||||
|
||||
public void OnDrawWeapon(){
|
||||
// Remove a current weapon
|
||||
if (currentWeapon != null) {
|
||||
Destroy(currentWeaponItem);
|
||||
currentWeaponItem = null;
|
||||
}
|
||||
|
||||
// Add weapon to status and hand
|
||||
currentWeapon = meleeWeapon;
|
||||
currentWeaponItem = meleeWeapon.PlaceInHand();
|
||||
|
||||
// Move item to hand
|
||||
currentWeaponItem.transform.SetParent((Unit.Animation as PlayerAnimation).rightHand);
|
||||
currentWeaponItem.transform.localPosition = meleeWeapon.handPositionOffset;
|
||||
currentWeaponItem.transform.rotation = (Unit.Animation as PlayerAnimation).rightHand.rotation * Quaternion.Euler(meleeWeapon.handRotationOffset);
|
||||
|
||||
Debug.Log(currentWeapon);
|
||||
|
||||
//
|
||||
(currentWeapon as Weapon).AddActorScript();
|
||||
|
||||
//
|
||||
// Unit.Graph.SendEvent("Draw Weapon");
|
||||
}
|
||||
|
||||
public GameObject GetCurrentWeaponItem(){
|
||||
return currentWeaponItem;
|
||||
}
|
||||
|
||||
public void OnHolsterWeapon(){
|
||||
Destroy(currentWeaponItem);
|
||||
currentWeaponItem = null;
|
||||
currentWeapon = null;
|
||||
|
||||
Debug.Log(currentWeapon);
|
||||
//
|
||||
// Unit.Graph.SendEvent("Holster Weapon");
|
||||
}
|
||||
public List<Item> storedItems{ get; set; }
|
||||
|
||||
public void EquipToCharacter(Item item){
|
||||
if (item is not IEquipable) {
|
||||
@@ -73,11 +30,5 @@ namespace Reset.Units{
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,20 @@ namespace Reset.Units{
|
||||
}
|
||||
|
||||
private UnitAnimation _animation;
|
||||
|
||||
internal UnitAnimation Animation{
|
||||
get {
|
||||
if (_animation == null) { _animation = GetComponent<UnitAnimation>(); }
|
||||
return _animation;
|
||||
}
|
||||
}
|
||||
|
||||
private IInventory _inventory;
|
||||
internal IInventory Inventory{
|
||||
get {
|
||||
if (_inventory == null) { _inventory = GetComponent<IInventory>(); }
|
||||
return _inventory;
|
||||
}
|
||||
}
|
||||
|
||||
// Debug and Gizmos
|
||||
public NetworkVariable<FixedString64Bytes> graphStateAsString;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Unity.Netcode.Components;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
@@ -18,6 +19,8 @@ namespace Reset.Units{
|
||||
|
||||
// Temporary
|
||||
private float inputMagnitude;
|
||||
|
||||
private NetworkAnimator netAnimator;
|
||||
|
||||
void Update(){
|
||||
// Temporary
|
||||
@@ -34,8 +37,19 @@ namespace Reset.Units{
|
||||
modelAnimator.SetFloat("Gravity", Unit.Movement.resolvedMovement.gravity);
|
||||
|
||||
modelAnimator.SetBool("Grounded", Physics.Raycast(transform.position, Vector3.down, .2f));
|
||||
|
||||
Debug.Log(Unit.Movement.GetGrounded());
|
||||
}
|
||||
|
||||
public void SendAnimationTrigger(string trigger){
|
||||
if (Unit.UnitIsNetworked()) {
|
||||
try {
|
||||
netAnimator.SetTrigger(trigger);
|
||||
} catch (Exception e){
|
||||
Debug.LogError($"Failed to send network animation trigger: {e.Message}");
|
||||
}
|
||||
|
||||
} else {
|
||||
modelAnimator.SetTrigger(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate(){
|
||||
|
||||
@@ -54,7 +54,9 @@ namespace Reset.Units{
|
||||
DoMovement(resolvedMovement.moveDirection.World, resolvedMovement.gravity, resolvedMovement.moveSpeed, data.gravityScale.Value);
|
||||
|
||||
// Apply movespeed to the Animator
|
||||
Unit.Animation.moveSpeed = resolvedMovement.moveSpeed * resolvedMovement.moveDirection.Local.magnitude / data.moveSpeed.currentValue;
|
||||
if (transform.gameObject == PlayerManager.Player){ // temp
|
||||
Unit.Animation.moveSpeed = resolvedMovement.moveSpeed * resolvedMovement.moveDirection.Local.magnitude / data.moveSpeed.currentValue;
|
||||
}
|
||||
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Move Direction (Local)", resolvedMovement.moveDirection.Local);
|
||||
DebugOverlayDrawer.ChangeValue("Movement", "Move Direction (World)", resolvedMovement.moveDirection.World);
|
||||
|
||||
Reference in New Issue
Block a user