diff --git a/Assets/Scripts/Etc/Constants.cs b/Assets/Scripts/Etc/Constants.cs index ea5e389..5de3673 100644 --- a/Assets/Scripts/Etc/Constants.cs +++ b/Assets/Scripts/Etc/Constants.cs @@ -5,4 +5,11 @@ using UnityEngine; public static class Constants { public static readonly float PLAY_TIME = 60; + + //TODO : ¸¶¿ì½º °¨µµ Á¶Àý µî¿¡ º¯°æ °¡´ÉÇÑÁö È®ÀÎ ÇÊ¿ä + public static readonly float CAM_TURN_SPEED = 40; + + //TODO : ij¸¯ÅÍ µ¥ÀÌÅÍ ¿Ï·áµÇ¸é µ¥ÀÌÅÍ °ªÀ¸·Î »ç¿ëÇؾßÇÔ + public static readonly float MOVE_SPEED = 3; + public static readonly float JUMP_FORCE = 3f; } diff --git a/Assets/Scripts/Stage/Controller/PropController.cs b/Assets/Scripts/Stage/Controller/PropController.cs index ed750f9..826f57f 100644 --- a/Assets/Scripts/Stage/Controller/PropController.cs +++ b/Assets/Scripts/Stage/Controller/PropController.cs @@ -1,3 +1,4 @@ +using FirstVillain.EventBus; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -7,6 +8,8 @@ public class PropController : MonoBehaviour //»ý¼º ½Ã FX private E_TEAM _hitTeam = E_TEAM.None; + private CharacterController _controller; + private Rigidbody _rigidBody; private void Start() { @@ -37,6 +40,7 @@ public class PropController : MonoBehaviour { //StageManager¿¡ ÆÀ º¸³»¼­ Á¡¼ö ȹµæ ¿äû Debug.Log("Á¡¼ö ȹµæ"); + EventBus.Instance.Publish(new EventPropRemoved()); AddressableManager.Instance.Release(gameObject); //Á¦°Å } diff --git a/Assets/Scripts/Stage/Controller/SpawnController.cs b/Assets/Scripts/Stage/Controller/SpawnController.cs index bc1cbfe..9ffbb38 100644 --- a/Assets/Scripts/Stage/Controller/SpawnController.cs +++ b/Assets/Scripts/Stage/Controller/SpawnController.cs @@ -1,3 +1,4 @@ +using FirstVillain.EventBus; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -6,7 +7,20 @@ public class SpawnController : MonoBehaviour { [SerializeField] private List _itemSpawnPosList; [SerializeField] private Transform _playerSpawnPos; + [SerializeField] private List _propGenerateArea; + private int _maxPropCount = 50; + private int _curPropCount = 0; + + private void Start() + { + EventBus.Instance.Subscribe(OnPropRemoved); + } + + private void OnDestroy() + { + EventBus.Instance.Unsubscribe(OnPropRemoved); + } //ÃÖÃÊ Ç÷¹À̾î ÇÁ¸®ÆÕ ·Îµå ¹× »ý¼º public PlayerController SpawnPlayer() { @@ -23,6 +37,45 @@ public class SpawnController : MonoBehaviour player.transform.position = _playerSpawnPos.position; player.transform.rotation = _playerSpawnPos.rotation; } + + //ŸÀÔº°·Î ¸¸µé¾î¾ß ÇÒ±î..? + public void SpawnProp() + { + StartCoroutine(StartSpawnProps()); + } + + private IEnumerator StartSpawnProps() + { + //TODO : °ÔÀÓ Ç÷¹ÀÌ ÁßÀ¸·Î º¯°æÇÊ¿ä + while(true) + { + yield return new WaitForSeconds(1f); + if (_curPropCount < _maxPropCount) + { + AddressableManager.Instance.Spawn("Crate_01", null, OnSpawnedProp); + _curPropCount++; + } + } + + yield break; + } + + public void OnSpawnedProp(GameObject obj) + { + int rnd = Random.Range(0, _propGenerateArea.Count); + var bound = _propGenerateArea[rnd]; + var randomPos = new Vector3( + Random.Range(bound.min.x, bound.max.y), + Random.Range(bound.min.y, bound.max.z), + Random.Range(bound.min.z, bound.max.z)); + + obj.transform.position = randomPos; + } + + private void OnPropRemoved(EventPropRemoved e) + { + _curPropCount--; + } //ij¸¯ÅÍ ³«ÇÏ ½Ã Àç»ý¼º diff --git a/Assets/Scripts/Stage/Events/StageEvents.cs b/Assets/Scripts/Stage/Events/StageEvents.cs index 2b74170..9f50680 100644 --- a/Assets/Scripts/Stage/Events/StageEvents.cs +++ b/Assets/Scripts/Stage/Events/StageEvents.cs @@ -14,3 +14,8 @@ public class EventSendMinigamePoint : EventBase MinigamePoint = point; } } + +public class EventPropRemoved : EventBase +{ + +} \ No newline at end of file diff --git a/Assets/Scripts/Stage/Manage/StageManager.cs b/Assets/Scripts/Stage/Manage/StageManager.cs index d0b724b..b143eb9 100644 --- a/Assets/Scripts/Stage/Manage/StageManager.cs +++ b/Assets/Scripts/Stage/Manage/StageManager.cs @@ -13,30 +13,22 @@ public class StageManager : UnitySingletonOnce private PlayerController _currentPlayer; private Dictionary _teamScoreDict = new(); - //1. ¹°Ã¼¸¦ ¸Ê¿¡ ¹Ì¸® »ý¼ºÇÑ´Ù. - //2. ¹°Ã¼¸¦ ÀüºÎ ¸®½ºÆ®¿¡ ³Ö¾î³õ°í ´Ù ¾ø¾îÁú °æ¿ì °ÔÀÓ Á¾·á - //3. ŸÀÌ¸Ó Á¸Àç(5ºÐ) - ŸÀÌ¸Ó Á¾·á ½Ã °ÔÀÓ Á¾·á - //4. °ÔÀÓ Á¾·á ½Ã ´Ù ¾ø¾Ø ½Ã°£(±â·Ï), ¶³±º ¹°Ã¼ °³¼ö Ç¥±â(x Á¡¼ö), - //5. ÃÑ Á¡¼ö¿¡ µû¶ó ÄÚÀΠȹµæ - private void Start() { - AddressableManager.Instance.Spawn("Crate_02", null, OnCompleteLoad); + //AddressableManager.Instance.Spawn("Crate_02", null, OnCompleteLoad); + _spawnController.SpawnProp(); } public void StartGame() { StartCoroutine(PlayTimer(Constants.PLAY_TIME)); } - private void OnCompleteLoad(GameObject obj) - { - Debug.Log("»ý¼º ¿Ï·á"); - obj.name = "Test"; - } //³«ÇÏÇßÀ» ¶§ - public void PlayerFall(PlayerController controller) + public void PlayerFall(PlayerController player) { + player.gameObject.SetActive(false); + _spawnController.RespawnPlayer(player); //À½... //_spawnController.RespawnPlayer(_currentPlayer); }