Renamed Healthbar animation and refactored BulletCalc.cs

This commit is contained in:
MarcUs7i 2024-10-09 11:56:51 +02:00
parent c1fa7a72b9
commit df6ee04c6b
24 changed files with 77 additions and 62 deletions

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 100%Live
m_Name: 100%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 25%Live
m_Name: 25%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 50%Live
m_Name: 50%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 75%Live
m_Name: 75%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -8,6 +8,12 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: 100
m_EventTreshold: 0
- m_ConditionMode: 2
m_ConditionEvent: 75
m_EventTreshold: 0
- m_ConditionMode: 1
m_ConditionEvent: 50
m_EventTreshold: 0
@ -57,7 +63,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 100%Leben
m_Name: 100%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -83,7 +89,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 75%Leben
m_Name: 75%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -144,7 +150,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 25%Leben
m_Name: 25%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -177,25 +183,25 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: 75
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: 50
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: 25
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -216,7 +222,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 50%Leben
m_Name: 50%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -243,6 +249,15 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: 100
m_EventTreshold: 0
- m_ConditionMode: 2
m_ConditionEvent: 75
m_EventTreshold: 0
- m_ConditionMode: 2
m_ConditionEvent: 50
m_EventTreshold: 0
- m_ConditionMode: 1
m_ConditionEvent: 25
m_EventTreshold: 0
@ -268,6 +283,9 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: 100
m_EventTreshold: 0
- m_ConditionMode: 1
m_ConditionEvent: 75
m_EventTreshold: 0

View file

@ -14,7 +14,7 @@ GameObject:
- component: {fileID: -5192191693051608455}
- component: {fileID: 4173109939112180973}
m_Layer: 0
m_Name: BulletAng
m_Name: BulletCalc
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View file

@ -42,7 +42,7 @@ public class Aleksei : MonoBehaviour
public Animator animator;
bool StopAttack = false;
bool NormalSpeeding = false;
public static float BulletAngDirection;
public static int BulletCalcDirection;
bool FirstStop = true;
bool Attacking = false;
public float encourageSec = 2.0f;
@ -108,12 +108,12 @@ public class Aleksei : MonoBehaviour
if (rb.velocity.x >= 0.01f)
{
enemyGFX.transform.localScale = new Vector3(-1f, 1f, 1f);
BulletAngDirection = 1f;
BulletAngDirection = -1f;
}
else if (rb.velocity.x <= -0.01f)
{
enemyGFX.transform.localScale = new Vector3(1f, 1f, 1f);
BulletAngDirection = 0f;
BulletAngDirection = 1f;
}
if (distance < attackRange)

View file

@ -1,38 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletAng : MonoBehaviour
{
public float speed = 20f;
public int damage = 40;
public Rigidbody2D rb;
public GameObject impactEffect;
public Vector3 desiredRotation0 = new Vector3(0f, 0f, 24f); // Change this to your desired rotation
public Vector3 desiredRotation1 = new Vector3(0f, 0f, -24f); // Change this to your desired rotation
void Start()
{
if (Aleksei.BulletAngDirection == 0f)
{
rb.velocity = -transform.right * speed;
transform.rotation = Quaternion.Euler(desiredRotation0);
}
if (Aleksei.BulletAngDirection == 1f)
{
rb.velocity = transform.right * speed;
transform.rotation = Quaternion.Euler(desiredRotation1);
}
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Enemy.TookDamage = true;
}
Instantiate(impactEffect, transform.position, transform.rotation);
Destroy(gameObject);
}
}

View file

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletCalc : MonoBehaviour
{
public float speed = 20f;
public int damage = 40;
public GameObject impactEffect;
public Vector3 desiredRotation = new Vector3(0f, 0f, 24f);
Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
Vector3 rotation = desiredRotation0;
rotation.z = rotation.z * -Aleksei.BulletCalcDirection;
rb.velocity = transform.right * Aleksei.BulletCalcDirection * speed;
transform.rotation = Quaternion.Euler(rotation);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
Enemy.TookDamage = true;
}
Instantiate(impactEffect, transform.position, transform.rotation);
Destroy(gameObject);
}
}

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 100%Leben
m_Name: 100%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 25%Leben
m_Name: 25%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 50%Leben
m_Name: 50%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -6,7 +6,7 @@ AnimationClip:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 75%Leben
m_Name: 75%Life
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0

View file

@ -116,7 +116,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 100%Live
m_Name: 100%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -142,7 +142,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 75%Live
m_Name: 75%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -233,7 +233,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 25%Live
m_Name: 25%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
@ -259,7 +259,7 @@ AnimatorState:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 50%Live
m_Name: 50%Life
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []