Commit 03bcfdf7 authored by Sebastian Frey's avatar Sebastian Frey

gesammelte Elemente werden kurz inaktiv; Spieler steht beim sammeln

parent 01439d27
......@@ -17,6 +17,7 @@ GameObject:
- component: {fileID: 879798643589630551}
- component: {fileID: 1812781561854320914}
- component: {fileID: 1681811072}
- component: {fileID: 4724602922512031261}
m_Layer: 14
m_Name: Wind-Gegner
m_TagString: Enemy
......@@ -212,6 +213,24 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &4724602922512031261
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1634356314439590}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3c0ce2eb523274b6fa61fccbf0227d85, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MaxLife: 1
LostLife:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!1 &3664861546676776734
GameObject:
m_ObjectHideFlags: 0
......
......@@ -209,7 +209,7 @@ Transform:
m_GameObject: {fileID: 5004504}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 60, y: 1, z: 1}
m_LocalScale: {x: 100, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
......@@ -307,6 +307,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7333302375623909992, guid: e79fbf1855fce6e4387f467f1fb65960,
type: 3}
propertyPath: _cooldown
value: 5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e79fbf1855fce6e4387f467f1fb65960, type: 3}
--- !u!1001 &188879110
......@@ -433,6 +438,16 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 105682324961186856, guid: 615b74be12ac7ec4e9b491a7ef5cbbe1,
type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1116401710732013377, guid: 615b74be12ac7ec4e9b491a7ef5cbbe1,
type: 3}
propertyPath: _cooldown
value: 5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 615b74be12ac7ec4e9b491a7ef5cbbe1, type: 3}
--- !u!1001 &249750742
......@@ -446,6 +461,10 @@ PrefabInstance:
propertyPath: m_Name
value: Wind-Gegner
objectReference: {fileID: 0}
- target: {fileID: 1634356314439590, guid: 6cd7f8e10f89642fd88661db0d3f3827, type: 3}
propertyPath: m_TagString
value: Air
objectReference: {fileID: 0}
- target: {fileID: 4738352637052488, guid: 6cd7f8e10f89642fd88661db0d3f3827, type: 3}
propertyPath: m_LocalPosition.x
value: -16
......@@ -651,6 +670,10 @@ PrefabInstance:
propertyPath: m_Name
value: Erd-Gegner
objectReference: {fileID: 0}
- target: {fileID: 1634356314439590, guid: f73431649cac0ba4b9385829c74919c0, type: 3}
propertyPath: m_TagString
value: Earth
objectReference: {fileID: 0}
- target: {fileID: 4738352637052488, guid: f73431649cac0ba4b9385829c74919c0, type: 3}
propertyPath: m_LocalPosition.x
value: -10
......@@ -764,6 +787,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4686249919483620138, guid: 599519593b27fd2448e33dcb9f69045b,
type: 3}
propertyPath: _cooldown
value: 5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 599519593b27fd2448e33dcb9f69045b, type: 3}
--- !u!1001 &671048602
......@@ -849,6 +877,11 @@ PrefabInstance:
propertyPath: m_SecondsWaitToJump
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52145075018362291, guid: 2e3528907311e438dab0d393127aa332,
type: 3}
propertyPath: m_GroundedOffset.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 352228603, guid: 2e3528907311e438dab0d393127aa332, type: 3}
propertyPath: m_Enabled
value: 0
......@@ -869,6 +902,10 @@ PrefabInstance:
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 352228602, guid: 2e3528907311e438dab0d393127aa332, type: 3}
propertyPath: infusingTime
value: 1
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 8997061578198512906, guid: 2e3528907311e438dab0d393127aa332, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 2e3528907311e438dab0d393127aa332, type: 3}
......@@ -885,11 +922,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4738352637052488, guid: 436bce950d0b3f4499ca6ffc2704906a, type: 3}
propertyPath: m_LocalPosition.x
value: 9
value: -19.82
objectReference: {fileID: 0}
- target: {fileID: 4738352637052488, guid: 436bce950d0b3f4499ca6ffc2704906a, type: 3}
propertyPath: m_LocalPosition.y
value: 7
value: 4.69
objectReference: {fileID: 0}
- target: {fileID: 4738352637052488, guid: 436bce950d0b3f4499ca6ffc2704906a, type: 3}
propertyPath: m_LocalPosition.z
......@@ -996,6 +1033,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2771610206244380725, guid: 4512b8eb550115443bbba2ecd59a960c,
type: 3}
propertyPath: _cooldown
value: 5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4512b8eb550115443bbba2ecd59a960c, type: 3}
--- !u!1 &1685552533
......@@ -1087,12 +1129,12 @@ PrefabInstance:
- target: {fileID: 7732554449417407852, guid: a0c6081106659114387502f3e4d51362,
type: 3}
propertyPath: m_LocalPosition.x
value: 15
value: 33.95
objectReference: {fileID: 0}
- target: {fileID: 7732554449417407852, guid: a0c6081106659114387502f3e4d51362,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.5
value: 2.65
objectReference: {fileID: 0}
- target: {fileID: 7732554449417407852, guid: a0c6081106659114387502f3e4d51362,
type: 3}
......
......@@ -5,16 +5,36 @@ namespace _Game.Scripts.Elements
{
public class InteractionObject : MonoBehaviour
{
[SerializeField] private InfusedElement element;
[SerializeField] private float _cooldown;
private bool _isReady = true;
private SpriteRenderer _spriteRenderer;
private Color _defaultColor;
private Color _idleColor;
private void Start()
{
_spriteRenderer = GetComponent<SpriteRenderer>();
_defaultColor = _spriteRenderer.color;
_idleColor = new Color(_defaultColor.r, _defaultColor.g, _defaultColor.b, 0);
}
public void InfuseElement()
{
//this.GetComponent<SpriteRenderer>().color = Color.green;
Debug.Log("Infused " + this.gameObject.tag);
_isReady = false;
_spriteRenderer.color = _idleColor;
Invoke("SetReady", _cooldown);
}
private void SetReady()
{
_isReady = true;
_spriteRenderer.color = _defaultColor;
}
public InfusedElement GetElement()
public bool GetIsReady()
{
return element;
return _isReady;
}
}
}
using UnityAtoms;
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Fire
......@@ -13,17 +14,17 @@ namespace _Game.Scripts.Player.PlayerAttacks.Fire
{
Invoke("Destroy", destroyTime);
}
void Destroy()
{
Destroy(gameObject);
}
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
{
if (collision.gameObject.CompareTag("Water"))
if (collision.gameObject.CompareTag("Water") || collision.gameObject.CompareTag("Air"))
{
collision.gameObject.GetComponent<Life>().Damage(1);
Destroy();
......
......@@ -16,7 +16,10 @@ namespace _Game.Scripts.Player
private GameObject _currentObject;
private InteractionObject _targetScript;
private Rigidbody2D _rigidbody2D;
[SerializeField] private PlayerState state;
[SerializeField] private float infusingTime;
private PlayerEarthAttack _earthAttack;
private Player_FireAttack _fireAttack;
......@@ -24,6 +27,9 @@ namespace _Game.Scripts.Player
private MovementController _controller;
private string _elementType;
private InteractionObject _elementScript;
private void Start()
{
_earthAttack = this.gameObject.GetComponent<PlayerEarthAttack>();
......@@ -32,10 +38,11 @@ namespace _Game.Scripts.Player
_controller = this.gameObject.GetComponent<MovementController>();
_rigidbody2D = this.gameObject.GetComponent<Rigidbody2D>();
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
//_controller.SetMovementParameters(state.GetCurrentMovementState());
}
private void Update()
......@@ -62,6 +69,7 @@ namespace _Game.Scripts.Player
state.ChangeCharges(-1);
}
break;
case InfusedElement.Air:
case InfusedElement.None:
break;
default:
......@@ -69,38 +77,12 @@ namespace _Game.Scripts.Player
}
}
if (Input.GetButtonDown("Interact") && _currentObject)
if (Input.GetButtonDown("Interact") && _currentObject && _targetScript.GetIsReady())
{
switch (_currentObject.tag)
{
case "Air":
state.UpdateElement(InfusedElement.Air);
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Earth":
state.UpdateElement(InfusedElement.Earth);
_earthAttack.enabled = true;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Fire":
state.UpdateElement(InfusedElement.Fire);
_earthAttack.enabled = false;
_fireAttack.enabled = true;
_waterAttack.enabled = false;
break;
case "Water":
state.UpdateElement(InfusedElement.Water);
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
_targetScript.InfuseElement();
_rigidbody2D.bodyType = RigidbodyType2D.Static;
_elementType = _currentObject.tag;
_elementScript = _targetScript;
Invoke("SuckIt", infusingTime);
}
if (Input.GetButtonDown("Cancel Element"))
......@@ -111,9 +93,43 @@ namespace _Game.Scripts.Player
_fireAttack.enabled = false;
_waterAttack.enabled = false;
}
//_controller.SetMovementParameters(state.GetCurrentMovementState());
}
private void SuckIt()
{
switch (_elementType)
{
case "Air":
state.UpdateElement(InfusedElement.Air);
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Earth":
state.UpdateElement(InfusedElement.Earth);
_earthAttack.enabled = true;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Fire":
state.UpdateElement(InfusedElement.Fire);
_earthAttack.enabled = false;
_fireAttack.enabled = true;
_waterAttack.enabled = false;
break;
case "Water":
state.UpdateElement(InfusedElement.Water);
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
_elementScript.InfuseElement();
_rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
}
private void OnTriggerEnter2D(Collider2D other)
{
......
......@@ -53,4 +53,4 @@ Physics2DSettings:
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffefffffffffffffbfeffffffffffffffffffffffffffffebffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
......@@ -31,7 +31,7 @@ TagManager:
- BackgroundTileMap
- Enemy
- MovableObject
-
- EnemyAttack
-
-
-
......
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