Skip to content

Commit

Permalink
Merge pull request #800 from GG-Studio-990001/778-ch2-접속-게임-슈퍼-아리오-브라…
Browse files Browse the repository at this point in the history
…더스-sw

[CH2] 접속 게임 - 슈퍼 아리오 브라더스 (4)
  • Loading branch information
NearthYou authored Dec 2, 2024
2 parents 9a3e777 + 5d07403 commit 6c6242b
Show file tree
Hide file tree
Showing 24 changed files with 5,680 additions and 1,022 deletions.
2,062 changes: 1,140 additions & 922 deletions Assets/Scenes/SuperArio.unity

Large diffs are not rendered by default.

48 changes: 26 additions & 22 deletions Assets/Scripts/Runtime/CH2/SuperArio/Ario.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Runtime.ETC;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.InputSystem;
Expand All @@ -13,13 +14,13 @@ public class Ario : MonoBehaviour

private bool _isJump;
private bool _isTop;
private bool _isPause;

private Vector2 _startPos;
private CapsuleCollider2D _col;
private Animator _animator;
private SpriteRenderer _spr;
private Sprite _initSprite;
private GameObject _pipe;

private int _life = 1;
private bool _isInvincible = false; // 무적 상태 여부
Expand All @@ -29,12 +30,18 @@ public class Ario : MonoBehaviour

private void Start()
{
_pipe = transform.GetChild(0).gameObject;
_spr = GetComponent<SpriteRenderer>();
_col = GetComponent<CapsuleCollider2D>();
_animator = GetComponent<Animator>();
_initSprite = _spr.sprite;
_startPos = transform.position;
ArioManager.instance.onPlay += InitData;
ArioManager.instance.OnPlay += InitData;
}

private void OnDestroy()
{
ArioManager.instance.OnPlay -= InitData;
}

private void FixedUpdate()
Expand Down Expand Up @@ -70,7 +77,8 @@ private void FixedUpdate()

