Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
8 changes: 8 additions & 0 deletions Assets/1.Scripts/0_Generic.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions Assets/1.Scripts/0_Generic/GenericSingleton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
namespace MainSystem
{
using UnityEngine;

public class GenericSingleton<T> : MonoBehaviour where T : MonoBehaviour
{

private static T _Instance = null;
private static object _lock = new object();
private static bool applicationIsQuitting = false;

public static T Instance
{
get
{
if (applicationIsQuitting)
{
#if UNITY_EDITOR
Debug.LogWarning("[Singleton] Instance" + typeof(T) + "Is Already");
#endif
return null;
}

lock (_lock)
{
if (null == _Instance)
{
_Instance = (T)FindObjectOfType(typeof(T));


if (FindObjectsOfType(typeof(T)).Length > 1)
{
#if UNITY_EDITOR
Debug.LogError("[Singleton] Already Instance : ERROR more then 2");
#endif
return _Instance;
}

if (null == _Instance)
{
GameObject singleton = new GameObject();
_Instance = singleton.AddComponent<T>();
singleton.name = "(singleton)" + typeof(T).ToString();

DontDestroyOnLoad(singleton);
#if UNITY_EDITOR
Debug.Log("[Singleton] An Instance of " + typeof(T).ToString());
#endif

}
#if UNITY_EDITOR
else
{

Debug.Log("[Singleton] Using Instance Already Created: " + _Instance.gameObject.name);

}
#endif
}

return _Instance;
}
}
}

public void OnDestroy()
{
applicationIsQuitting = true;
}

public void OnDestroyInstance()
{
Destroy(_Instance);
}
}

}
11 changes: 11 additions & 0 deletions Assets/1.Scripts/0_Generic/GenericSingleton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/1.Scripts/1_System.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Assets/1.Scripts/1_System/MainSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace MainSystem
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Managers.SceneManager;
using Managers.GameManager;
using Managers.UIManager;
public partial class MainSystem : GenericSingleton<MainSystem> //Data
{
public SceneManager SceneManager { get; private set; } = default;
public GameManager GameManager { get; private set; } = default;
public UIManager UIManager { get; private set; } = default;
}
public partial class MainSystem : GenericSingleton<MainSystem> //Main
{
private void Allocate()
{
UIManager = gameObject.AddComponent<UIManager>();
SceneManager = gameObject.AddComponent<SceneManager>();
GameManager = gameObject.AddComponent<GameManager>();
}
private void Initialize()
{
Allocate();
UIManager.Initialize();
SceneManager.Initialize();
GameManager.Initialize();
}
public void Exit()
{
Application.Quit();
}
}
public partial class MainSystem : GenericSingleton<MainSystem> //Prop
{
public void MainSystemStart(System.Action receiveFuntion)
{
Initialize();
receiveFuntion?.Invoke();
}
}
}
11 changes: 11 additions & 0 deletions Assets/1.Scripts/1_System/MainSystem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/1.Scripts/1_System/MainSystemTrigger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace MainSystem
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public partial class MainSystemTrigger : MonoBehaviour //Data
{
}
public partial class MainSystemTrigger : MonoBehaviour //Main
{
private void Awake()
{
MainSystem.Instance.MainSystemStart(ReceiveFinishMainSystemStart);
}
}
public partial class MainSystemTrigger : MonoBehaviour //Prop
{
public void ReceiveFinishMainSystemStart()
{
MainSystem.Instance.SceneManager.SceneLoadStandard("LogoScene");
}
}
}
11 changes: 11 additions & 0 deletions Assets/1.Scripts/1_System/MainSystemTrigger.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/1.Scripts/2_Managers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/1.Scripts/2_Managers/GameManager.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 155 additions & 0 deletions Assets/1.Scripts/2_Managers/GameManager/Character.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public enum AnimatorParameters
{
IsAttack, IsSpecialAttack, GetHit, IsDead
}

namespace MainSystem.Managers.GameManager
{
public partial class Character : MonoBehaviour//Data
{
[SerializeField] private UnityEvent<float> giveDamageEvent;
protected int gameRound;
protected int whoseTurn;
protected bool isFinished;
[SerializeField] protected float myHp = 100f;
[SerializeField] protected float myDamage = 20f;
[SerializeField] protected UnityEvent DeadSignal;
[SerializeField] protected int myNum;
private GameManager gameManager;
[SerializeField] private UnityEvent<int> sendName;
[SerializeField] protected UnityEvent<float> sendHealth;
}
public partial class Character : MonoBehaviour //Main
{
protected virtual void Start()
{
MainSystem.Instance.GameManager.SignupCharacter(this);
Initialize();
}
private void Allocate()
{
_animator = GetComponent<Animator>();
ExtendAllocate();
}
public void Initialize()
{
Allocate();

ExtendInitialize();
}
}
public partial class Character : MonoBehaviour//Extand
{
protected virtual void ExtendAllocate()
{

}
protected virtual void ExtendInitialize()
{

}
}
public partial class Character : MonoBehaviour//Signup
{
public void SignupGameManager(GameManager gameManagerp)
{
gameManager = gameManagerp;
DeadSignal.AddListener(gameManager.ReceiveDeadSignal);
}
}
public partial class Character : MonoBehaviour
{
public void SendName()
{
sendName.Invoke(myNum);
}
public void ReceiveTureOrder(int whosTurnPra, int gameRoundPra)
{
GameInfoUpdate(whosTurnPra, gameRoundPra);
if (whosTurnPra == myNum)
{
ReceiveAttackcommand();
}
}
private void GameInfoUpdate(int whosTurnPra, int gameRoundPra)
{
whoseTurn = whosTurnPra;
gameRound = gameRoundPra;
}
protected virtual void ReceiveAttackcommand()
{

}
protected void NormalAttack()
{
AttackMotion();
GiveDamage(myDamage);
}
public virtual void ReceiveDamagecommand(float damage)
{
GetHit(damage);
}
protected void GiveDamage(float damage)
{
giveDamageEvent.Invoke(damage);
}
protected void Healing(float heal)
{
myHp += heal;
}
protected virtual void GetHit(float damage)
{
myHp -= damage;
sendHealth.Invoke(myHp);
Debug.Log($"Object Number {myNum} HP: {myHp}");
if (myHp <= 0)
{
Death();
return;
}
GetHitMotion();
}
protected void Death()
{
DeadMotion();
DeadSignal.Invoke();
}
protected Animator _animator;

protected void AttackMotion()
{
_animator.SetTrigger(AnimatorParameters.IsAttack.ToString());
}
protected void SpecialAttackMotion()
{
_animator.SetTrigger(AnimatorParameters.IsSpecialAttack.ToString());
}

protected void DeadMotion()
{
StartCoroutine(DeadCoroutine());
}

protected void GetHitMotion()
{
StartCoroutine(GetHitCoroutine());
}

IEnumerator GetHitCoroutine()
{
yield return new WaitForSeconds(1f);
_animator.SetTrigger(AnimatorParameters.GetHit.ToString());
}

IEnumerator DeadCoroutine()
{
yield return new WaitForSeconds(1f);
_animator.SetTrigger(AnimatorParameters.IsDead.ToString());
}
}

}
Loading