Add Unity materials and prefabs for game objects for SOLID

This commit is contained in:
2026-03-31 18:37:10 +02:00
parent ba28ad06d3
commit f4ebe5ec8a
99 changed files with 8747 additions and 0 deletions
@@ -0,0 +1,45 @@
using System;
using UnityEngine;
namespace NonSolid
{
public enum AreaOfEffectType
{
Circle,
Line,
Rectangle,
Polygon,
Hexagon
}
public class AreaOfEffect : MonoBehaviour
{
[SerializeField] private AreaOfEffectType _areaOfEffectType;
[SerializeField] private float _radius = 10.0f; // circle
[SerializeField] private float _length = 10.0f; // line
[SerializeField] private float _width = 1.0f; // line
[SerializeField] private Rect _rect; // rectangle
private void OnCollisionEnter(Collision other)
{
float area = 0.0f;
switch (_areaOfEffectType)
{
case AreaOfEffectType.Circle:
area = Mathf.PI * _radius * _radius;
break;
case AreaOfEffectType.Line:
break;
case AreaOfEffectType.Rectangle:
break;
case AreaOfEffectType.Polygon:
break;
case AreaOfEffectType.Hexagon:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5f36882c752d4a708fcfd61ab377b21b
timeCreated: 1774973643
@@ -0,0 +1,9 @@
namespace NonSolid
{
public enum FireType
{
Bullet,
Spell,
Arrow
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e545c19b54174187a546da449a82fe4e
timeCreated: 1774971768
@@ -0,0 +1,90 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
namespace NonSolid
{
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Movement")]
[SerializeField] private float _speed = 10.0f;
[SerializeField] private float _rotationSpeed = 60.0f;
[Header("Firing")]
[SerializeField] private Transform _shootSpawn;
[SerializeField] private Rigidbody _projectilePrefab;
[SerializeField] private float _shootForce = 10.0f;
[SerializeField] private FireType _fireType = FireType.Bullet;
[Header("Inputs")]
[SerializeField] private InputActionReference _movementInputAction;
[SerializeField] private InputActionReference _rotationInputAction;
[SerializeField] private InputActionReference _fireInputAction;
private CharacterController _characterController;
private Vector2 _movement;
private Vector2 _rotation;
private void Awake()
{
_characterController = GetComponent<CharacterController>();
}
private void OnEnable()
{
_movementInputAction.action.Enable();
_rotationInputAction.action.Enable();
_fireInputAction.action.Enable();
_fireInputAction.action.performed += OnFireActionPerformed;
}
private void OnDisable()
{
_movementInputAction.action.Disable();
_rotationInputAction.action.Disable();
_fireInputAction.action.Disable();
_fireInputAction.action.performed -= OnFireActionPerformed;
}
private void Update()
{
HandleInput();
MoveAndRotate();
}
private void HandleInput()
{
_movement = _movementInputAction.action.ReadValue<Vector2>();
_rotation = _rotationInputAction.action.ReadValue<Vector2>();
}
private void MoveAndRotate()
{
transform.Rotate(0, _rotation.x * _rotationSpeed * Time.deltaTime, 0);
_characterController.Move(new Vector3(_movement.x, 0, _movement.y) * (_speed * Time.deltaTime));
}
private void Fire()
{
switch (_fireType)
{
case FireType.Bullet:
Rigidbody projectile = Instantiate(_projectilePrefab, _shootSpawn.position, _shootSpawn.rotation);
projectile.AddForce(_shootSpawn.forward * _shootForce, ForceMode.Impulse);
break;
case FireType.Spell:
break;
case FireType.Arrow:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private void OnFireActionPerformed(InputAction.CallbackContext ctx)
{
Fire();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a36a3c6df048464da7de1ecc52f7102f
timeCreated: 1774966133