public void OnMove(InputAction.CallbackContext context)
{
if (!ArioManager.instance.isPlay || _isPause) return;
if (!ArioManager.instance.isPlay || ArioManager.instance.isPause)
return;

Vector2 moveInput = context.ReadValue<Vector2>();

Expand Down Expand Up @@ -99,39 +107,35 @@ public void OnMove(InputAction.CallbackContext context)

private void InitData(bool isPlay)
{
transform.position = _startPos;
_isJump = false;
_isTop = false;
if (isPlay)
{
transform.position = _startPos;
_isJump = false;
_isTop = false;
_life = 1;
_animator.enabled = true;
_pipe.SetActive(false);
}
else
{
_life = 1;
_animator.enabled = false;
_isJump = false;
_pipe.SetActive(true);
}
}

public void PauseKeyInput()
{
_isPause = !_isPause;
}

private IEnumerator UseItemCoroutine()
{
_invincibleDuration = 20f;
_isInvincible = true; // 무적 상태 활성화
_originalColor = _spr.color; // 원래 색상 저장
_isInvincible = true;
_originalColor = _spr.color;

float elapsedTime = 0f;

while (elapsedTime < _invincibleDuration)
{
// 무지개 색상을 계산
float hue = (elapsedTime % 1f) / 1f; // 0~1 사이의 값을 사용
_spr.color = Color.HSVToRGB(hue, 1f, 1f); // HSV로 색상 변경
float hue = (elapsedTime % 1f) / 1f;
_spr.color = Color.HSVToRGB(hue, 1f, 1f);

elapsedTime += Time.deltaTime;
yield return null;
Expand All @@ -144,9 +148,10 @@ private IEnumerator UseItemCoroutine()

public void UseInvincibleItem()
{
if (_isInvincible && !ArioManager.instance.GetItem) return; // 이미 무적 상태라면 무시

ArioManager.instance.ChangeItemSprite(true);
if (_isInvincible || !ArioManager.instance.GetItem || !ArioManager.instance.isPlay)
return;

ArioManager.instance.ChangeItemSprite();
StartCoroutine(UseItemCoroutine());
}

Expand All @@ -166,9 +171,8 @@ private IEnumerator InvincibilityCoroutine()
yield return new WaitForSeconds(_blinkInterval);
}

// 깜빡임 종료 후 원래 상태로 복구
_spr.enabled = true;
_isInvincible = false; // 무적 상태 종료
_isInvincible = false;
}

private void OnTriggerEnter2D(Collider2D other)
Expand Down
15 changes: 15 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioCoin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using UnityEngine;

public class ArioCoin : MonoBehaviour
{
private System.Random random = new System.Random();

public void RandomCoin()
{
// random 객체를 사용하여 값을 추출
if (random.Next(0, 100) <= 10)
{
gameObject.SetActive(true);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioCoin.cs.meta

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

47 changes: 34 additions & 13 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Cinemachine;
using System;
using System.Collections;
using UnityEngine;

Expand All @@ -19,18 +21,21 @@ private void Awake()

instance = this;
}

#endregion

public delegate void OnPlay(bool isPlay);
public OnPlay onPlay;
public Action<bool> OnPlay;
public Action<bool> OnEnterStore;

[SerializeField] private ArioUIController ui; // UI 컨트롤러
[SerializeField] private ObstacleManager obstacleManager; // 장애물 매니저
[SerializeField] private ObstacleSpawnDataSet dataSet; // ScriptableObject 데이터셋

[SerializeField] private CinemachineVirtualCamera stageCamera;
[SerializeField] private CinemachineVirtualCamera storeCamera;


public float gameSpeed = 1; // 현재 게임 속도
public bool isPlay;
public bool isPause = true;

private int _coinCnt;
public string _currentStage = "1-1"; // 초기 스테이지 설정
Expand All @@ -44,10 +49,19 @@ private void Start()

public void RestartSuperArio()
{
storeCamera.Priority = 10;
if (!isPlay)
StartGame();
}

public void EnterStore()
{
// 카메라 변경
storeCamera.Priority = 12;
OnEnterStore.Invoke(true);
// 입장 연출
}

private IEnumerator WaitStart()
{
yield return new WaitForSeconds(0.5f);
Expand All @@ -58,20 +72,22 @@ private void StartGame()
{
ui.ChangeCoinText("RAPLEY\n" + _coinCnt);
ui.ActiveRestartText(false);
ui.ChangeItemSprite(false);
ui.ChangeObstacleText(0);
ChangeHeartUI(1);
isPlay = true;
isPause = false;
GetItem = true;
onPlay.Invoke(isPlay);
OnPlay.Invoke(isPlay);
UpdateStage(_currentStage);
}

private void GameOver()
{
ui.ChangeObstacleText(0);
UpdateStage(_currentStage);
ui.ActiveRestartText(true);
isPlay = false;
onPlay.Invoke(isPlay);
OnPlay.Invoke(isPlay);
}

public void ChangeHeartUI(int life)
Expand All @@ -87,11 +103,16 @@ public void GetCoin()
ui.ChangeCoinText("RAPLEY\n" + _coinCnt);
}

public void ChangeItemSprite(bool isUse)
public void ChangeItemSprite()
{
GetItem = false;
ui.ChangeItemSprite();
}

public void GetItemSprite()
{
if (isUse)
GetItem = false;
ui.ChangeItemSprite(isUse);
GetItem = true;
ui.GetItemSprite();
}

public void ChangeObstacleCnt(int count)
Expand Down Expand Up @@ -128,15 +149,15 @@ public void NextStage(string nextStage)
{
UpdateStage(nextStage); // 일반 스테이지 업데이트
isPlay = true;
onPlay.Invoke(isPlay);
OnPlay.Invoke(isPlay);
}
}

private void EnterRewardRoom()
{
// 보상 방으로 이동하는 로직
isPlay = false;
onPlay.Invoke(isPlay); // 게임 상태 정지
OnPlay.Invoke(isPlay); // 게임 상태 정지
}

public string CalculateNextStage(string currentStage)
Expand Down
56 changes: 56 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioStarUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;

public class ArioStarUI : MonoBehaviour
{
[SerializeField] private TMP_Text _count;
private Image _image;
private Color _originalColor;

private void Start()
{
_image = GetComponent<Image>();
_count.gameObject.SetActive(false);
_originalColor = _image.color;
}

public void StartCount()
{
_count.gameObject.SetActive(true);
StartCoroutine(ItemCount());
SetImageColorGray();
}

private IEnumerator ItemCount()
{
int num = 20;

while (num >= 0)
{
_count.text = num.ToString();
yield return new WaitForSeconds(1f);
num--;
}
_count.gameObject.SetActive(false);
}

private void SetImageColorGray()
{
if (_image != null)
{
_image.color = Color.gray; // 회색으로 설정
}
}

public void ResetImageColor()
{
if (_image != null)
{
_image.color = _originalColor; // 원래 색상으로 복구
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioStarUI.cs.meta

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

25 changes: 25 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Runtime.CH2.SuperArio;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ArioStore : MonoBehaviour
{
[SerializeField] private GameObject _ario;

private void Start()
{
ArioManager.instance.OnEnterStore += EnterStore;
}

private void OnDestroy()
{
ArioManager.instance.OnEnterStore -= EnterStore;
}

public void EnterStore(bool isTrue)
{
_ario.SetActive(true);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Runtime/CH2/SuperArio/ArioStore.cs.meta

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

Loading

0 comments on commit 6c6242b

Please sign in to comment.