Files
gpd-924-en/EditorCustomization/Assets/Scripts/PlayerController.cs
T
david a6dbfb224f add scriptable object examples
add editor window example
add attribute + drawer example
2025-06-13 18:07:18 +02:00

47 lines
1.4 KiB
C#

using System;
using Attributes;
using Data;
using Events;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Events")]
[SerializeField] private EventBroker eventBroker;
[Header("Movement")]
[SerializeField] private float speed;
[SerializeField] private float rotationSpeed;
[Header("Values")]
// [SerializeField] private float maxHealth = 100.0f;
[SerializeField] private CharacterAttributes characterAttributes;
[SerializeField, Require] private FloatValue maxHealth;
[SerializeField, Require] private FloatValue health;
// [Header("References")]
// [SerializeField] private Image healthBarFillingImage;
[Header("Abilities")] [SerializeField] private Ability ability;
[SerializeField] private Ability[] abilities;
// public float _currentHealth; // stupid public value for testing
private void Awake()
{
// _currentHealth = maxHealth;
// set health
health.Value = maxHealth.Value;
}
private void Update()
{
// healthBarFillingImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,
// Mathf.Clamp01(_currentHealth / maxHealth) * 200.0f);
if (health.Value <= 0.0f) eventBroker.RaisePlayerDied();
}
}