Commit 8edc0a0e authored by 15박보승's avatar 15박보승 Committed by 18류지석

Implementing grenade skill

parent 4393e73e
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: ac90b3b98d1169c42b75d1788914ce25
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3600785726789831876
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4355323098611446952}
- component: {fileID: 3150448414156628347}
- component: {fileID: 5008213590963855793}
- component: {fileID: 8819313297916535919}
m_Layer: 0
m_Name: Grenade
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4355323098611446952
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3600785726789831876}
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: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3150448414156628347
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3600785726789831876}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 6, y: 10}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &5008213590963855793
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3600785726789831876}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e028a1e44ca6634b962afda9b4e9ccd, type: 3}
m_Name:
m_EditorClassIdentifier:
moveCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 2
outSlope: 2
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
sizeCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 2
outSlope: 2
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 0.5
value: 3
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
inSlope: -1.576839
outSlope: -1.576839
tangentMode: 0
weightedMode: 0
inWeight: 0.19940042
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
explosionParticle: {fileID: 2617885523350496159, guid: ac90b3b98d1169c42b75d1788914ce25,
type: 3}
--- !u!96 &8819313297916535919
TrailRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3600785726789831876}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10306, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Time: 1
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 1
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_MinVertexDistance: 0.1
m_Autodestruct: 0
m_Emitting: 1
fileFormatVersion: 2
guid: cab7d294d6cf04045bc3f91650d08b5d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%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: affe345c8b2c9d24bab2cea6041cf994, type: 3}
m_Name: GrenadeSkill
m_EditorClassIdentifier:
m_tier: 0
m_index: 0
m_skillImage: {fileID: 21300000, guid: 4e522cf3a529ea94d846154ee98e05a8, type: 3}
m_skillRange: 5
cooltime: 5
explosionRadius: 3
explosionTime: 2
damage: 50
grenadePrefab: {fileID: 3600785726789831876, guid: cab7d294d6cf04045bc3f91650d08b5d,
type: 3}
fileFormatVersion: 2
guid: 690237717e4c813489e7d3cd106a590c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,5 +15,6 @@ MonoBehaviour:
m_tier: 0
m_index: 0
m_skillImage: {fileID: 21300000, guid: 4c85b737d44119f4f828910c3bd26659, type: 3}
m_skillRange: 10
cooltime: 0
damageTimes: 2
This diff is collapsed.
......@@ -32,6 +32,7 @@ public abstract class PlayableCharacter : Actor
[SerializeField]
private Skill[] m_skills = new Skill[4];
public Skill[] Skills { get { return m_skills; } }
public LineRenderer skillRangeRenderer;
protected override void Start()
{
......@@ -143,6 +144,17 @@ public abstract class PlayableCharacter : Actor
m_skills[index].Aiming();
}
public void DrawSkillRange(float range)
{
skillRangeRenderer.enabled = true;
skillRangeRenderer.DrawCircle(transform.position, range);
}
public void DisableSkillRangeRenderer()
{
skillRangeRenderer.enabled = false;
}
protected abstract void DefaultControl();
protected abstract void AimingControl();
}
......@@ -45,7 +45,7 @@ TextureImporter:
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spritePixelsToUnits: 1024
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
......@@ -70,6 +70,18 @@ TextureImporter:
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.Universal;
public class ExplosionEffect : MonoBehaviour
{
[SerializeField]
private Light2D light;
private ParticleSystem particle;
private float lifeTime;
private float lifeTimer = 0;
private float startIntensity;
[SerializeField]
private AnimationCurve lightCurve;
private void Start()
{
particle = GetComponent<ParticleSystem>();
lifeTime = particle.main.startLifetime.constantMax;
startIntensity = light.intensity;
}
private void Update()
{
lifeTimer += Time.deltaTime / lifeTime;
light.intensity = Mathf.Lerp(startIntensity, 0, lifeTimer);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 2e327f6223d4c8b42b4b71adde6d96e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class LineRendererExtension
{
public static void DrawCircle(this LineRenderer renderer, Vector3 center, float radius)
{
Vector3[] positions = new Vector3[361];
center.z = 0;
for (int i = 0; i < 360; i++)
{
positions[i] = center + Quaternion.Euler(0, 0, i) * Vector2.up * radius;
}
positions[360] = positions[0];
renderer.SetPositions(positions);
}
}
fileFormatVersion: 2
guid: 088e81594bd513a4b98f8cccd890d100
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Grenade : MonoBehaviour
{
[SerializeField]
AnimationCurve moveCurve;
[SerializeField]
AnimationCurve sizeCurve;
private Vector3 destination;
private float explosionTime = 2;
private float explosionTimer = 2;
private float explosionRadius = 3;
[SerializeField]
private ParticleSystem explosionParticle;
private Vector3 startPosition;
private TrailRenderer trail;
private float trailWidth;
public void Init(Vector3 destination, float explosionRadius, float explosionTime = 2)
{
this.destination = destination;
this.explosionRadius = explosionRadius;
this.explosionTime = explosionTimer = explosionTime;
startPosition = transform.position;
trail = GetComponent<TrailRenderer>();
}
private void Update()
{
transform.position = Vector2.Lerp(startPosition, destination, moveCurve.Evaluate((explosionTime - explosionTimer) / explosionTime));
transform.localScale = Vector3.one * sizeCurve.Evaluate((explosionTime - explosionTimer) / explosionTime);
//trail.widthCurve.keys[0].value = trailWidth * sizeCurve.Evaluate((explosionTime - explosionTimer) / explosionTime);
explosionTimer -= Time.deltaTime;
if (explosionTimer < 0)
{
Explode();
}
}
private void Explode()
{
Instantiate(explosionParticle, transform.position, Quaternion.identity).Play();
Destroy(gameObject);
}
}
fileFormatVersion: 2
guid: 7e028a1e44ca6634b962afda9b4e9ccd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -59,7 +59,14 @@ public class PlayerController : SingletonBehaviour<PlayerController>
character.UseSkill(0);
}
}
}
if (Input.GetKeyDown(KeyCode.W))
{
foreach (var character in characters)
{
character.UseSkill(1);
}
}
}
public void MouseControl()
{
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class GrenadeSkill : Skill
{
public float explosionRadius = 3f;
public float explosionTime = 2f;
public int damage = 50;
public GameObject grenadePrefab;
private LineRenderer explosionRangeRenderer;
#if UNITY_EDITOR
[MenuItem("Skiils/Grenade")]
static void CreateAsset()
{
GrenadeSkill skill = CreateInstance<GrenadeSkill>();
AssetDatabase.CreateAsset(skill, "Assets/" + skill.GetType().Name + ".asset");
}
#endif
public override void Aiming()
{
character.StartCoroutine(AimingRoutine());
}
private IEnumerator AimingRoutine()
{
explosionRangeRenderer = Instantiate(character.skillRangeRenderer);
while (true)
{
yield return new WaitForEndOfFrame();
character.DrawSkillRange(SkillRange);
explosionRangeRenderer.DrawCircle(Camera.main.ScreenToWorldPoint(Input.mousePosition), explosionRadius);
if (Input.GetMouseButton(0))
{
Use();
break;
}
}
Destroy(explosionRangeRenderer.gameObject);
}
protected override void Use()
{
GameObject obj = Instantiate(grenadePrefab, character.transform.position, character.transform.rotation);
obj.GetComponent<Grenade>().Init(Camera.main.ScreenToWorldPoint(Input.mousePosition), explosionRadius,explosionTime);
character.DisableSkillRangeRenderer();
}
}
fileFormatVersion: 2
guid: affe345c8b2c9d24bab2cea6041cf994
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -19,6 +19,10 @@ public abstract class Skill : ScriptableObject
private Sprite m_skillImage;
public Sprite SkillImage { get { return m_skillImage; } }
[SerializeField]
private float m_skillRange;
public float SkillRange { get { return m_skillRange; } }
[SerializeField]
private float cooltime;
protected float m_remainedCooltime = 0;
......@@ -27,6 +31,7 @@ public abstract class Skill : ScriptableObject
public bool IsReady { get { return m_remainedCooltime <= 0; } }
public float CooltimeRatio { get { return m_remainedCooltime / cooltime; } }
public virtual void UpdateSkill(float deltaTime)
{
m_remainedCooltime = Mathf.Max(0, m_remainedCooltime - deltaTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment