Commit 1f9290d4 authored by Unknown's avatar Unknown

PlayerAnimation erweitert

parent 20b16ac2
......@@ -200,7 +200,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.25
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
......
......@@ -78,9 +78,10 @@ GameObject:
- component: {fileID: 352228603}
- component: {fileID: 352228604}
- component: {fileID: 352228605}
- component: {fileID: 352228606}
- component: {fileID: 2596175625849265254}
- component: {fileID: 352228607}
- component: {fileID: 5703659376326297473}
- component: {fileID: 1141687766}
- component: {fileID: 1141687779}
m_Layer: 10
m_Name: Player
m_TagString: Player
......@@ -310,35 +311,6 @@ MonoBehaviour:
attackSpeed: 1
shotSpawn: {fileID: 2139239323}
fireBall: {fileID: 1870586037468468, guid: e5f7d8895a3df6547bca926919077d19, type: 3}
--- !u!114 &5703659376326297473
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52145075018362288}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78a856772da6c1c46a1edda241587b17, type: 3}
m_Name:
m_EditorClassIdentifier:
savePointList: []
--- !u!114 &8997061578198512906
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52145075018362288}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: -0.05, y: -0.3}
m_Size: {x: 1, y: 1.4}
m_Direction: 0
--- !u!114 &352228607
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -377,6 +349,68 @@ MonoBehaviour:
m_RotationOrder: 4
m_Time: 0.1
m_SizePerCharge: 0.2
m_Speed: 3
m_Radius: 1
m_RadiusSinDifference: 0.2
m_MaxScale: 0.3
m_ElementPrefab: {fileID: 3003439661819703112, guid: 484d043ea1f2a4f04bd827a3d15bea9b,
type: 3}
m_RotationOrigin: {fileID: 52145075018362285}
m_RotationOriginOffset: {x: 0, y: 0}
m_AirSprite: {fileID: 21300000, guid: fb7b033b78f4c7b44a9423c82efcd319, type: 3}
m_EarthSprite: {fileID: 21300000, guid: 0e669910a08f7cc4aab72705d1b69f9b, type: 3}
m_FireSprite: {fileID: 21300000, guid: f1a1b3fcad5c98845ba0de6c90e65b4d, type: 3}
m_WaterSprite: {fileID: 21300000, guid: 7a2ce65a83cff2340b4d887a879d765b, type: 3}
r_State: {fileID: 11400000, guid: c5777bcc7b64ce24c9bd65d2c4b7c639, type: 2}
r_Controller: {fileID: 52145075018362291}
r_Collider2D: {fileID: 0}
--- !u!114 &5703659376326297473
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52145075018362288}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78a856772da6c1c46a1edda241587b17, type: 3}
m_Name:
m_EditorClassIdentifier:
savePointList: []
--- !u!95 &1141687766
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52145075018362288}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 375b65aa2cf684af6978a76db238f875, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &1141687779
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52145075018362288}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c0ce2eb523274b6fa61fccbf0227d85, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MaxLife: 3
LostLife:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3003439661819703112
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3003439661819703113}
- component: {fileID: 3003439661819703114}
m_Layer: 0
m_Name: RotationElement
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &3003439661819703113
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3003439661819703112}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.92, y: -0.2, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3003439661819703114
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3003439661819703112}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
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_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -614652393
m_SortingLayer: 4
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: dc83a4d53c09d2c47b5eec2911bd35d0, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 10.24, y: 10.24}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
fileFormatVersion: 2
guid: 484d043ea1f2a4f04bd827a3d15bea9b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -8,10 +8,10 @@ public class Spikes : MonoBehaviour {
[SerializeField] private int m_Damage = 1;
void OnCollisionEnter2D(Collision2D col2D){
if(col2D.transform.gameObject.tag.Equals("Player")){
if(col2D.transform.gameObject.tag.Equals("Player") || col2D.transform.gameObject.tag.Equals("Enemy")){
Life l = col2D.transform.GetComponent<Life>();
l.Damage(m_Damage);
}
}
}
\ No newline at end of file
}
......@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using PlayerSpawnPointScript;
public class Life : MonoBehaviour {
......@@ -36,8 +37,11 @@ public class Life : MonoBehaviour {
public void Death(){
if (gameObject.CompareTag("Player"))
{
//PlayerSpawnPoint.psp.SetPlayerPosition();
gameObject.SetActive(false);
Heal(5);
Debug.Log("Death");
return;
}
Destroy(gameObject);
......
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Timers;
using UnityEngine;
using _Game.Scripts.Scriptable_Object;
public class PlayerAnimation : MonoBehaviour
{
public AnimationCurve m_AirScale;
[Header("Scaling")] public AnimationCurve m_AirScale;
public float m_Time = 10f;
public float m_SizePerCharge = 0.2f;
[SerializeField] private PlayerState r_State;
[Header("Rotation")] public float m_Speed = 3f;
public float m_Radius = 1f;
public float m_RadiusSinDifference = 0.3f;
public float m_MaxScale = 0.3f;
public GameObject m_ElementPrefab;
public Transform m_RotationOrigin;
public Vector2 m_RotationOriginOffset;
public Sprite m_AirSprite;
public Sprite m_EarthSprite;
public Sprite m_FireSprite;
public Sprite m_WaterSprite;
private List<GameObject> m_ElementOrbTransforms;
private List<SpriteRenderer> m_ElementOrbRenderer;
private float m_TimeCounter = 0;
[Header("References")] [SerializeField]
private PlayerState r_State;
[SerializeField] private MovementController r_Controller;
[SerializeField] private CapsuleCollider2D r_Collider2D;
private bool m_isAnimating = false;
private bool m_isScaled = false;
private bool m_isRotating = false;
private int m_PreviousCharges = 0;
private Vector3 m_OriginSize;
......@@ -31,12 +52,22 @@ public class PlayerAnimation : MonoBehaviour
m_OriginSize = transform.localScale;
m_OriginOffset = r_Controller.GroundCheckOffset;
m_OriginCheckDistance = r_Controller.GroundCheckDistance;
}
// Update is called once per frame
void Update()
{
//ScalePlayer();
m_ElementOrbTransforms = new List<GameObject>();
m_ElementOrbRenderer = new List<SpriteRenderer>();
float dis = 360 / 5; //need fix later
for (int i = 0; i < 5; i++)
{
GameObject obj = Instantiate(m_ElementPrefab, transform);
obj.SetActive(false);
m_ElementOrbTransforms.Add(obj);
m_ElementOrbRenderer.Add(obj.GetComponent<SpriteRenderer>());
float x = Mathf.Cos(i * Mathf.Deg2Rad * dis) * m_Radius;
float y = Mathf.Sin(i * Mathf.Deg2Rad * dis) * m_Radius;
Vector3 offset = m_RotationOriginOffset;
m_ElementOrbTransforms[i].transform.position = (m_RotationOrigin.position + offset + new Vector3(x, y, 0f));
}
}
public void OnChargesChange()
......@@ -44,16 +75,50 @@ public class PlayerAnimation : MonoBehaviour
switch (r_State.GetCurrentElement())
{
case InfusedElement.None:
m_isRotating = false;
SetRotationOrbsActive(false, 5);
ScalePlayer();
break;
case InfusedElement.Air:
ScalePlayer();
SetRotationOrbsActive(true, r_State.GetCharges());
SetRotationOrbSprite(m_AirSprite);
if (!m_isRotating)
{
m_isRotating = true;
StartCoroutine(RotatingElements());
}
break;
case InfusedElement.Fire:
SetRotationOrbsActive(true, r_State.GetCharges());
SetRotationOrbSprite(m_FireSprite);
if (!m_isRotating)
{
m_isRotating = true;
StartCoroutine(RotatingElements());
}
break;
case InfusedElement.Earth:
SetRotationOrbsActive(true, r_State.GetCharges());
SetRotationOrbSprite(m_EarthSprite);
if (!m_isRotating)
{
m_isRotating = true;
StartCoroutine(RotatingElements());
}
break;
case InfusedElement.Water:
SetRotationOrbsActive(true, r_State.GetCharges());
SetRotationOrbSprite(m_WaterSprite);
if (!m_isRotating)
{
m_isRotating = true;
StartCoroutine(RotatingElements());
}
break;
}
}
......@@ -62,7 +127,7 @@ public class PlayerAnimation : MonoBehaviour
{
int currentCharges = r_State.GetCharges();
int diff = currentCharges - m_PreviousCharges;
Debug.Log("current: " + currentCharges + " previous: " + m_PreviousCharges + " difference: " + diff);
//Debug.Log("current: " + currentCharges + " previous: " + m_PreviousCharges + " difference: " + diff);
if (!m_isAnimating || m_isAnimating)
{
if (diff > 0)
......@@ -97,10 +162,8 @@ public class PlayerAnimation : MonoBehaviour
transform.localScale = s + new Vector3(x * Mathf.Sign(s.x), x, x);
m_isAnimating = false;
}
private IEnumerator ScaleDown(int amount)
{
m_isAnimating = true;
......@@ -127,8 +190,53 @@ public class PlayerAnimation : MonoBehaviour
transform.localScale = m_OriginSize;
}
m_isAnimating = false;
}
private IEnumerator RotatingElements()
{
while (m_isRotating)
{
m_TimeCounter += Time.deltaTime * m_Speed;
float pos = 0;
for (int i = 0; i < m_ElementOrbTransforms.Count; i++)
{
pos = m_TimeCounter;
if(r_State.GetCharges() > 0)
pos = m_TimeCounter + i * Mathf.Deg2Rad * (360 / r_State.GetCharges());
float r = (m_Radius - m_RadiusSinDifference) + (m_RadiusSinDifference * Mathf.Sin(m_TimeCounter));
float x = Mathf.Cos(pos) * r;
float y = Mathf.Sin(pos) * r;
Vector3 offset = m_RotationOriginOffset;
//Transform elem = m_ElementOrbTransforms[i].transform;
m_ElementOrbTransforms[i].transform.position = m_RotationOrigin.position + offset + new Vector3(x, y, 0f);
yield return new WaitForFixedUpdate();
}
}
}
m_isAnimating = false;
private void SetRotationOrbsActive(bool value, int amount)
{
for (int i = 0; i < m_ElementOrbTransforms.Count; i++)
{
if (i < amount)
{
m_ElementOrbTransforms[i].SetActive(value);
}
else
{
m_ElementOrbTransforms[i].SetActive(!value);
}
}
}
private void SetRotationOrbSprite(Sprite s)
{
for (int i = 0; i < m_ElementOrbRenderer.Count; i++)
{
m_ElementOrbRenderer[i].sprite = s;
}
}
}
......@@ -19,7 +19,7 @@ namespace PlayerSpawnPointScript
SetPlayerPosition();
}
private void SetPlayerPosition()
public void SetPlayerPosition()
{
SavePointData savePosition = SaveSystem.LoadSavePoint();
transform.position = new Vector3(savePosition.position[0], savePosition.position[1], 0);
......
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