feat: add test shurken
This commit is contained in:
@@ -1,30 +1,45 @@
|
||||
using System;
|
||||
using Drawing;
|
||||
using NodeCanvas.StateMachines;
|
||||
using Reset.Core;
|
||||
using Reset.Units;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items{
|
||||
[CreateAssetMenu(menuName = "Reset/Weapon", fileName = "New Weapon")]
|
||||
public class Weapon : Item, IEquipable{
|
||||
public CombatType combatType;
|
||||
|
||||
public GameObject weaponModel;
|
||||
public NodeCanvas.Framework.Graph weaponFSM;
|
||||
|
||||
public Vector3 handPositionOffset;
|
||||
public Vector3 handRotationOffset;
|
||||
|
||||
void Awake(){
|
||||
|
||||
}
|
||||
public string actorScriptName;
|
||||
|
||||
public void AddActorScript(){
|
||||
// Type actorScript = Type.GetType("ShurikenActor");
|
||||
//
|
||||
// if (actorScript == null) {
|
||||
// Debug.LogError($"The WeaponActor supplied was not found for {itemName}. Does script named '{actorScriptName + ",Assembly-UnityScript"}' exist?");
|
||||
// return;
|
||||
// }
|
||||
|
||||
WeaponActor weaponActor = PlayerManager.Player.AddComponent<ShurikenActor>() as WeaponActor;
|
||||
|
||||
weaponActor.relatedObject = PlayerManager.Player.GetComponent<PlayerInventory>().GetCurrentWeaponItem();
|
||||
weaponActor.relatedWeapon = this;
|
||||
}
|
||||
|
||||
public override void DrawItemInfo(Vector3 position){
|
||||
Debug.Log("hiuh");
|
||||
Draw.ingame.Label2D(position + Vector3.up * 1.6f, "Damage goes here");
|
||||
Draw.ingame.Label2D(position + Vector3.up * 1.35f, "Speed goes here");
|
||||
}
|
||||
|
||||
public GameObject PlaceInHand(){
|
||||
return GameObject.Instantiate(weaponModel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Assets/Scripts/Items/WeaponActor.cs
Normal file
26
Assets/Scripts/Items/WeaponActor.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items{
|
||||
public abstract class WeaponActor : MonoBehaviour{
|
||||
public Dictionary<string, Action> weaponEvents = new Dictionary<string, Action>();
|
||||
|
||||
public Weapon relatedWeapon;
|
||||
public GameObject relatedObject;
|
||||
|
||||
public void RegisterWeaponEvent(string calledName, Action action){
|
||||
weaponEvents.Add(calledName, action);
|
||||
}
|
||||
|
||||
public void DoWeaponEvent(string eventName){
|
||||
if (weaponEvents.ContainsKey(eventName)) {
|
||||
weaponEvents[eventName].Invoke();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogError($"There is no event by name of {eventName} in {name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Items/WeaponActor.cs.meta
Normal file
3
Assets/Scripts/Items/WeaponActor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7db5375a3b8f4212b407f4f8f41a8870
|
||||
timeCreated: 1768000398
|
||||
3
Assets/Scripts/Items/Weapons.meta
Normal file
3
Assets/Scripts/Items/Weapons.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70ef6ecafdc149559e4cb6e19787e719
|
||||
timeCreated: 1768000824
|
||||
17
Assets/Scripts/Items/Weapons/ShurikenActor.cs
Normal file
17
Assets/Scripts/Items/Weapons/ShurikenActor.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Items{
|
||||
public class ShurikenActor : WeaponActor{
|
||||
public GameObject bladeRing;
|
||||
|
||||
void Start(){
|
||||
Debug.Log(GetType());
|
||||
bladeRing = relatedObject.transform.GetChild(0).gameObject;
|
||||
}
|
||||
|
||||
void Update(){
|
||||
bladeRing.transform.Rotate(Vector3.up * (180f * Time.deltaTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Items/Weapons/ShurikenActor.cs.meta
Normal file
3
Assets/Scripts/Items/Weapons/ShurikenActor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d1d2a1a617247459542ec29b4f50785
|
||||
timeCreated: 1768002409
|
||||
6
Assets/Scripts/Units/Combat/CombatType.cs
Normal file
6
Assets/Scripts/Units/Combat/CombatType.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Reset.Core{
|
||||
public enum CombatType{
|
||||
Melee = 0,
|
||||
Ranged = 1
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Units/Combat/CombatType.cs.meta
Normal file
3
Assets/Scripts/Units/Combat/CombatType.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb3157c88aaa41f8b0b20d4690bb1459
|
||||
timeCreated: 1767997846
|
||||
7
Assets/Scripts/Units/PlayerCombat.cs
Normal file
7
Assets/Scripts/Units/PlayerCombat.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Reset.Core;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class PlayerCombat : UnitCombat{
|
||||
public CombatType currentCombatType;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Units/PlayerCombat.cs.meta
Normal file
3
Assets/Scripts/Units/PlayerCombat.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2b74fc5d4eb483bb4e637c3be6353b2
|
||||
timeCreated: 1767998040
|
||||
@@ -36,10 +36,18 @@ namespace Reset.Units{
|
||||
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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class UnitAnimation : UnitComponent{
|
||||
@@ -30,6 +31,11 @@ namespace Reset.Units{
|
||||
// }
|
||||
|
||||
modelAnimator.SetFloat("Move Direction X", moveSpeed);
|
||||
modelAnimator.SetFloat("Gravity", Unit.Movement.resolvedMovement.gravity);
|
||||
|
||||
modelAnimator.SetBool("Grounded", Physics.Raycast(transform.position, Vector3.down, .2f));
|
||||
|
||||
Debug.Log(Unit.Movement.GetGrounded());
|
||||
}
|
||||
|
||||
private void LateUpdate(){
|
||||
|
||||
@@ -359,6 +359,10 @@ namespace Reset.Units{
|
||||
public Quaternion GetResolvedRotation(){
|
||||
return resolvedMovement.rotation;
|
||||
}
|
||||
|
||||
public bool GetGrounded(){
|
||||
return controller.isGrounded;
|
||||
}
|
||||
|
||||
[Button("Initialize Settings", ButtonHeight = 30), PropertySpace(10,5 )]
|
||||
void InitAllSettings(){
|
||||
|
||||
Reference in New Issue
Block a user