add scriptable object examples
add editor window example add attribute + drawer example
This commit is contained in:
@@ -1,34 +1,47 @@
|
||||
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 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("References")]
|
||||
// [SerializeField] private Image healthBarFillingImage;
|
||||
|
||||
[Header("Abilities")] [SerializeField] private Ability ability;
|
||||
[SerializeField] private Ability[] abilities;
|
||||
|
||||
public float _currentHealth; // stupid public value for testing
|
||||
// public float _currentHealth; // stupid public value for testing
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_currentHealth = maxHealth;
|
||||
// _currentHealth = maxHealth;
|
||||
|
||||
// set health
|
||||
health.Value = maxHealth.Value;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
healthBarFillingImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,
|
||||
Mathf.Clamp01(_currentHealth / maxHealth) * 200.0f);
|
||||
// healthBarFillingImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,
|
||||
// Mathf.Clamp01(_currentHealth / maxHealth) * 200.0f);
|
||||
|
||||
if (health.Value <= 0.0f) eventBroker.RaisePlayerDied();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user