Commit 56b5f4a6 authored by Sebastian Frey's avatar Sebastian Frey

Element kann gelöscht werden; GameEvents kommen jetzt vom PlayerState

parent 5e80266d
...@@ -12,15 +12,17 @@ MonoBehaviour: ...@@ -12,15 +12,17 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 353b156b7c59b1c45a8767d7500b31fb, type: 3} m_Script: {fileID: 11500000, guid: 353b156b7c59b1c45a8767d7500b31fb, type: 3}
m_Name: PlayerState m_Name: PlayerState
m_EditorClassIdentifier: m_EditorClassIdentifier:
currentInfusedElement: 0 currentInfusedElement: 1
currentMoveState: currentMoveState:
jumpForce: 10 jumpForce: 15
smoothing: 0.03 smoothing: 0.03
airControl: 1 airControl: 1
canSwim: 1 canSwim: 1
moveSpeed: 20 moveSpeed: 20
maxJumpCount: 1 maxJumpCount: 2
mass: 1 mass: 1
gravity: 3 gravity: 3
movementStates: {fileID: 11400000, guid: c757aad6925b37a46b916f609fa9012b, type: 2} movementStates: {fileID: 11400000, guid: c757aad6925b37a46b916f609fa9012b, type: 2}
charges: 2 onElementInfused: {fileID: 11400000, guid: 7e5b80a8353af1846a878c3a997bdb4a, type: 2}
onChargeChange: {fileID: 11400000, guid: 6ec6544f645a9d1458383b111fcaf8b6, type: 2}
charges: 0
...@@ -956,6 +956,12 @@ PrefabInstance: ...@@ -956,6 +956,12 @@ PrefabInstance:
propertyPath: m_MaxJumpCount propertyPath: m_MaxJumpCount
value: 2 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 52145075018362291, guid: 2e3528907311e438dab0d393127aa332,
type: 3}
propertyPath: r_State
value:
objectReference: {fileID: 11400000, guid: c5777bcc7b64ce24c9bd65d2c4b7c639,
type: 2}
- target: {fileID: 6060985002925283250, guid: 2e3528907311e438dab0d393127aa332, - target: {fileID: 6060985002925283250, guid: 2e3528907311e438dab0d393127aa332,
type: 3} type: 3}
propertyPath: lowJumpMultiplier propertyPath: lowJumpMultiplier
...@@ -1000,7 +1006,7 @@ MonoBehaviour: ...@@ -1000,7 +1006,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 83eb4399ff535ee4cbc76de3b8a32e46, type: 3} m_Script: {fileID: 11500000, guid: 83eb4399ff535ee4cbc76de3b8a32e46, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Cooldown: 0 cooldown: 0
volleySize: 10 volleySize: 10
launchPower: 10 launchPower: 10
attackSpeed: 0.1 attackSpeed: 0.1
...@@ -1018,6 +1024,9 @@ MonoBehaviour: ...@@ -1018,6 +1024,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ad90db0185377664288543ce4696c6b8, type: 3} m_Script: {fileID: 11500000, guid: ad90db0185377664288543ce4696c6b8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
cooldown: 0
massIncrease: 0
isStomping: 0
--- !u!114 &1876157330 --- !u!114 &1876157330
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1049,8 +1058,7 @@ MonoBehaviour: ...@@ -1049,8 +1058,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
state: {fileID: 11400000, guid: c5777bcc7b64ce24c9bd65d2c4b7c639, type: 2} state: {fileID: 11400000, guid: c5777bcc7b64ce24c9bd65d2c4b7c639, type: 2}
onElementInfused: {fileID: 11400000, guid: 7e5b80a8353af1846a878c3a997bdb4a, type: 2} onElementChanged: {fileID: 0}
onChargeChange: {fileID: 11400000, guid: 6ec6544f645a9d1458383b111fcaf8b6, type: 2}
--- !u!4 &1876157337 stripped --- !u!4 &1876157337 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 52145075018362285, guid: 2e3528907311e438dab0d393127aa332, m_CorrespondingSourceObject: {fileID: 52145075018362285, guid: 2e3528907311e438dab0d393127aa332,
......
using UnityEngine; using UnityEngine;
using _Game.Scripts.Scriptable_Object;
namespace _Game.Scripts.Elements namespace _Game.Scripts.Elements
{ {
public class InteractionObject : MonoBehaviour public class InteractionObject : MonoBehaviour
{ {
[SerializeField] private InfusedElement element;
public void InfuseElement() public void InfuseElement()
{ {
//this.GetComponent<SpriteRenderer>().color = Color.green; //this.GetComponent<SpriteRenderer>().color = Color.green;
Debug.Log("Infused " + this.gameObject.tag); Debug.Log("Infused " + this.gameObject.tag);
} }
public InfusedElement GetElement()
{
return element;
}
} }
} }
...@@ -19,9 +19,7 @@ namespace _Game.Scripts.Player ...@@ -19,9 +19,7 @@ namespace _Game.Scripts.Player
[SerializeField] private PlayerState state; [SerializeField] private PlayerState state;
[SerializeField] private ElementGameEvent onElementInfused; [SerializeField] private ElementGameEventListener onElementChanged;
[SerializeField] private ChargeGameEvent onChargeChange;
private PlayerAirAttack _airAttack; private PlayerAirAttack _airAttack;
private PlayerEarthAttack _earthAttack; private PlayerEarthAttack _earthAttack;
...@@ -44,7 +42,7 @@ namespace _Game.Scripts.Player ...@@ -44,7 +42,7 @@ namespace _Game.Scripts.Player
_earthAttack.enabled = false; _earthAttack.enabled = false;
_fireAttack.enabled = false; _fireAttack.enabled = false;
_waterAttack.enabled = false; _waterAttack.enabled = false;
_controller.SetMovementParameters(state.GetCurrentMovementState()); // _controller.SetMovementParameters(state.GetCurrentMovementState());
} }
private void Update() private void Update()
...@@ -64,78 +62,77 @@ namespace _Game.Scripts.Player ...@@ -64,78 +62,77 @@ namespace _Game.Scripts.Player
if (_earthAttack.Attack()) if (_earthAttack.Attack())
{ {
state.ChangeCharges(-1); state.ChangeCharges(-1);
onChargeChange.Raise();
} }
break; break;
case InfusedElement.Fire: case InfusedElement.Fire:
if (_fireAttack.Attack()) if (_fireAttack.Attack())
{ {
state.ChangeCharges(-1); state.ChangeCharges(-1);
onChargeChange.Raise();
} }
break; break;
case InfusedElement.Water: case InfusedElement.Water:
print("done");
if(_waterAttack.Attack()) if(_waterAttack.Attack())
{ {
state.ChangeCharges(-1); state.ChangeCharges(-1);
onChargeChange.Raise();
} }
break; break;
case InfusedElement.None: case InfusedElement.None:
break; break;
case InfusedElement.Air:
break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
} }
if (!Input.GetButtonDown("Interact") || !_currentObject) return; if (Input.GetButtonDown("Interact") && _currentObject)
{
switch (_currentObject.tag)
{
case "Air":
state.UpdateElement(InfusedElement.Air);
_airAttack.enabled = true;
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Earth":
state.UpdateElement(InfusedElement.Earth);
_airAttack.enabled = false;
_earthAttack.enabled = true;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Fire":
state.UpdateElement(InfusedElement.Fire);
_airAttack.enabled = false;
_earthAttack.enabled = false;
_fireAttack.enabled = true;
_waterAttack.enabled = false;
break;
case "Water":
state.UpdateElement(InfusedElement.Water);
_airAttack.enabled = false;
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
_targetScript.InfuseElement();
}
switch (_currentObject.tag) if (Input.GetButtonDown("Cancel Element"))
{ {
case "Air": state.UpdateElement(InfusedElement.None);
state.UpdateElement(InfusedElement.Air); state.ChangeCharges(-5);
state.ChangeCharges(3); _airAttack.enabled = false;
onElementInfused.Raise(InfusedElement.Air); _earthAttack.enabled = false;
onChargeChange.Raise(); _fireAttack.enabled = false;
_airAttack.enabled = true; _waterAttack.enabled = false;
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Earth":
state.UpdateElement(InfusedElement.Earth);
state.ChangeCharges(3);
onElementInfused.Raise(InfusedElement.Earth);
onChargeChange.Raise();
_airAttack.enabled = false;
_earthAttack.enabled = true;
_fireAttack.enabled = false;
_waterAttack.enabled = false;
break;
case "Fire":
state.UpdateElement(InfusedElement.Fire);
state.ChangeCharges(3);
onElementInfused.Raise(InfusedElement.Fire);
onChargeChange.Raise();
_airAttack.enabled = false;
_earthAttack.enabled = false;
_fireAttack.enabled = true;
_waterAttack.enabled = false;
break;
case "Water":
state.UpdateElement(InfusedElement.Water);
state.ChangeCharges(3);
onElementInfused.Raise(InfusedElement.Water);
onChargeChange.Raise();
_airAttack.enabled = false;
_earthAttack.enabled = false;
_fireAttack.enabled = false;
_waterAttack.enabled = true;
break;
} }
//_controller.SetMovementParameters(state.GetCurrentMovementState()); //_controller.SetMovementParameters(state.GetCurrentMovementState());
_targetScript.InfuseElement();
} }
......
...@@ -17,6 +17,9 @@ namespace _Game.Scripts.Scriptable_Object ...@@ -17,6 +17,9 @@ namespace _Game.Scripts.Scriptable_Object
[SerializeField] private MovementStates movementStates; [SerializeField] private MovementStates movementStates;
[SerializeField] private ElementGameEvent onElementInfused;
[SerializeField] private ChargeGameEvent onChargeChange;
[SerializeField][Range(0, 5)] private int charges; [SerializeField][Range(0, 5)] private int charges;
// [SerializeField] private float currentJumpForce; // [SerializeField] private float currentJumpForce;
...@@ -31,6 +34,11 @@ namespace _Game.Scripts.Scriptable_Object ...@@ -31,6 +34,11 @@ namespace _Game.Scripts.Scriptable_Object
{ {
currentInfusedElement = newElement; currentInfusedElement = newElement;
currentMoveState = movementStates.GetMovementState(newElement); currentMoveState = movementStates.GetMovementState(newElement);
onElementInfused.Raise(newElement);
if (newElement == InfusedElement.None) return;
ChangeCharges(5);
onChargeChange.Raise();
} }
public MovementState GetCurrentMovementState() public MovementState GetCurrentMovementState()
...@@ -38,22 +46,19 @@ namespace _Game.Scripts.Scriptable_Object ...@@ -38,22 +46,19 @@ namespace _Game.Scripts.Scriptable_Object
return currentMoveState; return currentMoveState;
} }
public bool ChangeCharges(int amount) public void ChangeCharges(int amount)
{ {
if ((charges + amount) > 5) if ((charges + amount) > 5)
{ {
charges = 5; charges = 5;
return true;
} else if ((charges + amount) <= 0) } else if ((charges + amount) <= 0)
{ {
charges = 0; charges = 0;
UpdateElement(InfusedElement.None); UpdateElement(InfusedElement.None);
return false;
} }
else else
{ {
charges += amount; charges += amount;
return true;
} }
} }
......
...@@ -54,13 +54,13 @@ InputManager: ...@@ -54,13 +54,13 @@ InputManager:
axis: 0 axis: 0
joyNum: 0 joyNum: 0
- serializedVersion: 3 - serializedVersion: 3
m_Name: Fire2 m_Name: Cancel Element
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: negativeButton:
positiveButton: left alt positiveButton: q
altNegativeButton: altNegativeButton:
altPositiveButton: mouse 1 altPositiveButton:
gravity: 1000 gravity: 1000
dead: 0.001 dead: 0.001
sensitivity: 1000 sensitivity: 1000
......
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