This commit is contained in:
2026-06-02 08:27:03 +07:00
parent 7889064469
commit a48cd962e1
4232 changed files with 2 additions and 36881 deletions

View File

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

View File

@@ -0,0 +1,76 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System;
namespace Invector.vShooter
{
public class vCreateShooterWeaponEditor : EditorWindow
{
GUISkin skin;
GameObject weaponObj;
Vector2 rect = new Vector2(400, 100);
Texture2D m_Logo;
[MenuItem("Invector/Shooter/Create Shooter Weapon")]
public static void CreateNewCharacter()
{
GetWindow<vCreateShooterWeaponEditor>();
}
void OnGUI()
{
if (!skin) skin = Resources.Load("vSkin") as GUISkin;
GUI.skin = skin;
this.minSize = rect;
this.titleContent = new GUIContent("ShooterWeapon", null, "Window Creator");
m_Logo = Resources.Load("icon_v2") as Texture2D;
GUILayout.BeginVertical("Shooter Weapon Creator Window", "window");
GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
GUILayout.Space(5);
GUILayout.BeginVertical("box");
weaponObj = EditorGUILayout.ObjectField("FBX Model", weaponObj, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;
if (weaponObj != null)
{
if (GUILayout.Button("Create"))
Create();
}
GUILayout.EndVertical();
GUILayout.EndVertical();
}
private GameObject InstantiateNewWeapon(GameObject selected)
{
if (selected == null) return selected;
if (selected.scene.IsValid()) return selected;
return PrefabUtility.InstantiatePrefab(selected) as GameObject;
}
private void Create()
{
var template = Resources.Load("ShooterWeaponTemplate") as GameObject;
GameObject weapon;
if (template)
weapon =(GameObject) PrefabUtility.InstantiatePrefab(template);
else
weapon = new GameObject(" ", typeof(vShooterWeapon));
var newWeapon = InstantiateNewWeapon(weaponObj);
if (!newWeapon) return;
newWeapon.transform.SetParent(weapon.transform);
newWeapon.transform.localPosition = Vector3.zero;
newWeapon.transform.localEulerAngles = Vector3.zero;
Selection.activeGameObject = weapon;
SceneView.lastActiveSceneView.FrameSelected();
this.Close();
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,569 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &127974
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 431300}
- component: {fileID: 10849134}
m_Layer: 2
m_Name: Point light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &135154
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 417286}
m_Layer: 0
m_Name: renderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &153606
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 419996}
m_Layer: 2
m_Name: AimReference
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &159428
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 453322}
m_Layer: 2
m_Name: leftHandIK
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &173410
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 419756}
- component: {fileID: 8248388}
m_Layer: 2
m_Name: AudioSource
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &182814
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 421838}
m_Layer: 2
m_Name: muzzle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &191594
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 480456}
m_Layer: 2
m_Name: ScopeTarget
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &199424
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 478760}
- component: {fileID: 11479324}
m_Layer: 2
m_Name: ShooterWeaponTemplate
m_TagString: Untagged
m_Icon: {fileID: 2270504221434485236, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &417286
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 135154}
m_LocalRotation: {x: 0.0016794787, y: 0.0012013902, z: 0.7432941, w: 0.66896164}
m_LocalPosition: {x: -0.0018, y: 0.0506, z: 0.3867}
m_LocalScale: {x: 0.27453846, y: 0.27453846, z: 0.2250934}
m_Children:
- {fileID: 421838}
- {fileID: 453322}
- {fileID: 419996}
- {fileID: 419756}
- {fileID: 431300}
- {fileID: 480456}
m_Father: {fileID: 478760}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &419756
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 173410}
m_LocalRotation: {x: 0.46546915, y: 0.52318436, z: 0.43578228, w: 0.5654294}
m_LocalPosition: {x: 0.064, y: 0.012, z: 1.281}
m_LocalScale: {x: 0.290133, y: 0.40305263, z: 0.21389934}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &419996
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 153606}
m_LocalRotation: {x: -0.0000015903419, y: -0.0000016971122, z: -0.7071067, w: 0.7071068}
m_LocalPosition: {x: 0.016026992, y: 0.0036404736, z: -1.5740136}
m_LocalScale: {x: 3.6424778, y: 3.6424778, z: 4.4426003}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &421838
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 182814}
m_LocalRotation: {x: -0.0000015903419, y: -0.0000016971122, z: -0.7071067, w: 0.7071068}
m_LocalPosition: {x: 0.114, y: 0.01, z: 0.896}
m_LocalScale: {x: 3.6424778, y: 3.6424778, z: 4.4426003}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &431300
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 127974}
m_LocalRotation: {x: 0.63728094, y: -0.02987191, z: -0.020991534, w: 0.7697662}
m_LocalPosition: {x: 0.054, y: -0.03, z: 1.26}
m_LocalScale: {x: 0.26729307, y: 0.40305272, z: 0.2321768}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &453322
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 159428}
m_LocalRotation: {x: 0.731455, y: 0.30543953, z: 0.6091697, w: 0.024341084}
m_LocalPosition: {x: -0.239, y: 0.244, z: -0.082}
m_LocalScale: {x: 4.573821, y: 3.7189708, z: 3.642559}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &478760
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 199424}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 417286}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &480456
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 191594}
m_LocalRotation: {x: -0.58142155, y: 0.19429177, z: -0.7886574, w: 0.04710898}
m_LocalPosition: {x: 0.269, y: 0.198, z: -1.608}
m_LocalScale: {x: 4.581436, y: 3.8824654, z: 3.8282037}
m_Children: []
m_Father: {fileID: 417286}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &8248388
AudioSource:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 173410}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- serializedVersion: 2
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 2
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
--- !u!108 &10849134
Light:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 127974}
m_Enabled: 0
serializedVersion: 8
m_Type: 2
m_Color: {r: 1, g: 0.7486692, b: 0.35820895, a: 1}
m_Intensity: 2.6
m_Range: 3
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 1
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!114 &11479324
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 199424}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 00bf0dc6ae04cf040b6ba6afb034b3c6, type: 3}
m_Name:
m_EditorClassIdentifier:
openCloseEvents: 0
openCloseWindow: 0
selectedToolbar: 5
isLeftWeapon: 0
chargeWeapon: 0
autoShotOnFinishCharge: 0
chargeSpeed: 0.1
chargeDamageMultiplier: 2
changeVelocityByCharge: 1
chargeVelocityMultiplier: 2
automaticWeapon: 0
shootFrequency: 0.5
reloadTime: 1
reloadOneByOne: 0
clipSize: 8
isInfinityAmmo: 0
ammo: 8
ammoID: 13
moveSetID: 2
upperBodyID: 2
shotID: 0
reloadID: 1
autoReload: 0
equipID: 0
alignRightHandToAim: 1
alignRightUpperArmToAim: 1
raycastAimTarget: 1
useIkOnIdle: 1
useIkOnFree: 1
useIkOnStrafe: 1
useIkAttacking: 0
disableIkOnShot: 0
useIKOnAiming: 1
canAimWithoutAmmo: 1
headTrackOffset: {x: 0, y: 0}
headTrackOffsetCrouch: {x: 0, y: 0}
handIKTarget: {fileID: 453322}
secundaryWeapon: {fileID: 0}
projectile: {fileID: 1000010710861650, guid: 22773fb6a3ebd59429b49fd6e288058e, type: 2}
projectileToHide: {fileID: 0}
projectileToHideDelay: 0
muzzle: {fileID: 421838}
aimReference: {fileID: 419996}
projectilesPerShot: 1
dispersion: 0
precision: 0.5
velocity: 380
damageByDistance: 1
DropOffStart: 8
DropOffEnd: 50
minDamage: 5
maxDamage: 10
recoilRight: 0
recoilLeft: 0
recoilUp: 1.5
fireClip: {fileID: 8300000, guid: 4912d5c56ce571e4fbad7af6de655772, type: 3}
emptyClip: {fileID: 8300000, guid: b6bc9198c8e32e749a9bb3f967aee671, type: 3}
reloadClip: {fileID: 8300000, guid: cc03a3bc3d3003c428240bcd6e12c487, type: 3}
finishReloadClip: {fileID: 0}
source: {fileID: 8248388}
testShootEffect: 0
lightOnShot: {fileID: 10849134}
emittShurykenParticle: []
onlyUseScopeUIView: 0
useUI: 0
scopeID: 0
scopeZoom: 60
customAimCameraState:
scopeTarget: {fileID: 480456}
zoomScopeCamera: {fileID: 0}
keepScopeCameraRotationZ: 1
onDestroy:
m_PersistentCalls:
m_Calls: []
m_TypeName: Invector.vShooter.vShooterWeapon+OnDestroyEvent, Assembly-CSharp,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
isAiming: 0
usingScope: 0
onShot:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onReload:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onFinishReload:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onEmptyClip:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onEnableAim:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onDisableAim:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onEnableScope:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onDisableScope:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onFullPower:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
onChangerPowerCharger:
m_PersistentCalls:
m_Calls: []
m_TypeName: Invector.vShooter.vShooterWeapon+OnChangePowerCharger, Assembly-CSharp,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
onInstantiateProjectile:
m_PersistentCalls:
m_Calls: []
m_TypeName: Invector.vShooter.vShooterWeapon+OnInstantiateProjectile, Assembly-CSharp,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
ignoreTags: []
hitLayer:
serializedVersion: 2
m_Bits: 0
root: {fileID: 0}
isSecundaryWeapon: 0
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 0}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: fireClip
value:
objectReference: {fileID: 8300000, guid: 4912d5c56ce571e4fbad7af6de655772, type: 3}
- target: {fileID: 0}
propertyPath: emptyClip
value:
objectReference: {fileID: 8300000, guid: b6bc9198c8e32e749a9bb3f967aee671, type: 3}
- target: {fileID: 0}
propertyPath: reloadClip
value:
objectReference: {fileID: 8300000, guid: cc03a3bc3d3003c428240bcd6e12c487, type: 3}
- target: {fileID: 0}
propertyPath: headTrackOffset.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: headTrackOffset.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: projectilesPerShot
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: dispersion
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: recoilRight
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: recoilLeft
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: recoilUp
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: velocity
value: 380
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 199424}
m_IsPrefabParent: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b73633091f185ef47a93cf3a862e7a60
timeCreated: 1486751874
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Invector.vItemManager
{
public class vAmmoDisplay : MonoBehaviour
{
public int displayID = 1;
[System.Serializable]
public class OnChangeAmmoEvent : UnityEvent<int> { }
[SerializeField]
[vHelpBox("Ammo loaded in the Clip")]
protected Text display;
[SerializeField]
[vHelpBox("Ammo left in the Inventory")]
protected Text secundaryDisplay;
public UnityEvent onShow, onHide;
[vHelpBox("Event based in the current AmmoID")]
public OnChangeAmmoEvent onChangeAmmo;
private int currentAmmoId;
void Start()
{
if (display == null)
{
Destroy(gameObject);
}
display.text = "";
if (secundaryDisplay)
{
secundaryDisplay.text = "";
}
currentAmmoId = -1;
}
public void Show()
{
if (display)
{
display.gameObject.SetActive(true);
}
if (secundaryDisplay)
{
secundaryDisplay.gameObject.SetActive(true);
}
onShow.Invoke();
}
public void Hide()
{
if (display)
{
display.gameObject.SetActive(false);
}
if (secundaryDisplay)
{
secundaryDisplay.gameObject.SetActive(true);
}
onHide.Invoke();
}
public void UpdateDisplay(string text1, string text2 = "", int id = 0)
{
if (display && !text1.Equals("") && !display.gameObject.activeSelf)
{
display.gameObject.SetActive(true);
}
if (secundaryDisplay && !text2.Equals("") && !secundaryDisplay.gameObject.activeSelf)
{
secundaryDisplay.gameObject.SetActive(true);
}
if (currentAmmoId != id)
{
onChangeAmmo.Invoke(id);
currentAmmoId = id;
}
if (display)
{
display.text = text1;
}
if (secundaryDisplay)
{
secundaryDisplay.text = text2;
}
}
}
}

