Commit 4af38694 authored by Sebastian Frey's avatar Sebastian Frey
Browse files

Code Cleanup

parent 504bf5ed
using UnityEngine;
namespace _Game.Scripts.Elements
{
public class InteractionObject : MonoBehaviour
{
public void DoInteraction()
{
this.GetComponent<SpriteRenderer>().color = Color.green;
}
}
}
fileFormatVersion: 2
guid: 5782222d4c9b9424ea96676650e643a8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InteractionObject : MonoBehaviour
{
public void DoInteraction()
{
this.GetComponent<SpriteRenderer>().color = Color.green;
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerInteract : MonoBehaviour
{
private GameObject currentObject;
private InteractionObject targetScript;
private void Update()
{
if (Input.GetButtonDown("Interact") && currentObject)
{
targetScript.DoInteraction();
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Element"))
{
Debug.Log("Entered Collider of " + other.name);
currentObject = other.gameObject;
targetScript = currentObject.GetComponent<InteractionObject>();
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.CompareTag("Element"))
{
if (other.gameObject == currentObject)
{
Debug.Log("Exited Collider of " + other.name);
currentObject = null;
targetScript = null;
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class Movement : MonoBehaviour {
namespace _Game.Scripts.Player
{
public class Movement : MonoBehaviour {
public float speed = 1.0f;
public float GroundDist = 0.5f;
public int layer;
public float speed = 1.0f;
public float groundDist = 0.5f;
public int layer;
private Transform player;
private Rigidbody2D r2d;
private float xAxis;
private Transform _player;
private Rigidbody2D _r2D;
private float _xAxis;
// Start is called before the first frame update
void Start () {
player = GetComponent<Transform>();
}
// Start is called before the first frame update
private void Start () {
_player = GetComponent<Transform>();
}
// Update is called once per frame
void Update () {
Move ();
}
// Update is called once per frame
private void Update () {
Move ();
}
void Move () {
xAxis = Input.GetAxis("Horizontal");
player.position += new Vector3(xAxis, 0, 0).normalized * speed * Time.deltaTime;
}
private void Move () {
_xAxis = Input.GetAxis("Horizontal");
_player.position += new Vector3(_xAxis, 0, 0).normalized * speed * Time.deltaTime;
}
bool Grounded(){
return Physics2D.Raycast(new Vector2(player.position.x, player.position.y) + (Vector2.up * 0.5f), Vector2.down, GroundDist, layer);
}
private bool Grounded()
{
var position = _player.position;
return Physics2D.Raycast(new Vector2(position.x, position.y) + (Vector2.up * 0.5f), Vector2.down, groundDist, layer);
}
}
}
\ No newline at end of file
using UnityEngine;
using _Game.Scripts.Elements;
namespace _Game.Scripts.Player
{
public class PlayerInteract : MonoBehaviour
{
private GameObject _currentObject;
private InteractionObject _targetScript;
private void Update()
{
if (Input.GetButtonDown("Interact") && _currentObject)
{
_targetScript.DoInteraction();
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("Element")) return;
Debug.Log("Entered Collider of " + other.name);
_currentObject = other.gameObject;
_targetScript = _currentObject.GetComponent<InteractionObject>();
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag("Element")) return;
if (other.gameObject != _currentObject) return;
Debug.Log("Exited Collider of " + other.name);
_currentObject = null;
_targetScript = null;
}
}
}
fileFormatVersion: 2
guid: efba442f6715bfe40b18801f66985717
guid: 284bf9e64b1631a4897eb66683d31ab8
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
......@@ -2,17 +2,20 @@
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "PlayerState")]
public class PlayerState : ScriptableObject
namespace _Game.Scripts.Scriptable_Object
{
public InfusedElement currentElement;
}
[CreateAssetMenu(fileName = "New Player State", menuName = "PlayerState", order = 51)]
public class PlayerState : ScriptableObject
{
public InfusedElement currentElement;
}
public enum InfusedElement
{
None,
Fire,
Water,
Earth,
Air
}
public enum InfusedElement
{
None,
Fire,
Water,
Earth,
Air
}
}
\ No newline at end of file
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