This commit is contained in:
2026-05-30 09:16:35 +07:00
parent 2f87ce19a7
commit 1c0ee6efb7
4001 changed files with 3363438 additions and 1738 deletions

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 78d005285245f3a468be1d36e996f268
folderAsset: yes
timeCreated: 1486579636
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Invector.IK
{
[CustomPropertyDrawer(typeof(IKOffsetSpine), true)]
public class IKOffsetSpineDrawer : PropertyDrawer
{
public static IKOffsetSpineCopy ikOffsetCopy;
public class IKOffsetSpineCopy
{
public string name;
public IKOffsetSpine offsetSpine;
public IKOffsetSpineCopy(string name, IKOffsetSpine offsetSpine)
{
this.name = name;
this.offsetSpine = offsetSpine;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return property.isExpanded ? EditorGUI.GetPropertyHeight(property, label, true) : EditorGUIUtility.singleLineHeight;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Event e = Event.current;
EditorGUI.PropertyField(position, property, true);
if (e.type == EventType.MouseDown && e.button == 1)
{
if (position.Contains(e.mousePosition))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Copy " + property.name), false, () => { Copy(property); });
if (ikOffsetCopy != null && property.name == ikOffsetCopy.name)
{
menu.AddItem(new GUIContent("Past " + property.name), false, () => { Past(property); });
}
else menu.AddDisabledItem(new GUIContent("Past " + property.name));
menu.ShowAsContext();
}
}
}
public void Copy(SerializedProperty property)
{
IKOffsetSpine ikOffset = new IKOffsetSpine();
ikOffset.spine = property.FindPropertyRelative("spine").vector2Value;
ikOffset.head = property.FindPropertyRelative("head").vector2Value;
ikOffsetCopy = new IKOffsetSpineCopy(property.name, ikOffset);
}
public void Past(SerializedProperty property)
{
property.FindPropertyRelative("spine").vector2Value = ikOffsetCopy.offsetSpine.spine;
property.FindPropertyRelative("head").vector2Value = ikOffsetCopy.offsetSpine.head;
property.serializedObject.ApplyModifiedProperties();
property.serializedObject.Update();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e39c2cac3e5bfc84f9523e3e369a4c8d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Invector.IK
{
[CustomPropertyDrawer(typeof(IKOffsetTransform),true)]
public class IKOffsetTransformDrawer : PropertyDrawer
{
public static IKOffsetTransformCopy ikOffsetCopy;
public class IKOffsetTransformCopy
{
public string name;
public IKOffsetTransform offsetTransform;
public IKOffsetTransformCopy(string name,IKOffsetTransform offsetTransform)
{
this.name = name;
this.offsetTransform = offsetTransform;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return property.isExpanded ? EditorGUI.GetPropertyHeight(property,label,true) : EditorGUIUtility.singleLineHeight;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Event e = Event.current;
EditorGUI.PropertyField(position,property,true);
if( e.type == EventType.MouseDown && e.button ==1)
{
if(position.Contains(e.mousePosition))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Copy " + property.name), false, () => { Copy(property); });
if (ikOffsetCopy != null && property.name == ikOffsetCopy.name)
{
menu.AddItem(new GUIContent("Past " + property.name), false, () => { Past(property); });
}
else menu.AddDisabledItem(new GUIContent("Past " + property.name));
menu.ShowAsContext();
}
}
}
public void Copy(SerializedProperty property)
{
IKOffsetTransform ikOffset = new IKOffsetTransform();
ikOffset.position = property.FindPropertyRelative("position").vector3Value;
ikOffset.eulerAngles = property.FindPropertyRelative("eulerAngles").vector3Value;
ikOffsetCopy = new IKOffsetTransformCopy(property.name, ikOffset);
}
public void Past(SerializedProperty property)
{
property.FindPropertyRelative("position").vector3Value = ikOffsetCopy.offsetTransform.position;
property.FindPropertyRelative("eulerAngles").vector3Value = ikOffsetCopy.offsetTransform.eulerAngles;
property.serializedObject.ApplyModifiedProperties();
property.serializedObject.Update();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55eb17c9ba2d97144b5abe6804363a92
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,168 @@
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace Invector.vItemManager
{
[CanEditMultipleObjects]
[CustomEditor(typeof(vAmmoListData), true)]
public class vAmmoListDataEditor : UnityEditor.Editor
{
GUISkin skin;
private Texture2D m_Logo = null;
public string ammoName;
public bool inAddAmmo, inEditAmmo;
public int id;
public int amount;
public int indexInEdit;
public vAmmoListData listData;
void OnEnable()
{
m_Logo = (Texture2D)Resources.Load("icon_v2", typeof(Texture2D));
listData = (vAmmoListData)target;
}
public override void OnInspectorGUI()
{
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
GUI.skin = skin;
GUILayout.BeginVertical("Ammo Manager List Data", "window");
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
GUILayout.Space(10);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
base.OnInspectorGUI();
GUILayout.BeginHorizontal();
if (!inAddAmmo && GUILayout.Button("New Ammo"))
{
inAddAmmo = true;
}
if (GUILayout.Button("Load Ammos"))
{
LoadAmmos();
}
GUILayout.EndHorizontal();
if (inAddAmmo) AddAmmo();
var ammos = serializedObject.FindProperty("ammos");
if (ammos != null)
{
for (int i = 0; i < ammos.arraySize; i++)
{
DrawAmmo(ammos.GetArrayElementAtIndex(i), i);
}
}
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.Space();
serializedObject.ApplyModifiedProperties();
}
void LoadAmmos()
{
if (listData.itemListDatas.Count > 0)
{
for (int i = 0; i < listData.itemListDatas.Count; i++)
{
var ammoItems = listData.itemListDatas[i].items.FindAll(item => item.type == Invector.vItemManager.vItemType.Ammo);
for (int a = 0; a < ammoItems.Count; a++)
{
if (!listData.ammos.Exists(ammo => ammo.ammoID == ammoItems[a].id))
{
listData.ammos.Add(new vAmmo(ammoItems[a].name, ammoItems[a].id));
}
}
}
}
}
void DrawAmmo(SerializedProperty ammo, int index)
{
GUILayout.BeginVertical("box");
var style = new GUIStyle(GUI.skin.GetStyle("Label"));
GUILayout.BeginHorizontal();
if (inEditAmmo && index == indexInEdit)
{
GUILayout.Label("Name");
EditorGUILayout.PropertyField(ammo.FindPropertyRelative("ammoName"), GUIContent.none);
}
else GUILayout.Label(ammo.FindPropertyRelative("ammoName").stringValue, style);
if (GUILayout.Button("O", EditorStyles.miniButton, GUILayout.Width(20)))
{
if (inEditAmmo)
{
if (index == indexInEdit)
{
indexInEdit = -1;
inEditAmmo = false;
}
else indexInEdit = index;
}
else
{
indexInEdit = index;
inEditAmmo = true;
}
}
if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20)))
{
listData.ammos.RemoveAt(index);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
return;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
style.fontStyle = FontStyle.BoldAndItalic;
if (inEditAmmo && index == indexInEdit)
{
GUILayout.Label("ID", style);
EditorGUILayout.PropertyField(ammo.FindPropertyRelative("ammoID"), GUIContent.none);
}
else
{
GUILayout.Label("ID", style);
EditorGUILayout.LabelField(ammo.FindPropertyRelative("ammoID").intValue.ToString("00"), style, GUILayout.MaxWidth(50));
}
GUILayout.Label("Count", style);
EditorGUILayout.PropertyField(ammo.FindPropertyRelative("_count"), GUIContent.none);
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
void AddAmmo()
{
GUILayout.BeginVertical("box");
GUILayout.Box("New Ammo");
ammoName = EditorGUILayout.TextField("Ammo Name", ammoName);
id = EditorGUILayout.IntField("Ammo ID", id);
amount = EditorGUILayout.IntField("Ammo Amount", amount);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Cancel"))
{
inAddAmmo = false;
}
if (GUILayout.Button("Create"))
{
listData.ammos.Add(new vAmmo(ammoName, id, amount));
inAddAmmo = false;
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
[MenuItem("Invector/Shooter/Create new AmmoListData")]
public static void CreateAmmoList()
{
vScriptableObjectUtility.CreateAsset<vAmmoListData>();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4594bc4b2e658c04f88caeb365cacd3b
timeCreated: 1487354174
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,309 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Invector.vShooter
{
using Invector.vCamera;
using vCharacterController;
using vItemManager;
using vMelee;
public class vCreateShooterCharacterEditor : EditorWindow
{
GUISkin skin;
public GameObject template;
public bool addMeleeCombat = true;
public bool useGameController = true;
public bool useInventory = true;
public GameObject inventory;
public vItemListData itemListData;
public GameObject charObj;
Animator charAnimator;
Vector2 rect = new Vector2(500, 660);
UnityEditor.Editor humanoidpreview;
Texture2D m_Logo;
/// <summary>
/// 3rdPersonController Menu
/// </summary>
[MenuItem("Invector/Shooter/Create Shooter Controller", false, 2)]
public static void CreateNewCharacter()
{
GetWindow<vCreateShooterCharacterEditor>();
}
bool isHuman, isValidAvatar, charExist;
public virtual void OnEnable()
{
m_Logo = Resources.Load("icon_v2") as Texture2D;
if(Selection.activeObject)
{
charObj = Selection.activeGameObject;
}
if (charObj)
{
charAnimator = charObj.GetComponent<Animator>();
humanoidpreview = Editor.CreateEditor(charObj);
}
charExist = charAnimator != null;
isHuman = charExist ? charAnimator.isHuman : false;
isValidAvatar = charExist ? charAnimator.avatar.isValid : false;
}
public virtual void OnGUI()
{
if (!skin)
{
skin = Resources.Load("vSkin") as GUISkin;
}
GUI.skin = skin;
this.minSize = rect;
this.titleContent = new GUIContent("Character", null, "Third Person Character Creator");
GUILayout.BeginVertical("Character Creator Window", "window");
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
GUILayout.Space(5);
GUILayout.BeginVertical("box");
if (!charObj)
{
EditorGUILayout.HelpBox("Make sure your FBX model is set as Humanoid!", MessageType.Info);
}
else if (!charExist)
{
EditorGUILayout.HelpBox("Missing a Animator Component", MessageType.Error);
}
else if (!isHuman)
{
EditorGUILayout.HelpBox("This is not a Humanoid", MessageType.Error);
}
else if (!isValidAvatar)
{
EditorGUILayout.HelpBox(charObj.name + " is a invalid Humanoid", MessageType.Info);
}
template = EditorGUILayout.ObjectField("Template", template, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;
charObj = EditorGUILayout.ObjectField("FBX Model", charObj, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;
EditorGUILayout.Space();
EditorGUILayout.LabelField("--- Optional---");
useGameController = EditorGUILayout.Toggle("Add GameController", useGameController);
addMeleeCombat = EditorGUILayout.Toggle("Add MeleeCombat", addMeleeCombat);
useInventory = EditorGUILayout.Toggle("Add Inventory", useInventory);
if (useInventory)
{
inventory = EditorGUILayout.ObjectField("Inventory Prefab", inventory, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;
itemListData = EditorGUILayout.ObjectField("ItemListData", itemListData, typeof(vItemListData), true, GUILayout.ExpandWidth(true)) as vItemListData;
}
if (GUI.changed && charObj != null && charObj.GetComponent<vThirdPersonController>() == null)
{
humanoidpreview = Editor.CreateEditor(charObj);
}
if (charObj != null && charObj.GetComponent<vThirdPersonController>() != null)
{
EditorGUILayout.HelpBox("This gameObject already contains the component vThirdPersonController", MessageType.Warning);
}
GUILayout.EndVertical();
//GUILayout.BeginHorizontal("box");
//EditorGUILayout.LabelField("Need to know how it works?");
//if (GUILayout.Button("Video Tutorial"))
//{
// Application.OpenURL("https://www.youtube.com/watch?v=KQ5xha36tfE&index=1&list=PLvgXGzhT_qehtuCYl2oyL-LrWoT7fhg9d");
//}
//GUILayout.EndHorizontal();
if (charObj)
{
charAnimator = charObj.GetComponent<Animator>();
}
charExist = charAnimator != null;
isHuman = charExist ? charAnimator.isHuman : false;
isValidAvatar = charExist ? charAnimator.avatar.isValid : false;
if (CanCreate())
{
DrawHumanoidPreview();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Create"))
{
Create();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
public virtual bool CanCreate()
{
return isValidAvatar && isHuman && charObj != null && charObj.GetComponent<vThirdPersonController>() == null;
}
/// <summary>
/// Draw the Preview window
/// </summary>
public virtual void DrawHumanoidPreview()
{
GUILayout.FlexibleSpace();
if (humanoidpreview != null)
{
humanoidpreview.OnInteractivePreviewGUI(GUILayoutUtility.GetRect(100, 400), "window");
}
}
private GameObject InstantiateNewCharacter(GameObject selected)
{
if (selected == null)
{
return selected;
}
if (selected.scene.IsValid())
{
return selected;
}
return PrefabUtility.InstantiatePrefab(selected) as GameObject;
}
/// <summary>
/// Created the Third Person Controller
/// </summary>
public virtual void Create()
{
// base for the character
GameObject newCharacter = InstantiateNewCharacter(charObj);
if (!newCharacter)
{
return;
}
GameObject _template = Instantiate(template, newCharacter.transform.position, newCharacter.transform.rotation);
// finds the '3D Model' gameobject or crate one if it doesn't exist
Transform modelParent = _template.transform.Find("3D Model");
if (modelParent == null)
{
modelParent = new GameObject("3D Model").transform;
modelParent.parent = _template.transform;
}
// finds the 'Invector Components' gameobject or crate one if it doesn't exist
Transform componentsParent = _template.transform.Find("Invector Components");
if (componentsParent == null)
{
componentsParent = new GameObject("Invector Components").transform;
componentsParent.parent = _template.transform;
}
newCharacter.transform.parent = modelParent;
newCharacter.transform.localPosition = Vector3.zero;
newCharacter.transform.localEulerAngles = Vector3.zero;
_template.name = "vShooterController_" + charObj.gameObject.name;
Animator animatorController = newCharacter.GetComponent<Animator>();
Animator animatorTemplate = _template.GetComponent<Animator>();
animatorTemplate.avatar = animatorController.avatar;
animatorTemplate.Rebind();
DestroyImmediate(animatorController);
newCharacter.tag = "Player";
var p_layer = LayerMask.NameToLayer("Player");
newCharacter.layer = p_layer;
foreach (Transform t in newCharacter.transform.GetComponentsInChildren<Transform>())
{
t.gameObject.layer = p_layer;
}
Selection.activeGameObject = _template;
// search for a MainCamera and attach to the tpCamera
var mainCamera = Camera.main;
var tpCamera = _template.GetComponentInChildren<vThirdPersonCamera>();
if (mainCamera == null)
{
mainCamera = new GameObject("MainCamera", typeof(Camera), typeof(AudioListener)).GetComponent<Camera>();
mainCamera.tag = "MainCamera";
}
if (mainCamera.transform.parent != tpCamera.transform)
{
mainCamera.transform.parent = tpCamera.transform;
mainCamera.transform.localPosition = Vector3.zero;
mainCamera.transform.localEulerAngles = Vector3.zero;
}
// add the gameController example
if (useGameController)
{
GameObject gC = null;
var gameController = FindObjectOfType<vGameController>();
if (gameController == null)
{
gC = new GameObject("vGameController_Example");
gC.AddComponent<vGameController>();
}
}
if (!addMeleeCombat)
{
var _meleeManager = _template.GetComponent<vMeleeManager>();
DestroyImmediate(_meleeManager as vMeleeManager, true);
}
if (useInventory)
{
// add prefab inventory to the 'Invector Components' gameObject inside the Controller
inventory = Instantiate(inventory, componentsParent.transform.position, componentsParent.transform.rotation);
inventory.gameObject.transform.parent = componentsParent.transform;
inventory.transform.localPosition = Vector3.zero;
inventory.transform.localEulerAngles = Vector3.zero;
// add shooter melee item list data
var _itemManager = _template.GetComponent<vItemManager>();
_itemManager.itemListData = itemListData;
}
else
{
// remove ItemManager from the character
var _inventory = _template.GetComponent<vItemManager>();
DestroyImmediate(_inventory as vItemManager, true);
}
// load bones for the BodySnapControl
var _bodySnap = _template.GetComponentInChildren<vBodySnappingControl>();
_bodySnap.LoadBones();
UnityEditor.SceneView.lastActiveSceneView.FrameSelected();
this.Close();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 19f72d8f3c7590945a266972068afe21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_PersistentViewDataDictionary: {instanceID: 0}
- template: {fileID: 3179500330022679588, guid: 9a4532ac5eb24424eb3383bb25c356bf,
type: 3}
- inventory: {fileID: 3444320678111530354, guid: 8cff4600ff380fc45910465a0a4d4ab1,
type: 3}
- itemListData: {fileID: 11400000, guid: 1493f9d9326e8014494b8cb04de38f25, type: 2}
- charObj: {fileID: 172952, guid: f331e7a83f743e541a9772d5c23959c6, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Events;
using UnityEngine;
namespace Invector.vItemManager
{
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b0e9db7c7f1512948974fcaaf4dd78b9
timeCreated: 1486667692
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 467d14e88c92baf4ea1c5af0f7810303
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
using UnityEditor;
using UnityEngine;
namespace Invector.vShooter
{
[CanEditMultipleObjects]
[CustomEditor(typeof(vShooterManager), true)]
public class vShooterManagerEditor : vEditorBase
{
protected vShooterManager manager;
protected override void OnEnable()
{
base.OnEnable();
}
protected override void AdditionalGUI()
{
if (!manager)
manager = (vShooterManager)this.target;
var color = GUI.color;
if (toolbars[selectedToolBar].title.Equals("IK Adjust"))
{
if (!Application.isPlaying && GUILayout.Button("Create New IK Adjust List"))
{
CreateNewIKAdjustList(manager);
}
if (manager.weaponIKAdjustList != null && GUILayout.Button("Edit IK Adjust List"))
{
vShooterIKAdjustWindow.InitEditorWindow();
}
}
if (Application.isPlaying)
{
if (manager.tpCamera)
{
GUI.color = Color.red;
GUI.color = color;
GUI.enabled = vShooterIKAdjustWindow.curWindow == null;
GUI.enabled = true;
EditorGUILayout.Space();
if (GUILayout.Button(manager.showCheckAimGizmos ? "Hide Aim Gizmos" : "Show Aim Gizmos", EditorStyles.toolbarButton))
{
manager.showCheckAimGizmos = !manager.showCheckAimGizmos;
}
}
}
GUI.color = color;
}
public virtual void CreateNewIKAdjustList(vShooterManager targetShooterManager)
{
vWeaponIKAdjustList ikAdjust = ScriptableObject.CreateInstance<vWeaponIKAdjustList>();
AssetDatabase.CreateAsset(ikAdjust, "Assets/" + manager.gameObject.name + "@IKAdjustList.asset");
targetShooterManager.weaponIKAdjustList = ikAdjust;
AssetDatabase.SaveAssets();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: db4f66cd735f8d348acd2ab853acf674
timeCreated: 1486579776
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using System.Collections;
using UnityEditor;
using Invector.vCharacterController;
namespace Invector.vShooter
{
public partial class vMenuComponent
{
[MenuItem("Invector/Shooter/Components/LockOn (Player Shooter Only)")]
static void LockOnShooterMenu()
{
if (Selection.activeGameObject && Selection.activeGameObject.GetComponent<Invector.vCharacterController.vThirdPersonInput>() != null)
Selection.activeGameObject.AddComponent<vLockOnShooter>();
else
Debug.Log("Please select a Player to add the component.");
}
[MenuItem("Invector/Shooter/Components/DrawHide ShooterWeapons")]
static void DrawShooterWeaponMenu()
{
if (Selection.activeGameObject && Selection.activeGameObject.GetComponent<Invector.vCharacterController.vThirdPersonInput>() != null)
Selection.activeGameObject.AddComponent<vDrawHideShooterWeapons>();
else
Debug.Log("Please select a Player to add the component.");
}
[MenuItem("Invector/Shooter/Components/ThrowObject")]
static void ThrowObjectMenu()
{
if (Selection.activeGameObject && Selection.activeGameObject.GetComponent<Invector.vCharacterController.vThirdPersonInput>() != null)
Selection.activeGameObject.AddComponent<Throw.vThrowManager>();
else
Debug.Log("Please select a Player to add the component.");
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 589b9361dc906454b9ba3fe28eef65b5
timeCreated: 1498607325
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
namespace Invector.vShooter
{
[CustomEditor(typeof(vWeaponIKAdjust))]
public class vWeaponIKAdjustEditor : UnityEditor.Editor
{
public string[] propertyBySide = new string[] { "ikAdjustsLeft", "ikAdjustsRight" };
public string[] toolbar = new string[] { "Left IK Adjust", "Right IK Adjust" };
public int selected = 1;
UnityEditorInternal.ReorderableList[] Lists;
private void OnEnable()
{
Lists = new UnityEditorInternal.ReorderableList[] {
new UnityEditorInternal.ReorderableList(serializedObject, serializedObject.FindProperty(propertyBySide[0]),true,false,true,true)
{
elementHeightCallback = GetElementHeight,
drawElementCallback = DrawElement
},
new UnityEditorInternal.ReorderableList(serializedObject, serializedObject.FindProperty(propertyBySide[1]),true,false,true,true)
{
elementHeightCallback = GetElementHeight,
drawElementCallback = DrawElement
}
};
}
private float GetElementHeight(int index)
{
var prop = Lists[selected].serializedProperty.GetArrayElementAtIndex(index);
return prop.isExpanded? EditorGUI.GetPropertyHeight(prop, true):EditorGUIUtility.singleLineHeight;
}
private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
{
var prop = Lists[selected].serializedProperty.GetArrayElementAtIndex(index);
rect=EditorGUI.PrefixLabel(rect, GUIContent.none);
EditorGUI.PropertyField(rect, prop,true);
}
public override void OnInspectorGUI()
{
serializedObject.Update();
GUILayout.BeginVertical("IK Adjust for Weapon Category", "window");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("weaponCategories"));
EditorGUI.indentLevel--;
selected = GUILayout.Toolbar(selected, toolbar);
GUILayout.BeginVertical("IK Adjust for " + (selected == 0 ? "Weapons in Left Side" : "Weapons in Right Side"),"window");
DrawListOfAdjust(Lists[selected]);
GUILayout.EndVertical();
GUILayout.EndVertical();
GUI.enabled = false;
Editor.DrawPropertiesExcluding(serializedObject, "weaponCategories", propertyBySide[0], propertyBySide[1],"m_Script");
GUI.enabled = true;
if (GUI.changed) serializedObject.ApplyModifiedProperties();
}
public void DrawListOfAdjust(UnityEditorInternal.ReorderableList list)
{
EditorGUI.indentLevel++;
list.DoLayoutList();
}
public override bool UseDefaultMargins()
{
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52121fc518dba31438eb4cfc4f5e0103
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b286ad5b80a17a44dba5b9529e418d14, type: 3}
m_Name: ShooterAI_AmmoListData
m_EditorClassIdentifier:
itemListDatas: []
ammos:
- ammoName:
ammoID: 13
_count: 0
ammoItems: []
- ammoName:
ammoID: 14
_count: 0
ammoItems: []
- ammoName:
ammoID: 17
_count: 0
ammoItems: []
- ammoName:
ammoID: 19
_count: 0
ammoItems: []
- ammoName:
ammoID: 18
_count: 0
ammoItems: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 156f393a0f483cb43a4256d3a3e107e6
timeCreated: 1499291181
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b286ad5b80a17a44dba5b9529e418d14, type: 3}
m_Name: Shooter_AmmoListData
m_EditorClassIdentifier:
itemListDatas:
- {fileID: 11400000, guid: 1493f9d9326e8014494b8cb04de38f25, type: 2}
ammos:
- ammoName: Rifle Ammo
ammoID: 13
_count: 0
ammoItems: []
- ammoName: Handgun Ammo
ammoID: 14
_count: 0
ammoItems: []
- ammoName: Shotgun Shells
ammoID: 17
_count: 0
ammoItems: []
- ammoName: RPG Ammo
ammoID: 18
_count: 0
ammoItems: []
- ammoName: Sniper Ammo
ammoID: 19
_count: 0
ammoItems: []
- ammoName: Arrows
ammoID: 21
_count: 0
ammoItems: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 63dd85acb3dbe1746ab7200f610a2d5f
timeCreated: 1487358496
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections.Generic;
namespace Invector.vItemManager
{
public class vAmmoListData : ScriptableObject
{
[vHelpBox("Leave the Count value at 0 if you want to use ammo from the Inventory Attribute", vHelpBoxAttribute.MessageType.Info)]
public List<vItemListData> itemListDatas;
[HideInInspector]
public List<vAmmo> ammos = new List<vAmmo>();
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b286ad5b80a17a44dba5b9529e418d14
timeCreated: 1487353769
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,297 @@
using UnityEngine;
using System.Collections.Generic;
namespace Invector.vItemManager
{
[vClassHeader("Ammo Manager", iconName = "ammoIcon")]
public class vAmmoManager : vMonoBehaviour
{
public vAmmoListData ammoListData;
[HideInInspector]
public vItemManager itemManager;
//[HideInInspector]
public List<vAmmo> ammos = new List<vAmmo>();
public delegate void OnUpdateTotalAmmo();
public OnUpdateTotalAmmo updateTotalAmmo = delegate { };
void Start()
{
itemManager = GetComponent<vItemManager>();
if (itemManager)
{
itemManager.onAddItem.AddListener(AddAmmo);
itemManager.onCollectItemRef.AddListener(AddAmmo);
itemManager.onDropItem.AddListener(DropAmmo);
itemManager.onDestroyItem.AddListener(LeaveAmmo);
itemManager.onChangeItemAmount.AddListener(ChangeItemAmount);
itemManager.onLoadItems.AddListener(ReloadAllAmmoItems);
}
if (ammoListData)
{
ammos.Clear();
for (int i = 0; i < ammoListData.ammos.Count; i++)
{
var ammo = new vAmmo(ammoListData.ammos[i]);
ammo.onDestroyAmmoItem = new vAmmo.OnDestroyItem(OnDestroyAmmoItem);
ammos.Add(ammo);
}
}
}
public vAmmo GetAmmo(int id)
{
return ammos.Find(a => a.ammoID == id);
}
/// <summary>
/// Use with AmmoStandalone Solution
/// </summary>
/// <param name="id"></param>
/// <param name="amount"></param>
public void AddAmmo(int id, int amount)
{
var ammo = ammos.Find(a => a.ammoID == id);
if (ammo != null)
{
ammo.AddAmmo(amount);
}
UpdateTotalAmmo();
}
/// <summary>
/// Use with AmmoStandalone Solution
/// </summary>
/// <param name="ammoName"></param>
/// <param name="id"></param>
/// <param name="amount"></param>
public void AddAmmo(string ammoName, int id, int amount)
{
var ammo = ammos.Find(a => a.ammoID == id);
if (ammo == null)
{
ammo = new vAmmo(ammoName, id, amount);
ammos.Add(ammo);
ammo.onDestroyAmmoItem = new vAmmo.OnDestroyItem(OnDestroyAmmoItem);
}
else if (ammo != null)
{
ammo.AddAmmo(amount);
}
UpdateTotalAmmo();
}
/// <summary>
/// Use with ItemManager
/// </summary>
/// <param name="item"></param>
public void AddAmmo(vItem item)
{
if (item.type == vItemType.Ammo)
{
var ammo = ammos.Find(a => a.ammoID == item.id);
if (ammo == null)
{
ammo = new vAmmo(item.name, item.id, 0);
ammos.Add(ammo);
ammo.onDestroyAmmoItem = new vAmmo.OnDestroyItem(OnDestroyAmmoItem);
}
ammo.ammoItems.Add(item);
}
else
{
var _ammo = item.GetItemAttribute(vItemAttributes.AmmoCount);
if (_ammo != null)
{
var weaponReference = item.originalObject.GetComponent<vShooter.vShooterWeapon>();
if (weaponReference != null)
{
if (_ammo != null && _ammo.value > weaponReference.clipSize)
{
var extraAmmo = _ammo.value - weaponReference.clipSize;
_ammo.value -= extraAmmo;
ItemReference newAmmoItem = new ItemReference(weaponReference.ammoID);
newAmmoItem.amount = extraAmmo;
itemManager.CollectItem(newAmmoItem, ignoreItemAnimation: true);
}
}
}
}
UpdateTotalAmmo();
}
/// <summary>
/// Add Ammo Attribute
/// </summary>
/// <param name="item"></param>
public void AddAmmo(ItemReference item)
{
var _ammo = item.attributes.Find(a => a.name == vItemAttributes.AmmoCount);
var _item = itemManager.itemListData.items.Find(i => i.id == item.id);
if (_ammo != null && _item != null)
{
var weaponReference = _item.originalObject.GetComponent<vShooter.vShooterWeapon>();
if (weaponReference != null)
{
ItemReference newAmmoItem = new ItemReference(weaponReference.ammoID);
newAmmoItem.amount = _ammo.value;
itemManager.CollectItem(newAmmoItem, ignoreItemAnimation: true);
}
}
UpdateTotalAmmo();
}
protected void ChangeItemAmount(vItem item)
{
if (item.type == vItemType.Ammo)
{
var ammo = ammos.Find(a => a.ammoID == item.id);
if (ammo == null)
{
ammo = new vAmmo(item.name, item.id, item.amount);
ammos.Add(ammo);
ammo.onDestroyAmmoItem = new vAmmo.OnDestroyItem(OnDestroyAmmoItem);
}
}
UpdateTotalAmmo();
}
public void LeaveAmmo(vItem item, int amount)
{
if (item.type == vItemType.Ammo)
{
var ammo = ammos.Find(a => a.ammoID == item.id);
if (ammo != null)
{
if ((item.amount - amount) <= 0 && ammo.ammoItems.Contains(item))
ammo.ammoItems.Remove(item);
}
}
UpdateTotalAmmo();
}
public void DropAmmo(vItem item, int amount)
{
if (item.type == vItemType.Ammo)
{
var ammo = ammos.Find(a => a.ammoID == item.id);
if (ammo != null)
{
if ((item.amount - amount) <= 0 && ammo.ammoItems.Contains(item))
ammo.ammoItems.Remove(item);
}
}
UpdateTotalAmmo();
}
public void UpdateTotalAmmo()
{
updateTotalAmmo.Invoke();
}
public void ReloadAllAmmoItems()
{
var ammosInManager = itemManager.items.FindAll(item => item.type == vItemType.Ammo);
ammos.Clear();
for (int i = 0; i < ammosInManager.Count; i++)
{
AddAmmo(ammosInManager[i]);
}
}
void OnDestroyAmmoItem(vItem item)
{
if (itemManager) itemManager.DestroyItem(item, item.amount);
}
}
[System.Serializable]
public class vAmmo
{
public string ammoName;
[Tooltip("Ammo ID - if is using ItemManager, make sure your AmmoManager and ItemListData use the same ID")]
public int ammoID;
[Tooltip("Don't need to setup if you're using a Inventory System")]
[SerializeField]
private int _count;
public List<vItem> ammoItems;
public delegate void OnDestroyItem(vItem item);
public OnDestroyItem onDestroyAmmoItem = delegate { };
public vAmmo()
{
ammoItems = new List<vItem>();
}
public vAmmo(string ammoName, int ammoID, int amount = 0)
{
this.ammoName = ammoName;
this.ammoID = ammoID;
this._count = amount;
ammoItems = new List<vItem>();
}
public vAmmo(int ammoID, int amount = 0)
{
this.ammoID = ammoID;
this._count = amount;
ammoItems = new List<vItem>();
}
public vAmmo(vAmmo ammo)
{
this.ammoName = ammo.ammoName;
this.ammoID = ammo.ammoID;
this.ammoItems = ammo.ammoItems;
this._count = ammo.count;
ammoItems = new List<vItem>();
}
public virtual int count
{
get
{
var value = 0;
if (ammoItems != null && ammoItems.Count > 0)
{
for (int i = 0; i < ammoItems.Count; i++)
if (ammoItems[i])
value += ammoItems[i].amount;
}
return _count + value;
}
}
public virtual void Use()
{
var ammoItem = ammoItems.Find(a => a.amount > 0);
if (ammoItem)
{
ammoItem.amount--;
if (ammoItem.amount == 0)
{
ammoItems.Remove(ammoItem);
onDestroyAmmoItem(ammoItem);
}
return;
}
else if (_count > 0) _count--;
}
public virtual void Use(int amout)
{
for (int i = 0; i < amout; i++) Use();
}
public void AddAmmo(int amount)
{
_count += amount;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: d48792010207c394f9890a9c148beb3a
timeCreated: 1487358535
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences:
- ammoListData: {fileID: 11400000, guid: 63dd85acb3dbe1746ab7200f610a2d5f, type: 2}
- shooterManager: {instanceID: 0}
- itemManager: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using Invector.vCharacterController;
namespace Invector.vShooter
{
[vClassHeader("Shooter Lock-On")]
public class vLockOnShooter : vLockOn
{
protected vShooterMeleeInput shooterMelee;
protected override void Start()
{
base.Start();
shooterMelee = this.tpInput as vShooterMeleeInput;
}
protected override void UpdateLockOn()
{
if (shooterMelee == null ||
shooterMelee.shooterManager == null ||
(shooterMelee.shooterManager.useLockOn && shooterMelee.shooterManager.rWeapon != null) ||
shooterMelee.shooterManager.useLockOnMeleeOnly && shooterMelee.shooterManager.rWeapon == null)
base.UpdateLockOn();
else if (isLockingOn && shooterMelee.shooterManager.rWeapon != null)
{
isLockingOn = false;
LockOn(false);
StopLockOn();
aimImage.transform.gameObject.SetActive(false);
}
}
protected override void LockOnInput()
{
if (tpInput.tpCamera == null || tpInput.cc == null) return;
// lock the camera into a target, if there is any around
if (lockOnInput.GetButtonDown() && !tpInput.cc.customAction)
{
isLockingOn = !isLockingOn;
LockOn(isLockingOn);
}
// unlock the camera if the target is null
else if (isLockingOn && tpInput.tpCamera.lockTarget == null)
{
isLockingOn = false;
LockOn(false);
}
// choose to use lock-on with strafe of free movement
if (strafeWhileLockOn && !tpInput.cc.locomotionType.Equals(vThirdPersonMotor.LocomotionType.OnlyStrafe))
{
if (shooterMelee.isAimingByInput || strafeWhileLockOn && isLockingOn && tpInput.tpCamera.lockTarget != null)
tpInput.cc.lockInStrafe = true;
else
tpInput.cc.lockInStrafe = false;
}
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 86d3d021f27159e4e93e4a7a7f096c49
timeCreated: 1498605032
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences:
- aimImagePrefab: {fileID: 22467274, guid: f2c21a5084b380e45af41fac8083c307, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
namespace Invector.vCharacterController
{
using vEventSystems;
[vClassHeader("DAMAGE RECEIVER", "You can add damage multiplier for example causing twice damage on Headshots", openClose = false)]
public partial class vDamageReceiver : vMonoBehaviour, vIAttackReceiver
{
public void OnReceiveAttack(vDamage damage, vIMeleeFighter attacker)
{
if ((ragdoll && !ragdoll.iChar.isDead))
{
var _damage = ApplyDamageModifiers(damage);
ragdoll.gameObject.ApplyDamage(_damage, attacker);
onReceiveDamage.Invoke(_damage);
}
else if (targetReceiver)
{
var _damage = ApplyDamageModifiers(damage);
targetReceiver.gameObject.ApplyDamage(_damage, attacker);
onReceiveDamage.Invoke(_damage);
}
else
{
TakeDamage(damage);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a7a04eca2b705bf47b75d6e9ef2ec850
timeCreated: 1486572787
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4c53b06e64363f74ca9377ee0b41842b
timeCreated: 1564455406
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences:
- weaponIKAdjustList: {instanceID: 0}
- rWeapon: {instanceID: 0}
- lWeapon: {instanceID: 0}
- ammoManager: {instanceID: 0}
- ammoDisplayR: {instanceID: 0}
- ammoDisplayL: {instanceID: 0}
- tpCamera: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 46ebb0c68fc51da4b94e466ea07cd110
timeCreated: 1479335763
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: