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,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items{
|
||||
public abstract class Item : ScriptableObject{
|
||||
public abstract class Item : SerializedScriptableObject{
|
||||
public string itemName;
|
||||
|
||||
public float permanency;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using Drawing;
|
||||
using NodeCanvas.StateMachines;
|
||||
using NodeCanvas.Framework;
|
||||
using Reset.Core;
|
||||
using Reset.Units;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items{
|
||||
@@ -18,6 +21,8 @@ namespace Reset.Items{
|
||||
|
||||
public string actorScriptName;
|
||||
|
||||
[OdinSerialize, ShowInInspector] public Type actorScript;
|
||||
|
||||
public void AddActorScript(){
|
||||
// Type actorScript = Type.GetType("ShurikenActor");
|
||||
//
|
||||
@@ -26,10 +31,17 @@ namespace Reset.Items{
|
||||
// return;
|
||||
// }
|
||||
|
||||
WeaponActor weaponActor = PlayerManager.Player.AddComponent<ShurikenActor>() as WeaponActor;
|
||||
|
||||
weaponActor.relatedObject = PlayerManager.Player.GetComponent<PlayerInventory>().GetCurrentWeaponItem();
|
||||
weaponActor.relatedWeapon = this;
|
||||
try {
|
||||
if (actorScript != null) {
|
||||
WeaponActor weaponActor = PlayerManager.Player.AddComponent(actorScript) as WeaponActor;
|
||||
|
||||
weaponActor.relatedObject = PlayerManager.Player.GetComponent<PlayerCombat>().GetCurrentWeaponItem();
|
||||
weaponActor.relatedWeapon = this;
|
||||
weaponActor.relatedGraph = PlayerManager.Player.GetComponent<GraphOwner>();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawItemInfo(Vector3 position){
|
||||
@@ -37,9 +49,10 @@ namespace Reset.Items{
|
||||
Draw.ingame.Label2D(position + Vector3.up * 1.35f, "Speed goes here");
|
||||
}
|
||||
|
||||
public GameObject PlaceInHand(){
|
||||
return GameObject.Instantiate(weaponModel);
|
||||
|
||||
|
||||
public GameObject InstantiateItemObject(){
|
||||
return GameObject.Instantiate(weaponModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Reset.Items{
|
||||
public abstract class WeaponActor : MonoBehaviour{
|
||||
public Dictionary<string, Action> weaponEvents = new Dictionary<string, Action>();
|
||||
public Dictionary<string, object> weaponVariables = new Dictionary<string, object>();
|
||||
|
||||
public Weapon relatedWeapon;
|
||||
public GraphOwner relatedGraph;
|
||||
public GameObject relatedObject;
|
||||
|
||||
// Recieve Weapon Catch signal from Animation
|
||||
public void WeaponCatch(){
|
||||
relatedGraph.SendEvent("Weapon Catch");
|
||||
}
|
||||
|
||||
// Recieve Weapon Release signal from Animation
|
||||
public void WeaponRelease(){
|
||||
relatedGraph.SendEvent("Weapon Release");
|
||||
}
|
||||
|
||||
public void RegisterWeaponEvent(string calledName, Action action){
|
||||
weaponEvents.Add(calledName, action);
|
||||
}
|
||||
|
||||
public void RegisterWeaponVariable(string variable, object value){
|
||||
if (weaponVariables.ContainsKey(variable)) {
|
||||
weaponVariables[variable] = value;
|
||||
} else {
|
||||
weaponVariables.Add(variable, value);
|
||||
}
|
||||
}
|
||||
|
||||
public object ReadWeaponVariable<T>(string variable) where T : class{
|
||||
return (T)weaponVariables[variable];
|
||||
}
|
||||
|
||||
public void DoWeaponEvent(string eventName){
|
||||
if (weaponEvents.ContainsKey(eventName)) {
|
||||
weaponEvents[eventName].Invoke();
|
||||
|
||||
@@ -1,17 +1,115 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using Unity.Services.Relay.Models;
|
||||
using UnityEngine;
|
||||
using Quaternion = UnityEngine.Quaternion;
|
||||
using Vector3 = UnityEngine.Vector3;
|
||||
|
||||
namespace Reset.Items{
|
||||
public class ShurikenActor : WeaponActor{
|
||||
public GameObject bladeRing;
|
||||
|
||||
void Start(){
|
||||
Debug.Log(GetType());
|
||||
bladeRing = relatedObject.transform.GetChild(0).gameObject;
|
||||
public Transform target;
|
||||
private Vector3 targetPosition;
|
||||
|
||||
private Transform originalParent;
|
||||
private Quaternion originalRotation;
|
||||
private Vector3 originalPosition;
|
||||
|
||||
private Vector3 originalWorldPosition;
|
||||
|
||||
private float rotateSpeed;
|
||||
private float rotateSpeedTarget;
|
||||
private float rotationAcceleration;
|
||||
|
||||
void Awake(){
|
||||
// Register Weapon Events
|
||||
weaponEvents.Add("Set Target", SetTarget);
|
||||
weaponEvents.Add("Fly To Target", FlyToTarget);
|
||||
weaponEvents.Add("Fly To Hand", FlyToHand);
|
||||
weaponEvents.Add("Return To Hand", ReturnToHand);
|
||||
}
|
||||
|
||||
void SetTarget(){
|
||||
Debug.Log($"{weaponVariables["target"]}, {weaponVariables["target"] as GameObject}");
|
||||
target = (Transform)weaponVariables["target"];
|
||||
}
|
||||
|
||||
void FlyToTarget(){
|
||||
rotateSpeedTarget = 1200f;
|
||||
rotationAcceleration = 200f;
|
||||
RegisterWeaponVariable("state", "Flying To Target");
|
||||
|
||||
originalParent = relatedObject.transform.parent;
|
||||
originalPosition = relatedObject.transform.localPosition;
|
||||
originalRotation = relatedObject.transform.localRotation;
|
||||
|
||||
originalWorldPosition = relatedObject.transform.position;
|
||||
|
||||
relatedObject.transform.SetParent(null, true);
|
||||
}
|
||||
|
||||
void FlyToHand(){
|
||||
rotateSpeed = 3000f;
|
||||
rotateSpeedTarget = 50f;
|
||||
rotationAcceleration = 2f;
|
||||
|
||||
RegisterWeaponVariable("state", new string("Flying To Hand"));
|
||||
}
|
||||
|
||||
void ReturnToHand(){
|
||||
rotateSpeedTarget = 250f;
|
||||
rotationAcceleration = 1f;
|
||||
RegisterWeaponVariable("state", new string("Back In Hand"));
|
||||
|
||||
relatedObject.transform.SetParent(originalParent);
|
||||
relatedObject.transform.localPosition = originalPosition;
|
||||
relatedObject.transform.localRotation = originalRotation;
|
||||
}
|
||||
|
||||
void Start(){
|
||||
// Save refernce to the blade outer ring
|
||||
bladeRing = relatedObject.transform.GetChild(0).gameObject;
|
||||
}
|
||||
|
||||
void Update(){
|
||||
bladeRing.transform.Rotate(Vector3.up * (180f * Time.deltaTime));
|
||||
if (target) {
|
||||
targetPosition = target.transform.position;
|
||||
} else {
|
||||
targetPosition = Vector3.forward * 5f;
|
||||
}
|
||||
|
||||
RegisterWeaponVariable("position", transform.position);
|
||||
|
||||
rotateSpeed = Mathf.Lerp(rotateSpeed, rotateSpeedTarget, rotationAcceleration * Time.deltaTime);
|
||||
bladeRing.transform.Rotate(Vector3.up * (rotateSpeed * Time.deltaTime));
|
||||
|
||||
Debug.Log((string)ReadWeaponVariable<string>("state"));
|
||||
|
||||
// Fly to the target
|
||||
if ((string)ReadWeaponVariable<string>("state") == "Flying To Target") {
|
||||
relatedObject.transform.position = Vector3.Lerp(relatedObject.transform.position, targetPosition, 5f * Time.deltaTime);
|
||||
|
||||
// When there, set next stage
|
||||
if (Vector3.Distance(relatedObject.transform.position, targetPosition) < .5f) {
|
||||
rotationAcceleration = 50f;
|
||||
rotateSpeedTarget = 1200f;
|
||||
RegisterWeaponVariable("state", new string("At Target"));
|
||||
}
|
||||
}
|
||||
|
||||
// Fly to the hand
|
||||
if ((string)ReadWeaponVariable<string>("state") as string == "Flying To Hand") {
|
||||
relatedObject.transform.position = Vector3.Lerp(relatedObject.transform.position, originalParent.transform.position, 5f * Time.deltaTime);
|
||||
|
||||
// When there, set as finished
|
||||
if (Vector3.Distance(relatedObject.transform.position, originalParent.transform.position) < .5f) {
|
||||
RegisterWeaponVariable("state", new string("At Hand"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user