View File

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

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
namespace Invector.vItemManager
{
public class vAmmoDisplayImage : MonoBehaviour
{
[System.Serializable]
public class vDisplayImage
{
public Sprite ammoImage;
public int ammoId;
}
public Image displayImage;
public Sprite defaultAmmoImage;
public List<vDisplayImage> displayImages = new List<vDisplayImage>();
private int currentAmmoId;
/// <summary>
/// Change Ammo display image by id
/// </summary>
/// <param name="id"></param>
public void ChangeAmmoDisplayImage(int id)
{
if (currentAmmoId != id && displayImages != null)
{
var display = displayImages.Find(d => d.ammoId.Equals(id));
if (display != null)
{
displayImage.sprite = display.ammoImage;
}
else
{
displayImage.sprite = defaultAmmoImage;
}
currentAmmoId = id;
}
}
}
}

View File

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

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using System.Collections;
namespace Invector.vItemManager
{
using vCharacterController.vActions;
[vClassHeader("vAmmoStandalone")]
public class vAmmoStandalone : vTriggerGenericAction
{
[Header("Ammo Standalone Options")]
[Tooltip("Use the same name as in the AmmoManager")]
public string weaponName;
public int ammoID;
public int ammoAmount;
private vAmmoManager ammoManager;
public override IEnumerator OnPressActionDelay(GameObject cc)
{
yield return StartCoroutine(base.OnPressActionDelay(cc));
ammoManager = cc.gameObject.GetComponent<vAmmoManager>();
if(ammoManager != null)
ammoManager.AddAmmo(weaponName, ammoID, ammoAmount);
}
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vShooter
{
[CreateAssetMenu(menuName = "Invector/Shooter/New BulletLifeSettings")]
public class vBulletLifeSettings : ScriptableObject
{
public List<vBulletLostLife> bulletLostLifeList;
private bool seedGenerated;
public vBulletLifeInfo GetReduceLife(string tag, int layer)
{
var bulletLostLife = bulletLostLifeList.Find(blf => isValid(blf, tag, layer));
vBulletLifeInfo bInfo = new vBulletLifeInfo();
if (bulletLostLife != null)
{
bInfo.lostLife = bulletLostLife.reduceLife;
bInfo.lostDamage = bulletLostLife.damageReducePercentage;
bInfo.minChangeTrajectory = bulletLostLife.minChangeTrajectory;
bInfo.maxChangeTrajectory = bulletLostLife.maxChangeTrajectory;
bInfo.maxThicknessToCross = bulletLostLife.maxThicknessToCross;
bInfo.ricochet = bulletLostLife.ricochet;
}
return bInfo;
}
bool isValid(vBulletLostLife blf, string tag, int layer)
{
return (blf.layers == (blf.layers | (1 << layer))) && blf.tags.Contains(tag);
}
[System.Serializable]
public class vBulletLostLife
{
public LayerMask layers = 1 << 0;
public List<string> tags = new List<string>() { "Untagged" };
public int reduceLife = 100;
public bool ricochet = false;
[vHideInInspector("ricochet", true)]
public float maxThicknessToCross = 0.2f;
[Range(0, 100)]
public int damageReducePercentage = 50;
[Range(0, 90)]
public float minChangeTrajectory = 2f;
[Range(0, 90)]
public float maxChangeTrajectory = 2f;
public vBulletLostLife()
{
layers = 1 << 0;
tags = new List<string>() { "Untagged" };
reduceLife = 100;
}
}
public struct vBulletLifeInfo
{
public int lostLife;
public int lostDamage;
public float minChangeTrajectory;
public float maxChangeTrajectory;
public float maxThicknessToCross;
public bool ricochet;
}
}
}

View File

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

View File

@@ -0,0 +1,126 @@
using UnityEngine;
namespace Invector.vMelee
{
using vCharacterController.vActions;
using vShooter;
[vClassHeader("Collect Shooter Melee Control", "This component is used when you're character doesn't have a ItemManager to manage items, this will allow you to pickup 1 weapon at the time.")]
public class vCollectShooterMeleeControl : vCollectMeleeControl
{
protected vShooterManager shooterManager;
[vEditorToolbar("Shooter Events")]
public UnityEngine.Events.UnityEvent onEquipShooterWeapon, onUnequipShooterWeapon;
internal bool wasUsingShooterWeapon;
protected override void Start()
{
base.Start();
shooterManager = GetComponent<vShooterManager>();
}
public override void HandleCollectableInput(vCollectableStandalone collectableStandAlone)
{
if (shooterManager && collectableStandAlone != null && collectableStandAlone.weapon != null)
{
EquipShooterWeapon(collectableStandAlone);
}
base.HandleCollectableInput(collectableStandAlone);
}
protected virtual void EquipShooterWeapon(vCollectableStandalone collectable)
{
var weapon = collectable.weapon.GetComponent<vShooterWeapon>();
if (!weapon)
{
return;
}
Transform p = null;
if (weapon.isLeftWeapon)
{
p = GetEquipPoint(leftHandler, collectable.targetEquipPoint);
if (p)
{
collectable.weapon.transform.SetParent(p);
collectable.weapon.transform.localPosition = Vector3.zero;
collectable.weapon.transform.localEulerAngles = Vector3.zero;
if (leftWeapon && leftWeapon.gameObject != collectable.gameObject)
RemoveLeftWeapon();
shooterManager.SetLeftWeapon(weapon.gameObject);
collectable.OnEquip.Invoke();
leftWeapon = collectable;
UpdateLeftDisplay(collectable);
if (rightWeapon)
RemoveRightWeapon();
}
}
else
{
p = GetEquipPoint(rightHandler, collectable.targetEquipPoint);
if (p)
{
collectable.weapon.transform.SetParent(p);
collectable.weapon.transform.localPosition = Vector3.zero;
collectable.weapon.transform.localEulerAngles = Vector3.zero;
if (rightWeapon && rightWeapon.gameObject != collectable.gameObject)
RemoveRightWeapon();
shooterManager.SetRightWeapon(weapon.gameObject);
collectable.OnEquip.Invoke();
rightWeapon = collectable;
UpdateRightDisplay(collectable);
if (leftWeapon)
RemoveLeftWeapon();
}
}
}
public override void RemoveRightWeapon()
{
base.RemoveRightWeapon();
if (shooterManager)
shooterManager.rWeapon = null;
}
public override void RemoveLeftWeapon()
{
base.RemoveLeftWeapon();
if (shooterManager)
shooterManager.lWeapon = null;
}
protected override void CheckIsEquipedWifhWeapon()
{
if (!wasUsingShooterWeapon && isUsingShooterWeapon)
{
onUnequipMeleeWeapon.Invoke();
wasUsingMeleeWeapon = false;
onEquipShooterWeapon.Invoke();
wasUsingShooterWeapon = true;
}
else if (wasUsingShooterWeapon && !isUsingShooterWeapon)
{
onUnequipShooterWeapon.Invoke();
wasUsingShooterWeapon = false;
}
if (!wasUsingShooterWeapon)
base.CheckIsEquipedWifhWeapon();
}
public virtual bool isUsingShooterWeapon
{
get
{
if (!shooterManager) return false;
return shooterManager.CurrentActiveWeapon;
}
}
}
}

View File

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

View File

@@ -0,0 +1,114 @@
using UnityEngine;
namespace Invector.vShooter
{
using vCharacterController;
[vClassHeader("Draw/Hide Shooter Melee Weapons", "This component works with vItemManager, vWeaponHolderManager and vShooterMeleeInput", useHelpBox = true)]
public class vDrawHideShooterWeapons : vDrawHideMeleeWeapons
{
public virtual vShooterMeleeInput shooter { get; set; }
[vEditorToolbar("Shooter")]
[Header("Draw Immediate Conditions")]
public bool shoot;
public bool aim = true;
public bool hipFire = true;
protected override void Start()
{
base.Start();
shooter = GetComponent<vShooterMeleeInput>();
}
protected override bool CanHideWeapons()
{
return (shooter && shooter.shooterManager && shooter.shooterManager.CurrentWeapon && (forceHide || (!shooter.IsAiming && !shooter.isReloading)))
|| (base.CanHideWeapons() && (forceHide || (!shooter.IsAiming && !shooter.isReloading)));
}
protected override bool CanDrawWeapons()
{
return (!forceHide && shooter && shooter.shooterManager && shooter.shooterManager.CurrentWeapon && !shooter.shooterManager.CurrentWeapon.gameObject.activeInHierarchy) || base.CanDrawWeapons();
}
protected override GameObject RightWeaponObject(bool checkIsActve = false)
{
if (shooter && shooter.shooterManager && shooter.shooterManager.rWeapon && (!checkIsActve || shooter.shooterManager.rWeapon.gameObject.activeInHierarchy))
{
return shooter.shooterManager.rWeapon.gameObject;
}
return base.RightWeaponObject(checkIsActve);
}
protected override GameObject LeftWeaponObject(bool checkIsActve = false)
{
if (shooter && shooter.shooterManager && shooter.shooterManager.lWeapon && (!checkIsActve || shooter.shooterManager.lWeapon.gameObject.activeInHierarchy))
{
return shooter.shooterManager.lWeapon.gameObject;
}
return base.LeftWeaponObject(checkIsActve);
}
protected override void DrawRightWeapon(bool immediate = false)
{
base.DrawRightWeapon(immediate);
}
protected override bool DrawWeaponsImmediateConditions()
{
if (shooter && shooter.shooterManager && shooter.shooterManager.CurrentWeapon)
{
return DrawShooterWeaponImmediateConditions();
}
else
{
return base.DrawWeaponsImmediateConditions();
}
}
protected virtual bool DrawShooterWeaponImmediateConditions()
{
if (!shooter || !shooter.shooterManager || shooter.cc.customAction || !shooter.shooterManager.CurrentWeapon || shooter.lockInput)
{
return false;
}
if (shooter.CurrentActiveWeapon == null && ((shooter.aimInput.GetButtonDown() && aim) ||
(shooter.shooterManager.hipfireShot && shooter.shotInput.GetButtonDown() && hipFire) || (shooter.shotInput.GetButtonDown() && shoot)))
{
return true;
}
return false;
}
protected override void HandleInput()
{
base.HandleInput();
// HandleShooterInput();
}
//protected virtual void HandleShooterInput()
//{
// if (!shooter.cc.IsAnimatorTag("IsThrowing") && shooter && shooter.shooterManager && !shooter.cc.customAction &&
// shooter.shooterManager.CurrentWeapon && shooter.CurrentActiveWeapon == null && !shooter._isAiming &&
// !shooter.shooterManager.hipfireShot && !shooter.lockInput && shooter.shotInput.GetButtonDown())
// {
// if (!IsEquipping)
// {
// if (CanHideRightWeapon() || CanHideLeftWeapon())
// {
// HideWeapons();
// }
// //else if (CanDrawRightWeapon() || CanDrawLeftWeapon())
// //{
// // DrawWeapons();
// //}
// }
// }
//}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
using UnityEngine;
namespace Invector.vShooter
{
[RequireComponent(typeof(LineRenderer))]
public class vLaserSight : MonoBehaviour
{
public LayerMask layerMask;
public GameObject aimSprite;
public float aimSpriteOffset;
public float maxDistance;
Ray ray;
RaycastHit hit;
LineRenderer line;
void Start()
{
line = GetComponent<LineRenderer>();
ray = new Ray();
}
void LateUpdate()
{
ray.origin = transform.position;
ray.direction = transform.forward.normalized;
var laserLenght = Vector3.zero;
if (Physics.Raycast(ray, out hit, maxDistance, layerMask))
{
laserLenght.z = transform.InverseTransformPoint(hit.point).z - aimSpriteOffset;
line.SetPosition(1, laserLenght);
aimSprite.transform.rotation = Quaternion.LookRotation(hit.normal);
}
else
{
laserLenght.z = Vector3.Distance(transform.position, ray.GetPoint(maxDistance - aimSpriteOffset));
line.SetPosition(1, laserLenght);
aimSprite.transform.localEulerAngles = Vector3.zero;
}
aimSprite.transform.localPosition = laserLenght;
}
}
}

View File

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

View File

@@ -0,0 +1,336 @@
using System.Collections.Generic;
using UnityEngine;
namespace Invector.vShooter
{
using Invector.vEventSystems;
[vClassHeader("Projectile Control", "The damage value is changed from minDamage, maxDamage, DropOffStart, DropOffEnd of the ShooterWeapon", openClose = false)]
public class vProjectileControl : vMonoBehaviour
{
public vBulletLifeSettings bulletLifeSettings;
public int bulletLife = 100;
public bool debugTrajetory;
public bool debugHittedObject;
public vDamage damage;
public float forceMultiplier = 1;
public bool destroyOnCast = true;
[Tooltip("Control Trail renderer")]
public TrailRenderer trail;
public ProjectilePassDamage onPassDamage;
public ProjectileCastColliderEvent onCastCollider;
public ProjectileCastColliderEvent onDestroyProjectile;
public vProjectileInstantiateData instantiateData;
internal bool damageByDistance;
internal float velocity = 580;
internal int minDamage;
internal int maxDamage;
internal float minDamageDistance = 8f;
internal float maxDamageDistance = 50f;
internal Vector3 startPosition;
internal LayerMask hitLayer = -1;
internal List<string> ignoreTags = new List<string>();
internal Transform shooterTransform;
protected Vector3 previousPosition;
protected Rigidbody _rigidBody;
protected Color debugColor = Color.green;
protected int debugLife;
protected float castDist;
protected List<Vector3> trajectoryPositions = new List<Vector3>();
protected virtual void Start()
{
transform.SetParent(vObjectContainer.root, true);
debugLife = bulletLife;
_rigidBody = GetComponent<Rigidbody>();
startPosition = transform.position;
previousPosition = transform.position - transform.forward * 0.1f;
if (trail)
{
AddTrailPosition();
}
}
protected virtual void Update()
{
RaycastHit hitInfo;
if (_rigidBody.linearVelocity.magnitude > 1)
{
transform.rotation = Quaternion.LookRotation(_rigidBody.linearVelocity.normalized, transform.up);
}
if (Physics.Linecast(previousPosition, transform.position + transform.forward * 0.5f, out hitInfo, hitLayer))
{
if (!hitInfo.collider)
{
return;
}
var dist = Vector3.Distance(startPosition, transform.position) + castDist;
if (!(ignoreTags.Contains(hitInfo.collider.gameObject.tag) || (shooterTransform != null && hitInfo.collider.transform.IsChildOf(shooterTransform))))
{
if (debugHittedObject)
{
Debug.Log(hitInfo.collider.gameObject.name, hitInfo.collider);
}
onCastCollider.Invoke(hitInfo);
damage.damageValue = maxDamage;
if (damageByDistance)
{
var result = 0f;
var damageDifence = maxDamage - minDamage;
//Calc damage per distance
if (dist - minDamageDistance >= 0)
{
int percentComplete = (int)System.Math.Round((double)(100 * (dist - minDamageDistance)) / (maxDamageDistance - minDamageDistance));
result = Mathf.Clamp(percentComplete * 0.01f, 0, 1f);
damage.damageValue = maxDamage - (int)(damageDifence * result);
}
else
{
damage.damageValue = maxDamage;
}
}
damage.hitPosition = hitInfo.point;
damage.receiver = hitInfo.collider.transform;
damage.force = transform.forward * damage.damageValue * forceMultiplier;
if (damage.damageValue > 0)
{
onPassDamage.Invoke(damage);
hitInfo.collider.gameObject.ApplyDamage(damage, damage.sender ? damage.sender.GetComponent<vIMeleeFighter>() : null);
}
var rigb = hitInfo.collider.gameObject.GetComponent<Rigidbody>();
if (rigb)
{
rigb.AddForce(transform.forward * damage.damageValue * forceMultiplier, ForceMode.Impulse);
}
startPosition = transform.position;
castDist = dist;
if (destroyOnCast)
{
if (bulletLifeSettings)
{
var bulletLifeInfo = bulletLifeSettings.GetReduceLife(hitInfo.collider.gameObject.tag, hitInfo.collider.gameObject.layer);
bulletLife -= bulletLifeInfo.lostLife;
if (debugTrajetory)
{
DrawHitPoint(hitInfo.point);
}
var crossed = false;
if (bulletLife > 0 && !bulletLifeInfo.ricochet)
{
var position = transform.position = hitInfo.point + transform.forward * 0.001f;
if (trail)
{
trail.AddPosition(transform.position);
}
if (debugTrajetory)
{
Debug.DrawLine(transform.position, previousPosition, debugColor, 10f);
}
for (float i = 0; i <= bulletLifeInfo.maxThicknessToCross; i += 0.01f)
{
var pointToCheck = position + transform.forward * (i);
if (Physics.Linecast(pointToCheck, position))
{
hitInfo.point = pointToCheck;
hitInfo.normal = transform.forward;
onCastCollider.Invoke(hitInfo);
crossed = true;
break;
}
}
if (crossed)
{
if (trail)
{
AddTrailPosition();
}
}
}
if (!crossed && !bulletLifeInfo.ricochet)
{
bulletLife = 0;
transform.position = hitInfo.point;
if (debugTrajetory)
{
Debug.DrawLine(transform.position, previousPosition, debugColor, 10f);
}
onDestroyProjectile.Invoke(hitInfo);
if (trail && trail.gameObject != this.gameObject)
{
if (trail)
{
AddTrailPosition();
}
trail.transform.SetParent(vObjectContainer.root);
}
Destroy(gameObject);
return;
}
maxDamage -= (maxDamage) - ((maxDamage * bulletLifeInfo.lostDamage) / 100);
minDamage -= (minDamage) - ((minDamage * bulletLifeInfo.lostDamage) / 100);
if (maxDamage < 0)
{
maxDamage = 0;
}
if (minDamage < 0)
{
minDamage = 0;
}
var x = Random.Range(bulletLifeInfo.minChangeTrajectory, bulletLifeInfo.maxChangeTrajectory) * (Random.Range(-1, 1) >= 0 ? 1 : -1);
var y = Random.Range(bulletLifeInfo.minChangeTrajectory, bulletLifeInfo.maxChangeTrajectory) * (Random.Range(-1, 1) >= 0 ? 1 : -1);
if (y > 60 || y < -60)
{
x = Mathf.Clamp(x, -15, 15);
}
if (x != 0 || y != 0)
{
var dir = Quaternion.Euler(x, y, 0) * _rigidBody.linearVelocity;
if (dir != Vector3.zero)
{
_rigidBody.linearVelocity = dir * (bulletLifeInfo.ricochet ? -1 : 1);
transform.forward = dir * (bulletLifeInfo.ricochet ? -1 : 1);
}
}
if (debugTrajetory)
{
var lostedLifePercent = (bulletLife / (float)debugLife) * 100f;
debugColor = lostedLifePercent > 76 ? Color.green : lostedLifePercent > 51 ? Color.yellow : lostedLifePercent > 26 ? new Color(1, .5f, 0) : Color.red;
debugColor.a = 0.5f;
}
}
else
{
bulletLife = 0;
}
if (bulletLife <= 0 || bulletLifeSettings == null)
{
transform.position = hitInfo.point;
if (debugTrajetory)
{
Debug.DrawLine(transform.position, previousPosition, debugColor, 10f);
}
onDestroyProjectile.Invoke(hitInfo);
if (trail && trail.gameObject != this.gameObject)
{
if (trail)
{
AddTrailPosition();
}
trail.transform.SetParent(vObjectContainer.root);
}
Destroy(gameObject);
return;
}
}
}
else
{
transform.position = hitInfo.point + transform.forward * 0.001f;
if (trail && trail.gameObject != this.gameObject)
{
if (trail)
{
AddTrailPosition();
}
}
if (debugTrajetory)
{
Debug.DrawLine(transform.position, previousPosition, debugColor, 10f);
}
}
}
else
{
if (debugTrajetory)
{
Debug.DrawLine(transform.position, previousPosition, debugColor, 10f);
}
}
previousPosition = transform.position;
}
private void AddTrailPosition()
{
if (trajectoryPositions.Count > 0)
{
var lastPosition = trajectoryPositions[trajectoryPositions.Count - 1];
var distance = Vector3.Distance(lastPosition, transform.position);
var dir = transform.position - lastPosition;
var count = (int)(distance / 0.5f);
for (int i = 0; i < count; i++)
{
trajectoryPositions.Add(lastPosition + dir.normalized * 0.5f);
if (debugTrajetory)
{
Debug.DrawRay(lastPosition, Vector3.up * .1f, Color.red, 10);
}
lastPosition = lastPosition + dir.normalized * 0.5f;
}
}
else
{
trajectoryPositions.Add(transform.position);
}
trail.Clear();
var position = trajectoryPositions.ToArray();
trail.AddPositions(position);
}
void DrawHitPoint(Vector3 point)
{
Debug.DrawRay(point, -transform.forward * 0.1f, Color.red, 10f);
Debug.DrawRay(point, transform.right * 0.1f, Color.red, 10f);
Debug.DrawRay(point, -transform.right * 0.1f, Color.red, 10f);
Debug.DrawRay(point, transform.up * 0.1f, Color.red, 10f);
Debug.DrawRay(point, -transform.up * 0.1f, Color.red, 10f);
}
public void RemoveParentOfOther(Transform other)
{
other.SetParent(vObjectContainer.root, true);
}
[System.Serializable]
public class ProjectileCastColliderEvent : UnityEngine.Events.UnityEvent<RaycastHit> { }
[System.Serializable]
public class ProjectilePassDamage : UnityEngine.Events.UnityEvent<vDamage> { }
}
}

View File

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

View File

@@ -0,0 +1,9 @@
using UnityEngine;
[System.Serializable]
public partial class vProjectileInstantiateData
{
public Vector3 aimPos;
public Vector3 dir;
public float vel;
}

View File

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

View File

@@ -0,0 +1,104 @@
using Invector.vShooter;
namespace Invector.vItemManager
{
[vClassHeader("Shooter Equipment", openClose = false, useHelpBox = true, helpBoxText = "Use this component if you also use the ItemManager in your Character")]
public class vShooterEquipment : vMeleeEquipment
{
protected vShooterWeapon _shooter;
protected vEquipment _secondaryEquipment;
protected bool withoutShooterWeapon;
public virtual vEquipment secondaryEquipment
{
get
{
return _secondaryEquipment;
}
}
public virtual vShooterWeapon shooterWeapon
{
get
{
if (!_shooter && !withoutShooterWeapon)
{
_shooter = GetComponent<vShooterWeapon>();
if (!_shooter) withoutShooterWeapon = true;
}
return _shooter;
}
}
public override bool IsEquipped
{
get
{
return base.IsEquipped;
}
set
{
base.IsEquipped = value;
if (shooterWeapon) shooterWeapon.IsEquipped = value;
}
}
public override void OnEquip(vItem item)
{
if (shooterWeapon)
{
shooterWeapon.changeAmmoHandle = new vShooterWeapon.ChangeAmmoHandle(ChangeAmmo);
shooterWeapon.checkAmmoHandle = new vShooterWeapon.CheckAmmoHandle(CheckAmmo);
var damageAttribute = item.GetItemAttribute(vItemAttributes.Damage);
if (damageAttribute != null)
{
shooterWeapon.maxDamage = damageAttribute.value;
}
if (secondaryEquipment)
{
secondaryEquipment.OnEquip(item);
}
}
base.OnEquip(item);
}
public override void OnUnequip(vItem item)
{
if (shooterWeapon)
{
shooterWeapon.changeAmmoHandle = null;
shooterWeapon.checkAmmoHandle = null;
if (secondaryEquipment)
{
secondaryEquipment.OnUnequip(item);
}
}
base.OnUnequip(item);
}
protected virtual bool CheckAmmo(ref bool isValid, ref int totalAmmo)
{
if (!referenceItem) return false;
var ammoAttribute = referenceItem.GetItemAttribute(vItemAttributes.AmmoCount);
isValid = ammoAttribute != null && !ammoAttribute.isBool;
if (isValid) totalAmmo = ammoAttribute.value;
return isValid && ammoAttribute.value > 0;
}
protected virtual void ChangeAmmo(int value)
{
if (!referenceItem) return;
var ammoAttribute = referenceItem.GetItemAttribute(vItemAttributes.AmmoCount);
if (ammoAttribute != null)
{
ammoAttribute.value += value;
}
}
}
}

View File

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

View File

@@ -0,0 +1,496 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
namespace Invector.vShooter
{
public static class IKLocomotionOptionsHelper
{
public static vShooterWeapon.IKLocomotionOptions Copy(this vShooterWeapon.IKLocomotionOptions options)
{
vShooterWeapon.IKLocomotionOptions copy = new vShooterWeapon.IKLocomotionOptions()
{
use = options.use,
useOnIdle = options.useOnIdle,
useOnWalk = options.useOnWalk,
useOnRun = options.useOnRun,
useOnSprint = options.useOnSprint,
};
return copy;
}
}
[vClassHeader("Shooter Weapon", openClose = false)]
public class vShooterWeapon : vShooterWeaponBase
{
public enum AutoReloadStyle
{
WhenAiming,WhenShot,WhenAmmoAvailable
}
#region variables
[System.Serializable]
public class IKLocomotionOptions
{
public bool use = true;
[vHideInInspector("use")]
public bool useOnIdle = true;
[vHideInInspector("use")]
public bool useOnWalk = true;
[vHideInInspector("use")]
public bool useOnRun = true;
[vHideInInspector("use")]
public bool useOnSprint = true;
public IKLocomotionOptions()
{
use = true;
useOnIdle = true;
useOnWalk = true;
useOnRun = true;
useOnSprint = true;
}
}
[vEditorToolbar("Weapon Settings")]
public bool isLeftWeapon = false;
[Tooltip("Hold Charge Input to charge")]
public bool chargeWeapon = false;
[vHideInInspector("chargeWeapon")]
public bool autoShotOnFinishCharge = false;
[vHideInInspector("chargeWeapon")]
public float chargeSpeed = 0.1f;
[vHideInInspector("chargeWeapon")]
public float chargeDamageMultiplier = 2;
[vHideInInspector("chargeWeapon")]
public bool changeVelocityByCharge = true;
[vHideInInspector("chargeWeapon")]
public float chargeVelocityMultiplier = 2;
[Tooltip("Change between automatic weapon or shot once")]
[vHideInInspector("chargeWeapon", true)]
public bool automaticWeapon;
[vEditorToolbar("Ammo")]
public float reloadTime = 1f;
public bool reloadOneByOne;
[SerializeField, Tooltip("Max clip size of your weapon"), FormerlySerializedAs("clipSize")]
protected int _clipSize;
public virtual int clipSize { get { return _clipSize; } set { _clipSize = value; } }
[Tooltip("Check this to combine extra ammo with the current ammo, the Reload will not be used")]
public bool dontUseReload;
[vHideInInspector("dontUseReload", true)]
[Tooltip("Automatically reload the weapon when it's empty")]
public bool autoReload;
[vHideInInspector("autoReload")]
public AutoReloadStyle autoReloadStyle = AutoReloadStyle.WhenAiming;
[Tooltip("Ammo ID - make sure your AmmoManager and ItemListData use the same ID"), vHideInInspector("isInfinityAmmo", true)]
public int ammoID;
[vEditorToolbar("Weapon ID")]
[Tooltip("What moveset the underbody will play")]
public float moveSetID;
[Tooltip("What moveset the uperbody will play")]
public float upperBodyID;
[Tooltip("What shot animation will trigger")]
public float shotID;
[Tooltip("What reload animation will play")]
public int reloadID;
[Tooltip("What equip animation will play")]
public int equipID;
[vEditorToolbar("IK Options")]
[Tooltip("IK will help the right hand to align where you actually is aiming")]
public bool alignRightHandToAim = true;
[Tooltip("IK will help the right hand to align where you actually is aiming")]
public bool alignRightUpperArmToAim = true;
public bool raycastAimTarget = true;
[Tooltip("Left IK on free locomotion")]
public IKLocomotionOptions freeIKOptions = new IKLocomotionOptions();
[Tooltip("Left IK on strafe locomotion")]
public IKLocomotionOptions strafeIKOptions = new IKLocomotionOptions();
[Tooltip("Left IK while attacking")]
public bool useIkAttacking = false;
[Tooltip("Left IK while Shot")]
public bool disableIkOnShot = false;
[Tooltip("Left IK while Aiming")]
public bool useIKOnAiming = true;
[Tooltip("Left IK Hand Target")]
public Transform handIKTarget;
[vEditorToolbar("Projectile")]
[Tooltip("Assign the aimReference of your weapon")]
public Transform aimReference;
[vHelpBox("Only affects the camera from player, when player is aiming")]
[Tooltip("how much the camera will sway when aiming, 1 means no cameraSway and means maxCameraSway from the ShooterManager")]
[Range(0, 1)]
[UnityEngine.Serialization.FormerlySerializedAs("precision")]
public float cameraStability = 0.5f;
[Tooltip("Creates a right recoil on the camera")]
public float recoilRight = 1;
[Tooltip("Creates a left recoil on the camera")]
public float recoilLeft = -1;
[Tooltip("Creates a up recoil on the camera")]
public float recoilUp = 1;
[vEditorToolbar("Audio & VFX")]
public AudioSource reloadSource;
public AudioClip reloadClip;
public AudioClip finishReloadClip;
[vEditorToolbar("Scope View")]
[vHelpBox("Third Person Controller Only", vHelpBoxAttribute.MessageType.Info)]
public bool onlyUseScopeUIView;
[Tooltip("Check this bool to use an UI image for the scope, ex: snipers")]
public bool useUI;
[Tooltip("You can create different Aim sprites and use for different weapons")]
public int scopeID;
[Tooltip("The weight of shoot animation when using scope"), Range(0, 1f)]
public float scopeShootAnimationWeight = .5f;
[Tooltip("change the FOV of the scope view\n **The calc is default value (60)-scopeZoom**"), Range(-118, 60)]
public float scopeZoom = 60;
[Tooltip("Change the FOV of the scope view Background\n **The calc is default value (60)-scopeZoom**"), Range(-118, 60)]
public float backGroundScopeZoom = 0;
[Tooltip("Used with the TPCamera to use a custom CameraState while aiming, if it's empty it will use the 'Aiming' CameraState.")]
public string customAimCameraState;
[Tooltip("Used with the TPCamera to use a custom CameraState while using scope view mode, if it's empty it will use the 'Aiming' CameraState.")]
public string customScopeCameraState;
[Tooltip("assign an empty transform with the pos/rot of your scope view")]
public Transform scopeTarget;
public Camera zoomScopeCamera;
[vHelpBox("Keep Scope Camera Z is used to align z rotation of the zoomScopeCamera to z rotation of the weapon muzzle<color=red> (Projectile toolbar)</color>. if you want to align camera with Vector3.up in z rotation enable this.")]
public bool keepScopeCameraRotationZ = true;
[System.Serializable]
public class OnChangePowerCharger : UnityEvent<float> { }
[HideInInspector]
public bool isAiming, usingScope;
[vEditorToolbar("Events")]
public UnityEvent onReload, onCancelReload, onFinishReload, onFinishAmmo, onEnableAim, onDisableAim, onEnableScope, onDisableScope, onFullPower;
[HideInInspector]
public UnityEvent onDisable;
public OnChangePowerCharger onPowerChargerChanged;
[HideInInspector]
public Transform root;
[HideInInspector]
public bool isSecundaryWeapon;
public delegate bool CheckAmmoHandle(ref bool isValid, ref int totalAmmo);
public delegate void ChangeAmmoHandle(int value);
public CheckAmmoHandle checkAmmoHandle;
public ChangeAmmoHandle changeAmmoHandle;
/// <summary>
/// Weapon is in equipped in hand
/// </summary>
public virtual bool IsEquipped { get; set; }
protected virtual float _charge { get; set; }
protected virtual Transform _handIKTargetOffset
{
get; set;
}
public virtual Transform handIKTargetOffset
{
get
{
if (_handIKTargetOffset == null && handIKTarget != null)
{
_handIKTargetOffset = new GameObject("Offset").transform;
_handIKTargetOffset.SetParent(handIKTarget);
_handIKTargetOffset.localPosition = Vector3.zero;
_handIKTargetOffset.localEulerAngles = Vector3.zero;
}
return _handIKTargetOffset;
}
}
#endregion
[System.NonSerialized] private float testTime;
protected virtual void OnDrawGizmos()
{
if (!Application.isPlaying && testShootEffect)
{
if (testTime <= 0)
{
Shootest();
}
else
{
testTime -= Time.deltaTime;
}
}
}
protected virtual void OnDisable()
{
onDisable.Invoke();
}
protected virtual void Start()
{
if (!reloadSource)
{
reloadSource = source;
}
SetScopeZoom(scopeZoom);
}
public virtual void Shootest()
{
testTime = shootFrequency;
StartEmitters();
lightOnShot.enabled = true;
source.PlayOneShot(fireClip);
Invoke("StopShootTest", .037f);
}
protected virtual void StopShootTest()
{
StopEmitters();
lightOnShot.enabled = false;
}
public virtual float powerCharge
{
get
{
return _charge;
}
set
{
if (value != _charge)
{
_charge = value;
onPowerChargerChanged.Invoke(_charge);
if (_charge >= 1)
{
onFullPower.Invoke();
}
}
}
}
public virtual void SetPrecision(float value)
{
cameraStability = Mathf.Clamp(value, 0, 1);
}
public override bool HasAmmo()
{
if (checkAmmoHandle != null)
{
bool isValidAmmo = false;
int totalAmmo = 0;
var hasAmmo = checkAmmoHandle.Invoke(ref isValidAmmo, ref totalAmmo);
if (isValidAmmo)
{
return hasAmmo;
}
else
{
return ammo > 0;
}
}
else
{
return ammo > 0;
}
}
public virtual int ammoCount
{
get
{
if (checkAmmoHandle != null)
{
bool isValidAmmo = false;
int totalAmmo = 0;
checkAmmoHandle.Invoke(ref isValidAmmo, ref totalAmmo);
if (isValidAmmo)
{
return totalAmmo;
}
else
{
return ammo;
}
}
return ammo;
}
}
public virtual void AddAmmo(int value)
{
if (checkAmmoHandle != null && changeAmmoHandle != null)
{
bool isValidAmmo = false;
int totalAmmo = 0;
checkAmmoHandle.Invoke(ref isValidAmmo, ref totalAmmo);
if (isValidAmmo)
{
changeAmmoHandle(value);
}
else
{
ammo += value;
}
}
else
{
ammo += value;
}
}
public override void UseAmmo(int count = 1)
{
if (checkAmmoHandle != null && changeAmmoHandle != null)
{
bool isValidAmmo = false;
int totalAmmo = 0;
checkAmmoHandle.Invoke(ref isValidAmmo, ref totalAmmo);
if (isValidAmmo)
{
changeAmmoHandle(-count);
}
else
{
ammo -= count;
}
}
else
{
ammo -= count;
}
}
public virtual void ReloadEffect()
{
if (reloadSource && reloadClip)
{
reloadSource.Stop();
reloadSource.PlayOneShot(reloadClip);
}
onReload.Invoke();
}
public virtual void FinishReloadEffect()
{
if (reloadSource && finishReloadClip)
{
reloadSource.Stop();
reloadSource.PlayOneShot(finishReloadClip);
}
onFinishReload.Invoke();
}
protected override float damageMultiplier
{
get
{
if (!chargeWeapon)
{
return base.damageMultiplier;
}
return (float)System.Math.Round((1 + Mathf.Lerp(0, chargeDamageMultiplier, _charge)) + damageMultiplierMod, 1);
}
}
protected override float velocityMultiplier
{
get
{
if (!chargeWeapon || !changeVelocityByCharge)
{
return base.velocityMultiplier;
}
return (1 + Mathf.Lerp(0, chargeVelocityMultiplier, _charge)) + velocityMultiplierMod;
}
}
public virtual void SetScopeZoom(float value)
{
if (zoomScopeCamera)
{
var zoom = Mathf.Clamp(61 - value, 1, 179);
zoomScopeCamera.fieldOfView = zoom;
}
}
public virtual void SetActiveAim(bool value)
{
if (isAiming != value)
{
isAiming = value;
if (isAiming)
{
onEnableAim.Invoke();
}
else
{
onDisableAim.Invoke();
}
}
}
/// <summary>
/// Set if Weapon is using scope
/// </summary>
/// <param name="value"></param>
public virtual void SetActiveScope(bool value)
{
if (usingScope != value)
{
usingScope = value;
if (usingScope)
{
onEnableScope.Invoke();
}
else
{
onDisableScope.Invoke();
}
}
}
/// <summary>
/// Set look target point to Zoom scope camera
/// </summary>
/// <param name="point"></param>
public virtual void SetScopeLookTarget(Vector3 point)
{
if (zoomScopeCamera)
{
var euler = Quaternion.LookRotation(point - zoomScopeCamera.transform.position, Vector3.up).eulerAngles;
if (keepScopeCameraRotationZ)
{
euler.z = muzzle.transform.eulerAngles.z;
}
zoomScopeCamera.transform.eulerAngles = euler;
}
}
public virtual void CancelReload()
{
if (reloadSource && reloadSource.isPlaying)
{
reloadSource.Stop();
}
onCancelReload.Invoke();
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 00bf0dc6ae04cf040b6ba6afb034b3c6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,476 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
namespace Invector.vShooter
{
[vClassHeader("Shooter Weapon", openClose = false)]
public class vShooterWeaponBase : vMonoBehaviour
{
#region Variables
[vEditorToolbar("Weapon Settings")]
[Tooltip("The category of the weapon\n Used to the IK offset system. \nExample: HandGun, Pistol, Machine-Gun")]
public string weaponCategory = "MyCategory";
[SerializeField, Tooltip("Frequency of shots"), FormerlySerializedAs("shootFrequency")]
protected float _shootFrequency;
public virtual float shootFrequency { get { return _shootFrequency; } set { _shootFrequency = value; } }
[vEditorToolbar("Ammo")]
[Tooltip("Unlimited ammo")]
public bool isInfinityAmmo;
[Tooltip("Starting ammo")]
[SerializeField, vHideInInspector("isInfinityAmmo", true), FormerlySerializedAs("ammo")]
protected int _ammo;
public virtual int ammo { get { return _ammo; } set { _ammo = value; } }
[vEditorToolbar("Layer & Tag")]
public List<string> ignoreTags = new List<string>();
public LayerMask hitLayer = 1 << 0;
[vEditorToolbar("Projectile")]
[Tooltip("Prefab of the projectile")]
public GameObject projectile;
[Tooltip("Assign the muzzle of your weapon")]
public Transform muzzle;
[Tooltip("How many projectiles will spawn per shot")]
[Range(1, 20)]
public int projectilesPerShot = 1;
[Range(0, 90)]
[Tooltip("how much dispersion the weapon have")]
public float dispersion = 0;
[vToggleOption("DispersionShape", "Circle", "Quad")]
public bool quadDispersion = false;
[Range(0, 1000)]
[Tooltip("Velocity of your projectile")]
public float velocity = 380;
[vHelpBox("If you're using the ItemManager attribute 'Damage' on your item, the damage will be always maxDamage, ignoring the distance or minDamage", vHelpBoxAttribute.MessageType.Info)]
[Tooltip("Check this to calculate damage automatically based on distance using min and max damage, higher distance less damage, less distance more damage")]
public bool damageByDistance = true;
[Tooltip("Min distance to apply damage, used to evaluate the damage between minDamage and maxDamage")]
[SerializeField, vHideInInspector("damageByDistance"), FormerlySerializedAs("minDamageDistance")]
protected float _minDamageDistance = 8f;
public virtual float minDamageDistance { get { return _minDamageDistance; } set { _minDamageDistance = value; } }
[Tooltip("Max distance to apply damage, used to evaluate the damage between minDamage and maxDamage")]
[SerializeField, vHideInInspector("damageByDistance"), FormerlySerializedAs("maxDamageDistance")]
protected float _maxDamageDistance = 50f;
public virtual float maxDamageDistance { get { return _maxDamageDistance; } set { _maxDamageDistance = value; } }
[vHideInInspector("damageByDistance")]
[SerializeField, Tooltip("Minimum damage caused by the shot, regardless the distance"), FormerlySerializedAs("minDamage")]
protected int _minDamage;
public virtual int minDamage { get { return _minDamage; } set { _minDamage = value; } }
[SerializeField, Tooltip("Maximum damage caused by the close shot"), FormerlySerializedAs("maxDamage")]
protected int _maxDamage;
public virtual int maxDamage { get { return _maxDamage; } set { _maxDamage = value; } }
[vEditorToolbar("Audio & VFX")]
[Header("Audio")]
public AudioSource source;
public AudioClip fireClip;
public AudioClip emptyClip;
[Header("Effects")]
public bool testShootEffect;
public Light lightOnShot;
[SerializeField]
public ParticleSystem[] emittShurykenParticle;
[HideInInspector]
public OnDestroyEvent onDestroy;
[System.Serializable]
public class OnDestroyEvent : UnityEvent<GameObject> { }
[System.Serializable]
public class OnInstantiateProjectile : UnityEvent<vProjectileControl> { }
[vEditorToolbar("Events")]
public UnityEvent onShot, onEmptyClip;
public OnInstantiateProjectile onInstantiateProjectile;
protected virtual float _nextShootTime { get; set; }
protected virtual float _nextEmptyClipTime { get; set; }
protected virtual Transform sender { get; set; }
#endregion
#region Public Methods
/// <summary>
/// Apply additional velocity to the Shot projectile
/// </summary>
public virtual float velocityMultiplierMod { get; set; }
/// <summary>
/// Apply additional damage to the projectile
/// </summary>
public virtual float damageMultiplierMod { get; set; }
/// <summary>
/// Weapon Name
/// </summary>
public virtual string weaponName
{
get
{
var value = gameObject.name.Replace("(Clone)", string.Empty);
return value;
}
}
/// <summary>
/// Shoot to direction of the muzzle forward
/// </summary>
public virtual void Shoot()
{
Shoot(muzzle.position + muzzle.forward * 100f);
}
/// <summary>
/// Shoot to direction of the muzzle forward
/// </summary>
/// <param name="sender">Sender to reference of the damage</param>
/// <param name="successfulShot">Action to check if shoot is successful</param>
public virtual void Shoot(Transform _sender = null, UnityAction<bool> successfulShot = null)
{
Shoot(muzzle.position + muzzle.forward * 100f, _sender, successfulShot);
}
/// <summary>
/// Shoot to direction of the aim Position
/// </summary>
/// <param name="aimPosition">Aim position to override direction of the projectile</param>
/// <param name="sender">ender to reference of the damage</param>
/// <param name="successfulShot">Action to check if shoot is successful</param>
public virtual void Shoot(Vector3 aimPosition, Transform _sender = null, UnityAction<bool> successfulShot = null)
{
Shoot(muzzle.position, aimPosition, _sender, successfulShot);
}
public virtual void Shoot(Vector3 startPoint, Vector3 endPoint, Transform _sender = null, UnityAction<bool> successfulShot = null)
{
if (HasAmmo())
{
if (!CanDoShot)
{
return;
}
UseAmmo();
this.sender = _sender != null ? _sender : transform;
HandleShot(startPoint, endPoint);
if (successfulShot != null)
{
successfulShot.Invoke(true);
}
_nextShootTime = Time.time + shootFrequency;
_nextEmptyClipTime = _nextShootTime;
}
else
{
if (!CanDoEmptyClip)
{
return;
}
EmptyClipEffect();
if (successfulShot != null)
{
successfulShot.Invoke(false);
}
_nextEmptyClipTime = Time.time + shootFrequency;
}
}
/// <summary>
/// Check if can shoot by <seealso cref="shootFrequency"/>
/// </summary>
public virtual bool CanDoShot
{
get
{
bool _canShot = _nextShootTime < Time.time;
return _canShot;
}
}
/// <summary>
/// Check if can do empty clip effect, <seealso cref="shootFrequency"/>
/// </summary>
public virtual bool CanDoEmptyClip
{
get
{
bool _canShot = _nextEmptyClipTime < Time.time;
return _canShot;
}
}
/// <summary>
/// Use weapon Ammo
/// </summary>
/// <param name="count">count to use</param>
public virtual void UseAmmo(int count = 1)
{
if (ammo <= 0)
{
return;
}
ammo -= count;
if (ammo <= 0)
{
ammo = 0;
}
}
/// <summary>
/// Check if Weapon Has Ammo
/// </summary>
/// <returns></returns>
public virtual bool HasAmmo()
{
return isInfinityAmmo || ammo > 0;
}
#endregion
#region Protected Methods
protected virtual void OnDestroy()
{
onDestroy.Invoke(gameObject);
}
private void OnApplicationQuit()
{
onDestroy.RemoveAllListeners();
}
protected virtual void HandleShot(Vector3 startPoint, Vector3 endPoint)
{
ShootBullet(startPoint, endPoint);
ShotEffect();
}
public virtual Vector3 Dispersion(Vector3 aim, float dispersion)
{
return quadDispersion ? QuadDispersion(aim, dispersion) : CircleDispersion(aim, dispersion);
}
public virtual Vector3 CircleDispersion(Vector3 aim, float dispersion)
{
var rotatedAim = Quaternion.Euler(Random.insideUnitSphere * dispersion);
aim = (rotatedAim) * aim;
return aim;
}
public virtual Vector3 QuadDispersion(Vector3 aim, float dispersion)
{
var rotatedAim = Quaternion.Euler
(
Random.Range(-dispersion, dispersion),
Random.Range(-dispersion, dispersion),
Random.Range(-dispersion, dispersion)
);
aim = (rotatedAim) * aim;
return aim.normalized;
}
//IEnumerator DebugDispersion(Vector3 startPoint, Vector3 endPoint)
//{
// var dir = endPoint - startPoint;
// float time = 10;
// while (time>0)
// {
// var dispersionDir = Dispersion(dir.normalized, dispersion);
// (startPoint + dispersionDir * dir.magnitude).DebugPoint(Color.red, 10, 0.02f);
// yield return null;
// time -= Time.deltaTime;
// }
//}
protected virtual void ShootBullet(Vector3 startPoint, Vector3 endPoint)
{
var dir = endPoint - startPoint;
//StartCoroutine(DebugDispersion(startPoint, endPoint));
var rotation = Quaternion.LookRotation(dir);
GameObject bulletObject = null;
var velocityChanged = 0f;
if (dispersion > 0 && projectile)
{
for (int i = 0; i < projectilesPerShot; i++)
{
var dispersionDir = Dispersion(dir.normalized, dispersion);
var spreadRotation = Quaternion.LookRotation(dispersionDir);
bulletObject = Instantiate(projectile, startPoint, spreadRotation);
var pCtrl = bulletObject.GetComponent<vProjectileControl>();
if (pCtrl.debugTrajetory && i == 0)
{
startPoint.DebugPoint(Color.red, 10, 0.1f);
Debug.DrawLine(startPoint, endPoint, Color.red, 10);
endPoint.DebugPoint(Color.red, 10, 0.1f);
}
pCtrl.shooterTransform = sender;
pCtrl.ignoreTags = ignoreTags;
pCtrl.hitLayer = hitLayer;
pCtrl.damage.sender = sender;
pCtrl.startPosition = bulletObject.transform.position;
pCtrl.damageByDistance = damageByDistance;
pCtrl.maxDamage = (int)((maxDamage / projectilesPerShot) * damageMultiplier);
pCtrl.minDamage = (int)((minDamage / projectilesPerShot) * damageMultiplier);
pCtrl.minDamageDistance = minDamageDistance;
pCtrl.maxDamageDistance = maxDamageDistance;
onInstantiateProjectile.Invoke(pCtrl);
velocityChanged = velocity * velocityMultiplier;
ApplyForceToBullet(bulletObject, dispersionDir, velocityChanged);
pCtrl = CreateProjectileData(endPoint, velocityChanged, dispersionDir, pCtrl);
}
}
else if (projectilesPerShot > 0 && projectile)
{
bulletObject = Instantiate(projectile, startPoint, rotation);
var pCtrl = bulletObject.GetComponent<vProjectileControl>();
if (pCtrl.debugTrajetory)
{
startPoint.DebugPoint(Color.red, 10, 0.1f);
Debug.DrawLine(startPoint, endPoint, Color.red, 10);
endPoint.DebugPoint(Color.red, 10, 0.1f);
}
pCtrl.shooterTransform = sender;
pCtrl.ignoreTags = ignoreTags;
pCtrl.hitLayer = hitLayer;
pCtrl.damage.sender = sender;
pCtrl.startPosition = bulletObject.transform.position;
pCtrl.damageByDistance = damageByDistance;
pCtrl.maxDamage = (int)((maxDamage / projectilesPerShot) * damageMultiplier);
pCtrl.minDamage = (int)((minDamage / projectilesPerShot) * damageMultiplier);
pCtrl.minDamageDistance = minDamageDistance;
pCtrl.maxDamageDistance = maxDamageDistance;
onInstantiateProjectile.Invoke(pCtrl);
velocityChanged = velocity * velocityMultiplier;
ApplyForceToBullet(bulletObject, dir, velocityChanged);
}
}
protected virtual vProjectileControl CreateProjectileData(Vector3 aimPosition, float velocityChanged, Vector3 dispersionDir, vProjectileControl pCtrl)
{
pCtrl.instantiateData = new vProjectileInstantiateData
{
aimPos = aimPosition,
dir = dispersionDir,
vel = velocityChanged
};
return pCtrl;
}
protected virtual void ApplyForceToBullet(GameObject bulletObject, Vector3 direction, float velocityChanged)
{
try
{
var _rigidbody = bulletObject.GetComponent<Rigidbody>();
_rigidbody.mass = _rigidbody.mass / projectilesPerShot;//Change mass per projectiles count.
_rigidbody.AddForce((direction.normalized * velocityChanged), ForceMode.VelocityChange);
}
catch
{
}
}
protected virtual float damageMultiplier
{
get
{
return 1 + damageMultiplierMod;
}
}
protected virtual float velocityMultiplier
{
get
{
return 1 + velocityMultiplierMod;
}
}
#region Effects
protected virtual void ShotEffect()
{
onShot.Invoke();
StopCoroutine(LightOnShoot());
if (source && fireClip)
{
source.PlayOneShot(fireClip);
}
StartCoroutine(LightOnShoot(0.037f));
StartEmitters();
}
protected virtual void StopSound()
{
if (source)
{
source.Stop();
}
}
protected virtual IEnumerator LightOnShoot(float time = 0)
{
if (lightOnShot)
{
lightOnShot.enabled = true;
yield return new WaitForSeconds(time);
lightOnShot.enabled = false;
}
}
protected virtual void StartEmitters()
{
if (emittShurykenParticle != null)
{
foreach (ParticleSystem pe in emittShurykenParticle)
{
pe.Emit(1);
}
}
}
protected virtual void StopEmitters()
{
if (emittShurykenParticle != null)
{
foreach (ParticleSystem pe in emittShurykenParticle)
{
pe.Stop();
}
}
}
protected virtual void EmptyClipEffect()
{
if (source && emptyClip)
{
source.PlayOneShot(emptyClip);
}
onEmptyClip.Invoke();
}
#endregion
#endregion
}
}

View File

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

View File

@@ -0,0 +1,67 @@
using Invector.vCharacterController.vActions;
using UnityEngine;
public class vWeaponCollectableControl : MonoBehaviour
{
[vHelpBox("This component is used for NO INVENTORY weapons", vHelpBoxAttribute.MessageType.Info)]
public Rigidbody _rigidbody;
public Collider _physicsCollider;
public Collider _selfCollider;
public virtual void Start()
{
var _collectable = GetComponent<vCollectableStandalone>();
if (_collectable)
{
_collectable.OnEquip.AddListener(OnEquip);
_collectable.OnDrop.AddListener(OnDrop);
}
if (_rigidbody == null)
{
_rigidbody = GetComponentInParent<Rigidbody>();
}
if (_physicsCollider == null)
{
_physicsCollider = GetComponentInParent<Collider>();
}
if (_selfCollider == null)
{
_selfCollider = GetComponentInChildren<Collider>();
}
}
public virtual void OnEquip()
{
if (_rigidbody != null)
{
_rigidbody.isKinematic = true;
}
if (_physicsCollider != null)
{
_physicsCollider.enabled = false;
}
if (_selfCollider != null)
{
_selfCollider.enabled = false;
}
}
public virtual void OnDrop()
{
if (_rigidbody != null)
{
_rigidbody.isKinematic = false;
}
if (_physicsCollider != null)
{
_physicsCollider.enabled = true;
}
if (_selfCollider != null)
{
_selfCollider.enabled = true;
}
}
}

View File

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