반응형
LevelManager.cs
public List<Character> Players { get; protected set; }
//...
/// <summary>
/// Kills the player.
/// </summary>
public virtual void PlayerDead(Character playerCharacter)
{
if (Players.Count < 2)
{
StartCoroutine (PlayerDeadCo ());
}
}
/// <summary>
/// Triggers the death screen display after a short delay
/// </summary>
/// <returns></returns>
protected virtual IEnumerator PlayerDeadCo()
{
yield return new WaitForSeconds(DelayBeforeDeathScreen);
GUIManager.Instance.SetDeathScreen(true);
}
/// <summary>
/// Initiates the respawn
/// </summary>
protected virtual void Respawn()
{
if (Players.Count < 2)
{
StartCoroutine(SoloModeRestart());
}
}
Players.Count
Canvas 처리
Singleton인 GUIManager에서 처리
Example (GameOver)
public void SetGameOver()
{
TopDownEngineEvent.Trigger(TopDownEngineEventTypes.GameOver, null);
GUIManager.Instance.SetDeathScreen(true);
}
GUIManager.cs
public virtual void SetDeathScreen(bool state)
{
if (DeathScreen != null)
{
DeathScreen.SetActive(state);
EventSystem.current.sendNavigationEvents = state;
}
}
GameManger.cs
public enum TopDownEngineEventTypes
{
SpawnCharacterStarts,
LevelStart,
LevelComplete,
LevelEnd,
Pause,
UnPause,
PlayerDeath,
SpawnComplete,
RespawnStarted,
RespawnComplete,
StarPicked,
GameOver,
CharacterSwap,
CharacterSwitch,
Repaint,
TogglePause,
LoadNextScene
}
public class GameManager :
MMPersistentSingleton<GameManager>,
MMEventListener<MMGameEvent>,
MMEventListener<TopDownEngineEvent>,
MMEventListener<TopDownEnginePointEvent>
{
// ...
인벤토리 Cnavas 열리는 부분
public virtual void OpenInventory()
{
if (CloseList.Count > 0)
{
foreach (string playerID in CloseList)
{
MMInventoryEvent.Trigger(MMInventoryEventType.InventoryCloseRequest, null, "", null, 0, 0, playerID);
}
}
// we set the game to pause
_pause = true;
if (_canvasGroup != null)
{
_canvasGroup.blocksRaycasts = true;
}
// we open our inventory
MMInventoryEvent.Trigger(MMInventoryEventType.InventoryOpens, null, TargetInventoryDisplay.TargetInventoryName, TargetInventoryDisplay.TargetInventory.Content[0], 0, 0, TargetInventoryDisplay.PlayerID);
MMGameEvent.Trigger("inventoryOpens");
InventoryIsOpen = true;
StartCoroutine(MMFade.FadeCanvasGroup(TargetInventoryContainer, 0.2f, 1f));
StartCoroutine(MMFade.FadeCanvasGroup(Overlay, 0.2f, 0.85f));
}
반응형
'Unity > TopdownEngine' 카테고리의 다른 글
MMEvent 동작 원리 (0) | 2023.01.29 |
---|---|
데미지 숫자 표시 (0) | 2023.01.28 |
특정 Ability On/Off 하기 (0) | 2023.01.28 |
Weapon 발사 시 뒤로 밀려나는 반동(recoil) (0) | 2023.01.28 |
주인공 초기 시작 Weapon(Item) (0) | 2023.01.28 |