add unity project
add SOLID examples
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace.NonSolid
|
||||
{
|
||||
public class AreaOfEffect : MonoBehaviour
|
||||
{
|
||||
public enum AreaOfEffectType
|
||||
{
|
||||
Circle,
|
||||
Rectangle,
|
||||
Pentagon,
|
||||
Hexagon,
|
||||
}
|
||||
|
||||
[SerializeField] private AreaOfEffectType _areaOfEffectType;
|
||||
[SerializeField] private float _radius;
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
float area = 0.0f;
|
||||
|
||||
switch (_areaOfEffectType)
|
||||
{
|
||||
case AreaOfEffectType.Circle:
|
||||
area = Mathf.Pow(_radius, 2.0f) * Mathf.PI;
|
||||
break;
|
||||
case AreaOfEffectType.Rectangle:
|
||||
break;
|
||||
case AreaOfEffectType.Pentagon:
|
||||
break;
|
||||
case AreaOfEffectType.Hexagon:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user