728x90

1. 개발 현황

1. 원거리 폭발형 무기 구현 완료

2. 게임 시작 & 종료 HUD 및 제어로직 추가 완료

3. 업적 시스템 구현 완료

2. 금일 개발 내용

1. 거미줄 무기 추가

1) 스프라이트 추가 (Atlas Sprite)

- 스프라이트 자료 경로: https://www.klipartz.com/ko/sticker-png-bxswr

2) 투사체 크기 제어 로직 추가

    void FireWeb()
    {
        if (!GameManager.instance.mPlayer.mScanner.mNearestTarget)
            return;

        Vector3 targetPos = GameManager.instance.mPlayer.mScanner.mNearestTarget.position;
        Vector3 rootDir = targetPos - GameManager.instance.mPlayer.transform.position;
        rootDir = rootDir.normalized;

        // 방사형 공격 로직
        for (int i = 0; i < GameManager.instance.mWeaponLastData[mId].Projectile; ++i)
        {
            Vector3 dir = rootDir;
            if (GameManager.instance.mWeaponLastData[mId].Projectile != 1)
            {
                float rot = 30 * (i / ((float)GameManager.instance.mWeaponLastData[mId].Projectile - 1)) - 15;
                dir = Quaternion.Euler(0, 0, rot) * dir;
            }

            Transform bullet = mWeaponPool.Get().transform;
            bullet.parent = mWeaponPool.transform;
            bullet.position = GameManager.instance.mPlayer.transform.position;
            bullet.rotation = Quaternion.FromToRotation(Vector3.up, dir);
            bullet.localScale = new Vector3(0.02f, 0.4f, 1f); // 투사체 크기 제어
            bullet.GetComponent<Range>().Init(Mathf.RoundToInt(GameManager.instance.mWeaponLastData[mId].Damage), GameManager.instance.mWeaponLastData[mId].Pierce, dir, GameManager.instance.mWeaponLastData[mId].Speed); // -1 is Infinity Per
        }
    }

3) 디버프 로직 추가

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Garlic"))
        {
            mIsGarlic = true;
            mGarlicDamage = collision.GetComponent<Melee>().mDamage;
            return;
        }
        if (collision.CompareTag("SpiderWeb"))
        {
            mMovementSpeedCoef *= 0.5f;
            collision.GetComponent<Range>().transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); // 투사체 범위 제어
            collision.GetComponent<Range>().mSpeed = 0f;
        }
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Garlic"))
            mIsGarlic = false;
        if (collision.CompareTag("SpiderWeb"))
            mMovementSpeedCoef = 2f;
    }

2. 게임 시작 및 종료 HUD 추가

1-1) 캐릭터 선택 HUD 제작

1-2) HUD 자동생성 로직 추가

- RootHUD 기반, 캐릭터 선택 버튼 복제

public class HUDGameStart : MonoBehaviour
{
    RectTransform mRect;
    public GameObject mRootHUD;
    GameObject[] mPlayers;
    void Awake()
    {
        mRect = GetComponent<RectTransform>();
        mPlayers = new GameObject[GameManager.instance.mPlayerJsonData.Length];
        mPlayers[0] = mRootHUD;
        mPlayers[0].GetComponent<HUDBtnPlayer>().mId = 0;
        mPlayers[0].GetComponent<HUDBtnPlayer>().Init();
        for (int i = 1; i < mPlayers.Length; ++i)
        {
            mPlayers[i] = Instantiate(mRootHUD);
            mPlayers[i].transform.SetParent(mRootHUD.transform.parent);
            mPlayers[i].transform.name = "Character " + i;
            mPlayers[i].transform.localScale = mRootHUD.transform.localScale;
            mPlayers[i].GetComponent<HUDBtnPlayer>().mId = i;
            mPlayers[i].GetComponent<HUDBtnPlayer>().Init();
            mPlayers[i].GetComponent<Button>().interactable = true;
            if (!GameManager.instance.mPlayerJsonData[i].Enable)
                mPlayers[i].GetComponent<Button>().interactable = false;
        }    
    }
}

- 텍스트 및 스프라이트 초기화

- 버튼 클릭 시 게임 시작

public class HUDBtnPlayer : MonoBehaviour
{
    public int mId;

    Image mImgBackground;
    Image mImgChar;
    TMP_Text mTextName;
    TMP_Text mTextDesc;

