From 1f1f44e62c0f78a131262f1ee45e6842d9c75682 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 13 Jun 2022 02:56:05 +0300 Subject: [PATCH] character update --- ldjam50/Assets/Scripts/Character.meta | 8 +++++ ldjam50/Assets/Scripts/Character/Character.cs | 29 +++++++++++++++++++ .../Scripts/Character/Character.cs.meta | 11 +++++++ .../Scripts/Character/CharacterData.asset | 27 +++++++++++++++++ .../Character/CharacterData.asset.meta | 8 +++++ .../{Misc => Character}/CharacterData.cs | 4 ++- .../{Misc => Character}/CharacterData.cs.meta | 0 .../{Character.cs => Character_obsolete.cs} | 7 +++-- ...ter.cs.meta => Character_obsolete.cs.meta} | 0 9 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 ldjam50/Assets/Scripts/Character.meta create mode 100644 ldjam50/Assets/Scripts/Character/Character.cs create mode 100644 ldjam50/Assets/Scripts/Character/Character.cs.meta create mode 100644 ldjam50/Assets/Scripts/Character/CharacterData.asset create mode 100644 ldjam50/Assets/Scripts/Character/CharacterData.asset.meta rename ldjam50/Assets/Scripts/{Misc => Character}/CharacterData.cs (96%) rename ldjam50/Assets/Scripts/{Misc => Character}/CharacterData.cs.meta (100%) rename ldjam50/Assets/Scripts/{Character.cs => Character_obsolete.cs} (95%) rename ldjam50/Assets/Scripts/{Character.cs.meta => Character_obsolete.cs.meta} (100%) diff --git a/ldjam50/Assets/Scripts/Character.meta b/ldjam50/Assets/Scripts/Character.meta new file mode 100644 index 0000000..3fcb67a --- /dev/null +++ b/ldjam50/Assets/Scripts/Character.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2404d8b5a589d3078ac5c4223e0b3ec0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Character/Character.cs b/ldjam50/Assets/Scripts/Character/Character.cs new file mode 100644 index 0000000..ce228fa --- /dev/null +++ b/ldjam50/Assets/Scripts/Character/Character.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Character : MonoBehaviour +{ + + [SerializeField] private CharacterData characterData; + private Rigidbody2D rigidBody; + [SerializeField] private GameObject characterSprite; + private Animator animator; + private static readonly int IsRun = Animator.StringToHash("IsRun"); + + public void Start() + { + rigidBody = GetComponent(); + animator = characterSprite.GetComponent(); + } + + public void Update() + { + var horInput = Input.GetAxis("Horizontal"); + var verInput = Input.GetAxis("Vertical"); + rigidBody.velocity = new Vector2(horInput , verInput) * characterData.moveSpeedMultiplier; + characterSprite.transform.localScale = new Vector3(horInput > 0 ? 1 : -1, 1, 1); + animator.SetBool(IsRun, Mathf.Abs(horInput) > 0 || Mathf.Abs(verInput) > 0); + } +} diff --git a/ldjam50/Assets/Scripts/Character/Character.cs.meta b/ldjam50/Assets/Scripts/Character/Character.cs.meta new file mode 100644 index 0000000..d295e90 --- /dev/null +++ b/ldjam50/Assets/Scripts/Character/Character.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 584da5b9caaf58e0da2ae26a4bbe9d02 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Character/CharacterData.asset b/ldjam50/Assets/Scripts/Character/CharacterData.asset new file mode 100644 index 0000000..a9b7f2f --- /dev/null +++ b/ldjam50/Assets/Scripts/Character/CharacterData.asset @@ -0,0 +1,27 @@ +%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: 65ab2b639f4ff314a962ad5a94ab058a, type: 3} + m_Name: CharacterData + m_EditorClassIdentifier: + shootableObject: {fileID: 0} + staticShootable: {fileID: 0} + meleeWeapon: {fileID: 0} + moveSpeedMultiplier: 2 + crouchSpeed: 50 + crouchColliderHeight: 1 + normalColliderHeight: 2 + rotationSpeed: 60 + crouchRotationSpeed: 30 + jumpForce: 10 + diveForce: 30 + bulletInitialSpeed: 10 + diveCooldownTimer: 0.25 diff --git a/ldjam50/Assets/Scripts/Character/CharacterData.asset.meta b/ldjam50/Assets/Scripts/Character/CharacterData.asset.meta new file mode 100644 index 0000000..cf26fac --- /dev/null +++ b/ldjam50/Assets/Scripts/Character/CharacterData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4da5c8fa0351efd6c8284885156d13c6 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ldjam50/Assets/Scripts/Misc/CharacterData.cs b/ldjam50/Assets/Scripts/Character/CharacterData.cs similarity index 96% rename from ldjam50/Assets/Scripts/Misc/CharacterData.cs rename to ldjam50/Assets/Scripts/Character/CharacterData.cs index 9daa774..b006bd7 100644 --- a/ldjam50/Assets/Scripts/Misc/CharacterData.cs +++ b/ldjam50/Assets/Scripts/Character/CharacterData.cs @@ -29,6 +29,7 @@ */ using UnityEngine; +using UnityEngine.Serialization; [CreateAssetMenu(fileName = "CharacterData", menuName = "Game Data/Character Data")] public class CharacterData : ScriptableObject @@ -36,7 +37,8 @@ public class CharacterData : ScriptableObject public GameObject shootableObject; public GameObject staticShootable; public GameObject meleeWeapon; - public float movementSpeed = 150f; + [Range(1f,5f)] + public float moveSpeedMultiplier = 1f; public float crouchSpeed = 50f; public float crouchColliderHeight = 1f; public float normalColliderHeight = 2f; diff --git a/ldjam50/Assets/Scripts/Misc/CharacterData.cs.meta b/ldjam50/Assets/Scripts/Character/CharacterData.cs.meta similarity index 100% rename from ldjam50/Assets/Scripts/Misc/CharacterData.cs.meta rename to ldjam50/Assets/Scripts/Character/CharacterData.cs.meta diff --git a/ldjam50/Assets/Scripts/Character.cs b/ldjam50/Assets/Scripts/Character_obsolete.cs similarity index 95% rename from ldjam50/Assets/Scripts/Character.cs rename to ldjam50/Assets/Scripts/Character_obsolete.cs index aecc7ac..6d86c7e 100644 --- a/ldjam50/Assets/Scripts/Character.cs +++ b/ldjam50/Assets/Scripts/Character_obsolete.cs @@ -5,9 +5,9 @@ using UnityEngine; using UnityEngine.UI; -public class Character : MonoBehaviour +public class Character_obsolete : MonoBehaviour { - [SerializeField] private Gameplay _gameplay; + //[SerializeField] private Gameplay _gameplay; [SerializeField] private float health; [SerializeField] private float damage; [SerializeField] private float moveSpeed; @@ -84,6 +84,7 @@ public void ApplyDamage(float damage) { health -= damage; } + /* public float GetHealth() { return health; @@ -99,5 +100,5 @@ public void SetHealth(float newHealth) public void SetDamage(float newDamage) { damage = newDamage; - } + }*/ } diff --git a/ldjam50/Assets/Scripts/Character.cs.meta b/ldjam50/Assets/Scripts/Character_obsolete.cs.meta similarity index 100% rename from ldjam50/Assets/Scripts/Character.cs.meta rename to ldjam50/Assets/Scripts/Character_obsolete.cs.meta