Sword Halo & Arrow to the nearest enemy

This commit is contained in:
2023-10-17 10:55:31 +02:00
parent eb51da13ed
commit ec1084bd10
23 changed files with 1097 additions and 3 deletions
+29 -1
View File
@@ -13,7 +13,8 @@ GameObject:
- component: {fileID: 1364958835108450234} - component: {fileID: 1364958835108450234}
- component: {fileID: 4588410858226605926} - component: {fileID: 4588410858226605926}
- component: {fileID: 247299863115505385} - component: {fileID: 247299863115505385}
m_Layer: 0 - component: {fileID: 5118712594196875348}
m_Layer: 6
m_Name: Mayor m_Name: Mayor
m_TagString: Ennemy m_TagString: Ennemy
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@@ -168,3 +169,30 @@ BoxCollider2D:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.19, y: 0.49} m_Size: {x: 0.19, y: 0.49}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!50 &5118712594196875348
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6061697268588932327}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
+68
View File
@@ -39,6 +39,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 4152598028236711869} - {fileID: 4152598028236711869}
- {fileID: 4740856695113674186}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &4824869534615406026 --- !u!212 &4824869534615406026
@@ -280,6 +281,73 @@ MonoBehaviour:
laser: {fileID: 4893257253370123985, guid: 95cb513377bf0e248bd66d6f7ddae920, type: 3} laser: {fileID: 4893257253370123985, guid: 95cb513377bf0e248bd66d6f7ddae920, type: 3}
laserOnX: 0 laserOnX: 0
laserOnY: 0 laserOnY: 0
arrow: {fileID: 6280786298679187013, guid: 856a449688373494987701d49b79a7af, type: 3}
--- !u!1001 &993819705047970090
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 3622515600777588477}
m_Modifications:
- target: {fileID: -8230784050683220836, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: initialSwordsCount
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3957911104700806788, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_Name
value: Halo
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
--- !u!4 &4740856695113674186 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5476423095808072928, guid: fd7d128113472244d88a3fc511da99a0, type: 3}
m_PrefabInstance: {fileID: 993819705047970090}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1611953582756194365 --- !u!1001 &1611953582756194365
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
+54 -1
View File
@@ -1,19 +1,22 @@
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
[RequireComponent (typeof(PlayerMovements))] [RequireComponent (typeof(PlayerMovements))]
public class PlayerWeapons : MonoBehaviour public class PlayerWeapons : MonoBehaviour
{ {
[SerializeField] private GameObject laser; [SerializeField] private GameObject laser;
[Header("If all are false: only on 1 side")]
[SerializeField] private bool laserOnX; [SerializeField] private bool laserOnX;
[SerializeField] private bool laserOnY; [SerializeField] private bool laserOnY;
[SerializeField] private GameObject arrow;
private PlayerMovements _pm; private PlayerMovements _pm;
private void Start() private void Start()
{ {
_pm = GetComponent<PlayerMovements>(); _pm = GetComponent<PlayerMovements>();
InvokeRepeating(nameof(ShootBeam), 5f, 5f); InvokeRepeating(nameof(ShootBeam), 5f, 5f);
InvokeRepeating(nameof(ShootArrow), 2f, 2f);
} }
private void ShootBeam() private void ShootBeam()
@@ -32,4 +35,54 @@ public class PlayerWeapons : MonoBehaviour
} }
} }
private void ShootArrow()
{
// Get all enemies in given radius
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, 20f, LayerMask.GetMask("Enemy"));
if (hits.Length <= 0)
{
return;
}
GameObject target = null;
float shortestDistance = Mathf.Infinity;
for(int i = 0; i < hits.Length; i++)
{
float distance = Vector3.Distance(transform.position, hits[i].transform.position);
if (distance < shortestDistance)
{
shortestDistance = distance;
target = hits[i].gameObject;
}
}
// Shoot arrow
if (target != null)
{
GameObject spawnedArrow = Instantiate(arrow, transform.position, Quaternion.identity);
spawnedArrow.GetComponent<Arrow>().target = target;
}
}
GameObject GetClosestEnemy(GameObject[] enemies)
{
GameObject bestTarget = null;
float closestDistanceSqr = Mathf.Infinity;
Vector3 currentPosition = transform.position;
foreach (GameObject potentialTarget in enemies)
{
Vector3 directionToTarget = potentialTarget.transform.position - currentPosition;
float dSqrToTarget = directionToTarget.sqrMagnitude;
if (dSqrToTarget < closestDistanceSqr)
{
closestDistanceSqr = dSqrToTarget;
bestTarget = potentialTarget;
}
}
return bestTarget;
}
} }
+128
View File
@@ -123,6 +123,67 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1001 &8782028
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4588410858226605926, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: speed
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 6061697268588932327, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_Name
value: Mayor (2)
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.x
value: -2.39
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.y
value: 1.78
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
--- !u!4 &325474385 stripped --- !u!4 &325474385 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 3622515600777588477, guid: 05d927a24df204541afbb77f1af3a9a2, type: 3} m_CorrespondingSourceObject: {fileID: 3622515600777588477, guid: 05d927a24df204541afbb77f1af3a9a2, type: 3}
@@ -291,6 +352,67 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4ce1de8b166656e4a97422e7ac85530b, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 4ce1de8b166656e4a97422e7ac85530b, type: 3}
--- !u!1001 &1503345568
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4588410858226605926, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: speed
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 6061697268588932327, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_Name
value: Mayor (1)
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.x
value: 5.31
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.y
value: 3.93
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8999614972709205858, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 797fec3354cfff54e95743a263e79f8f, type: 3}
--- !u!1001 &1803491063 --- !u!1001 &1803491063
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -360,6 +482,10 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 3553905824341430, guid: 05d927a24df204541afbb77f1af3a9a2, type: 3}
propertyPath: initialSwordsCount
value: 5
objectReference: {fileID: 0}
- target: {fileID: 1784956759114531697, guid: 05d927a24df204541afbb77f1af3a9a2, type: 3} - target: {fileID: 1784956759114531697, guid: 05d927a24df204541afbb77f1af3a9a2, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Player value: Player
@@ -481,5 +607,7 @@ SceneRoots:
- {fileID: 519420032} - {fileID: 519420032}
- {fileID: 5393968438828368982} - {fileID: 5393968438828368982}
- {fileID: 1803491063} - {fileID: 1803491063}
- {fileID: 1503345568}
- {fileID: 8782028}
- {fileID: 5921508570549303515} - {fileID: 5921508570549303515}
- {fileID: 1252793503} - {fileID: 1252793503}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56ac331b9976ab045b26c6ace72bf83e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+27
View File
@@ -0,0 +1,27 @@
using UnityEngine;
public class Arrow : MonoBehaviour
{
public int Damages = 10;
public GameObject target;
private void Update()
{
transform.position = Vector3.MoveTowards(transform.position, target.transform.position, 20f * Time.deltaTime);
if (target == null)
{
Destroy(gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Ennemy"))
{
collision.gameObject.GetComponent<Ennemy>().Life -= Damages;
Destroy(gameObject);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07290ccb39a0b6f4b9054a0ddfbf0010
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

+127
View File
@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 7c78d103104212d46820314794f6d4e0
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
+147
View File
@@ -0,0 +1,147 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6280786298679187013
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5329668281820824229}
- component: {fileID: 2550340728729587092}
- component: {fileID: 5085684478776765362}
- component: {fileID: 1122248669417151642}
m_Layer: 0
m_Name: Arrow
m_TagString: Ennemy
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5329668281820824229
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6280786298679187013}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2550340728729587092
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6280786298679187013}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, 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: 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: 21300000, guid: 7c78d103104212d46820314794f6d4e0, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.17, y: 0.05}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!61 &5085684478776765362
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6280786298679187013}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.17, y: 0.05}
newSize: {x: 0.17, y: 0.05}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.17, y: 0.05}
m_EdgeRadius: 0
--- !u!114 &1122248669417151642
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6280786298679187013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 07290ccb39a0b6f4b9054a0ddfbf0010, type: 3}
m_Name:
m_EditorClassIdentifier:
Damages: 10
target: {fileID: 0}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 856a449688373494987701d49b79a7af
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cd2347eaf9135d046b0966c606b05c0e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+60
View File
@@ -0,0 +1,60 @@
using System.Collections.Generic;
using UnityEngine;
public class Halo : MonoBehaviour
{
[SerializeField]
private int radius = 1;
[SerializeField]
private int initialSwordsCount = 5;
[SerializeField]
private GameObject _sword;
private List<GameObject> swords = new();
private void Start()
{
float angle = Mathf.PI*2f / initialSwordsCount;
for(int i = 0; i < initialSwordsCount; i++)
{
GameObject sword = Instantiate(
_sword,
transform.position + new Vector3(Mathf.Cos(i * angle), Mathf.Sin(i * angle), 0),
Quaternion.identity,
transform
);
swords.Add(sword);
}
}
private void Update()
{
transform.Rotate(Vector3.forward, 200f * Time.deltaTime, Space.Self);
}
private void OnDrawGizmos()
{
Gizmos.DrawWireSphere(transform.position, radius);
}
public void AddSword()
{
for(int i = 0; i < swords.Count; i++)
{
Destroy(swords[i]);
}
swords.Clear();
float angle = Mathf.PI * 2f / initialSwordsCount;
for (int i = 0; i < initialSwordsCount; i++)
{
GameObject sword = Instantiate(
_sword,
transform.position + new Vector3(Mathf.Cos(i * angle), Mathf.Sin(i * angle), 0),
Quaternion.identity,
transform
);
swords.Add(sword);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c66d516caeed4214d850b87e7b964e5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+49
View File
@@ -0,0 +1,49 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3957911104700806788
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5476423095808072928}
- component: {fileID: -8230784050683220836}
m_Layer: 0
m_Name: Halo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5476423095808072928
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3957911104700806788}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &-8230784050683220836
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3957911104700806788}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c66d516caeed4214d850b87e7b964e5f, type: 3}
m_Name:
m_EditorClassIdentifier:
radius: 1
initialSwordsCount: 10
_sword: {fileID: 4974588604955100116, guid: d21b2e937bf67eb4c8fc3db75696d4ce, type: 3}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fd7d128113472244d88a3fc511da99a0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+33
View File
@@ -0,0 +1,33 @@
using UnityEngine;
[RequireComponent (typeof(BoxCollider2D))]
public class Sword : MonoBehaviour
{
public int Damages = 25;
private void Update()
{
RotateSword();
}
private void RotateSword()
{
// LookAt 2D
Vector3 target = transform.parent.position;
// get the angle
Vector3 norTar = (target - transform.position).normalized;
float angle = Mathf.Atan2(norTar.y, norTar.x) * Mathf.Rad2Deg;
// rotate to angle
Quaternion rotation = new();
rotation.eulerAngles = new Vector3(0, 0, angle - 180);
transform.rotation = rotation;
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Ennemy") && collision.gameObject != null)
{
collision.GetComponent<Ennemy>().Life -= Damages;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eb7d27bb22bd0cb4aaa180bffb894086
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

+127
View File
@@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 51073fff944dadb4db1ed99b95749f92
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
+177
View File
@@ -0,0 +1,177 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2562985348320510001
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 134652930934767754}
- component: {fileID: 4192855879509752947}
m_Layer: 0
m_Name: Sprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &134652930934767754
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2562985348320510001}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: -0.38268343, w: 0.92387956}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2092803419585940329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -45}
--- !u!212 &4192855879509752947
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2562985348320510001}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, 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: 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: 21300000, guid: 51073fff944dadb4db1ed99b95749f92, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &4974588604955100116
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2092803419585940329}
- component: {fileID: -8018772042839309711}
- component: {fileID: 5490123958980842494}
m_Layer: 0
m_Name: Sword
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2092803419585940329
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4974588604955100116}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 134652930934767754}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &-8018772042839309711
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4974588604955100116}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eb7d27bb22bd0cb4aaa180bffb894086, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!61 &5490123958980842494
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4974588604955100116}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.2, y: 0.1}
m_EdgeRadius: 0
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d21b2e937bf67eb4c8fc3db75696d4ce
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
@@ -6,7 +6,7 @@ public class LaserBeam : MonoBehaviour
{ {
public int Damages = 50; public int Damages = 50;
public float lifeSeconds = 1f; public float lifeSeconds = .5f;
public void Start() public void Start()
{ {