    private void Awake()
    {
        Image[] imgs = GetComponentsInChildren<Image>();
        TMP_Text[] texts = GetComponentsInChildren<TMP_Text>();

        mImgBackground = imgs[0];
        mImgChar = imgs[1];
        mTextName = texts[0];
        mTextDesc = texts[1];
    }
    public void Init()
    {
        mImgChar.sprite = GameManager.instance.mPlayerSprite[mId];
        mTextName.text = GameManager.instance.mPlayerJsonData[mId].Name;
        mTextDesc.text = GameManager.instance.mPlayerJsonData[mId].Desc;
        if (!GameManager.instance.mPlayerJsonData[mId].Enable)
        {
            mTextName.text = "Unlocked";
            mTextDesc.text = GameManager.instance.mPlayerJsonData[mId].UnlockDesc;
            mImgBackground.color = new Color(150, 150, 150);
            mImgChar.color = new Color(0, 0, 0);
        }
    }

    public void OnClick()
    {
        GameManager.instance.GameStart(mId);
    }
}

2-1) 게임 종료 HUD 추가

2-2) HUD 관리 로직 추가

public class HUDResult : MonoBehaviour
{
    public GameObject[] mTitle;
    public void Lose()
    {
        mTitle[0].SetActive(true);
        mTitle[1].SetActive(false);
    }
    public void Win()
    {
        mTitle[0].SetActive(false);
        mTitle[1].SetActive(true);
    }
}
public class GameManager : MonoBehaviour
{
    public static GameManager instance;
    // 생략
    public HUDResult mHUDResult;
    public WaitForSeconds mWait0_5s;
    
    IEnumerator GameOverRoutine()
    {
        mIsLive = false;
        yield return mWait0_5s;
        mHUDResult.Lose();
        mHUDResult.gameObject.SetActive(true);
        Stop();
    }
    IEnumerator GameVictoryRoutine()
    {
        mIsLive = false;
        for (int i = 0; i < mEnemyPool.mPool.Count; ++i)
            mEnemyPool.mPool[i].SetActive(false);
        yield return mWait0_5s;
        mHUDResult.Win();
        mHUDResult.gameObject.SetActive(true);
        Stop();
    }
    public void GameOver()
    {
        StartCoroutine(GameOverRoutine());
    }
    public void GameVictory()
    {
        StartCoroutine(GameVictoryRoutine());
    }
}

 

3. 업적 시스템 추가

1) HUD 추가

2) HUD 자동화 시스템

    public void InitAchive()
    {
        PlayerPrefs.SetInt("MyData", 1);

        for (int i = 0; i < mAchiveJsonData.Length; ++i)
        {
            PlayerPrefs.SetInt(mAchiveJsonData[i].Name.ToString(), 0);
        }
    }
    void CheckAchive()
    {
        for (int i= 0; i< mAchiveJsonData.Length; ++i)
        {
            bool isAchive = false;
            switch (mAchiveJsonData[i].Name)
            {
                case Enum.Achive.UnlockChar2:
                    if (mPlayerData.Kill >= 1) isAchive = true;
                    break;
                case Enum.Achive.UnlockChar3:
                    if (mPlayerData.GameTime >= 300) isAchive = true;
                    break;
                default:
                    Debug.Assert(false, "Error");
                    break;
            }
            if (isAchive && PlayerPrefs.GetInt(mAchiveJsonData[i].Name.ToString()) == 0)
            {
                PlayerPrefs.SetInt(mAchiveJsonData[i].Name.ToString(), 1);
                StartCoroutine(NoticeRoutine(i));
            }
        }
    }
    
    IEnumerator NoticeRoutine(int i)
    {
        mHUDAchive.gameObject.SetActive(true);
        mHUDAchive.mIcon.sprite = mAchiveSprite[mAchiveJsonData[i].SpriteId];
        mHUDAchive.mText.text = mAchiveJsonData[i].Desc;
        yield return mWait5s;
        mHUDAchive.gameObject.SetActive(false);
    }
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class HUDAchive : MonoBehaviour
{
    public Image mIcon;
    public TMP_Text mText;

    private void Awake()
    {
        mIcon = GetComponentsInChildren<Image>()[1];
        mText = GetComponentsInChildren<TMP_Text>()[0];
    }
}

 

3. TODO

1. 골드 및 경험치 드롭 구현

2. 필드 장애물 구현

3. 필드 드롭 아이템 구현

4. 필드 이벤트 구현

5. 이펙트 구현

6. 사운드 구현

+ Recent posts