From d5d9357cf82fb4a7e4533acc6e31a412186c05b1 Mon Sep 17 00:00:00 2001 From: dart Date: Sun, 3 Apr 2022 03:01:22 +0300 Subject: [PATCH] Mob feautures --- ldjam50/Assets/Prefabs/Abilities.meta | 8 + .../Prefabs/Abilities/Ultraviolet.prefab | 158 ++++++++++++++++++ .../Prefabs/Abilities/Ultraviolet.prefab.meta | 7 + ldjam50/Assets/Scripts/Abilities.meta | 8 + .../Assets/Scripts/Abilities/Ultraviolet.cs | 34 ++++ .../Scripts/Abilities/Ultraviolet.cs.meta | 11 ++ ldjam50/Assets/Scripts/Character.cs | 4 +- ldjam50/Assets/Scripts/Mob.cs | 36 ++-- ldjam50/Assets/Scripts/OverMind.cs | 10 +- ldjam50/ProjectSettings/TagManager.asset | 1 + 10 files changed, 262 insertions(+), 15 deletions(-) create mode 100644 ldjam50/Assets/Prefabs/Abilities.meta create mode 100644 ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab create mode 100644 ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab.meta create mode 100644 ldjam50/Assets/Scripts/Abilities.meta create mode 100644 ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs create mode 100644 ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs.meta diff --git a/ldjam50/Assets/Prefabs/Abilities.meta b/ldjam50/Assets/Prefabs/Abilities.meta new file mode 100644 index 0000000..bf54bdb --- /dev/null +++ b/ldjam50/Assets/Prefabs/Abilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7beb512e9f6d1f6cf8d4e41d4b2cd856 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab b/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab new file mode 100644 index 0000000..91a0e97 --- /dev/null +++ b/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab @@ -0,0 +1,158 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6196285449860538992 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4291895258293432843} + - component: {fileID: 4864008898460965936} + - component: {fileID: 6102265118150421119} + m_Layer: 0 + m_Name: Square + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4291895258293432843 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6196285449860538992} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1.15, y: -0.48, z: 1.3160809} + m_LocalScale: {x: 4.1, y: 0.18550389, z: 1} + m_Children: [] + m_Father: {fileID: 4220328572880531123} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &4864008898460965936 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6196285449860538992} + 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_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: 7482667652216324306, guid: 48e93eef0688c4a259cb0eddcd8661f7, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &6102265118150421119 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6196285449860538992} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.00081826746, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.9983634, y: 1} + m_EdgeRadius: 0 +--- !u!1 &6863736067666425520 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4220328572880531123} + - component: {fileID: 7866767662200354342} + m_Layer: 0 + m_Name: Ultraviolet + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4220328572880531123 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6863736067666425520} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.8834, y: 0.72714, z: -2.1158} + m_LocalScale: {x: 1.6076, y: 1.6076, z: 1.6076} + m_Children: + - {fileID: 4291895258293432843} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7866767662200354342 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6863736067666425520} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 49f585561ea104de189705939209031c, type: 3} + m_Name: + m_EditorClassIdentifier: + beam: {fileID: 6196285449860538992} + rotationSpeed: 1 + damage: 0 diff --git a/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab.meta b/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab.meta new file mode 100644 index 0000000..edaa7ea --- /dev/null +++ b/ldjam50/Assets/Prefabs/Abilities/Ultraviolet.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bc5b45bd6fa94ff02acf62aa17c345a1 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Abilities.meta b/ldjam50/Assets/Scripts/Abilities.meta new file mode 100644 index 0000000..735e15c --- /dev/null +++ b/ldjam50/Assets/Scripts/Abilities.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c63b17a518eaed3e193bafd9c6f89e90 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs b/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs new file mode 100644 index 0000000..ac9a704 --- /dev/null +++ b/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Ultraviolet : MonoBehaviour +{ + [SerializeField] private GameObject beam; + + [SerializeField] private float rotationSpeed; + + [SerializeField] private float damage; + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + //beam.transform.rotation.eulerAngles += new Vector3(0, 0 0.2f); + beam.transform.Rotate(new Vector3(0,0,1), rotationSpeed * Time.deltaTime); + } + + void OnTriggerEnter2D(Collider2D col) + { + Debug.Log("PIZDAAAAAA"); + if (col.gameObject.CompareTag("Mob")) + { + Debug.Log("PIZDAAAAAA"); + col.gameObject.GetComponent().SendMessage("ApplyDamage", damage); + } + } +} diff --git a/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs.meta b/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs.meta new file mode 100644 index 0000000..589a9fe --- /dev/null +++ b/ldjam50/Assets/Scripts/Abilities/Ultraviolet.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49f585561ea104de189705939209031c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Character.cs b/ldjam50/Assets/Scripts/Character.cs index 2a9af91..c58e43f 100644 --- a/ldjam50/Assets/Scripts/Character.cs +++ b/ldjam50/Assets/Scripts/Character.cs @@ -48,8 +48,8 @@ public StatReturn GetStats() return stats; } - public void ApplyDamage(float newDamage) + public void ApplyDamage(float damage) { - damage += newDamage; + health -= damage; } } diff --git a/ldjam50/Assets/Scripts/Mob.cs b/ldjam50/Assets/Scripts/Mob.cs index acfa702..64dd977 100644 --- a/ldjam50/Assets/Scripts/Mob.cs +++ b/ldjam50/Assets/Scripts/Mob.cs @@ -1,7 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using UnityEngine; +using UnityEngine.UI; public class Mob : MonoBehaviour { @@ -9,20 +11,28 @@ public class Mob : MonoBehaviour [SerializeField] private OverMind overMind; [SerializeField] private float moveSpeed; + [SerializeField] private float health; + [SerializeField] private float damage; [SerializeField] private float minDist; [SerializeField] private float maxDist; - //private Character character; - - // Start is called before the first frame update - void Start() + + [SerializeField] private TextMesh healthText; + + public void ApplyDamage(float damage) { - + health -= damage; } // Update is called once per frame void Update() { + if (health < 0) + { + overMind.DeathGoToPull(gameObject); + } + + healthText.text = health.ToString(CultureInfo.InvariantCulture); //transform.LookAt(characterObject.transform); if (Vector3.Distance(transform.position, characterObject.transform.position) >= minDist) @@ -69,17 +79,21 @@ void Update() } void OnTriggerEnter2D(Collider2D col) { - Debug.Log("PIZDAAAAAA"); - overMind.DeathGoToPull(gameObject); - } - - private void Death() - { + if (col.gameObject.CompareTag("Character")) + { + characterObject.GetComponent().SendMessage("ApplyDamage", damage); + overMind.DeathGoToPull(gameObject); + } + //Debug.Log("PIZDAAAAAA"); + } + public void SetupMob(OverMind.MobParameters mobParameters) { characterObject = mobParameters.Character; moveSpeed = mobParameters.MoveSpeed; overMind = mobParameters.OverMind; + health = mobParameters.Health; + damage = mobParameters.Damage; } } diff --git a/ldjam50/Assets/Scripts/OverMind.cs b/ldjam50/Assets/Scripts/OverMind.cs index 774a4c2..6a207d5 100644 --- a/ldjam50/Assets/Scripts/OverMind.cs +++ b/ldjam50/Assets/Scripts/OverMind.cs @@ -10,6 +10,8 @@ public class OverMind : MonoBehaviour [SerializeField] private GameObject characterObject; [SerializeField] private float mobMoveSpeed; + [SerializeField] private float mobHealth; + [SerializeField] private float mobDamage; [SerializeField] private GameObject mobPull; [SerializeField] private GameObject activeMobs; @@ -32,6 +34,8 @@ public struct MobParameters public float MoveSpeed; public GameObject Character; public OverMind OverMind; + public float Health; + public float Damage; } void Start() @@ -101,7 +105,9 @@ private void PreHeaterSpawn() { MoveSpeed = mobMoveSpeed, Character = characterObject, - OverMind = this + OverMind = this, + Health = mobHealth, + Damage = mobDamage, }; newMob.GetComponent().SetupMob(newMobParameters); @@ -125,7 +131,7 @@ IEnumerator spawnMobsCourutine() { while(true) { - Debug.Log ("OnCoroutine: "+(int)Time.time); + //Debug.Log ("OnCoroutine: "+(int)Time.time); yield return new WaitForSeconds(1f); var mobToSpawn = mobPull.transform.GetChild(0); diff --git a/ldjam50/ProjectSettings/TagManager.asset b/ldjam50/ProjectSettings/TagManager.asset index b99ab8d..9587530 100644 --- a/ldjam50/ProjectSettings/TagManager.asset +++ b/ldjam50/ProjectSettings/TagManager.asset @@ -5,6 +5,7 @@ TagManager: serializedVersion: 2 tags: - Character + - Mob layers: - Default - TransparentFX