일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 게임개발
- Multiplay
- DP
- 언리얼 엔진
- Security
- MLFQ
- Delegate
- 메카님
- gameplay ability system
- Race condition
- CTF
- 유니티
- photon fusion2
- stride
- Unreal Engine
- DSP
- Rr
- Replication
- unity
- ability task
- dirty cow
- animation
- gas
- 언리얼엔진
- ret2libc
- boss monster
- 운영체제
- 유스케이스
- 게임 개발
- MAC
Archives
- Today
- Total
다양한 기록
[Fortress Craft] 골드, 경험치 본문
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RewardManager : MonoBehaviour
{
public static RewardManager Instance { get; set; }
public int Gold { get; set; }
public float Exp { get; set; }
private void Awake()
{
Instance = this;
}
}
싱글톤 Reward 매니저에서 골드랑 경험치 프로퍼티로 가짐
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Agit.FortressCraft
{
public class ArrowAttackCollider : AttackCollider
{
private Arrow arrow;
private void Awake()
{
arrow = GetComponent<Arrow>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (TargetUnit == null) return;
if (collision.CompareTag(TargetUnit))
{
if (collision.TryGetComponent<BodyCollider>(out BodyCollider bodycoliider))
{
if (collision.transform.parent != null)
{
if (collision.transform.parent.TryGetComponent<NormalUnitRigidBodyMovement>(
out NormalUnitRigidBodyMovement normal))
{
Debug.Log("Hit! , " + normal.HP + ", " + Damage);
if (normal.HP - Damage * normal.Defense <= 0.0f && !normal.NoReward)
{
normal.NoReward = true;
RewardManager.Instance.Gold += normal.gold;
RewardManager.Instance.Exp += normal.exp;
}
}
}
bodycoliider.RPCSetDamage(Damage);
bodycoliider.CallDamageCheck();
arrow.Release();
}
}
}
}
}
공격할 때 유닛이나 몬스터를 죽이면 설정된 골드나 경험치를 받을 수 있음
* 몬스터는 Scriptable Object로 해당 프로퍼티 관리
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Agit.FortressCraft
{
public class GoldUI : MonoBehaviour
{
private Text moneyText;
private void Awake()
{
moneyText = GetComponentInChildren<Text>();
}
private void FixedUpdate()
{
moneyText.text = RewardManager.Instance.Gold.ToString();
}
}
}
골드 수치는 UI에 붙여서 업데이트 되도록 함
'유니티 엔진 > Fortress Craft' 카테고리의 다른 글
[Fortress Craft] Commander_Archer - 외형, 화살 나가는 방향 UI (0) | 2025.02.05 |
---|---|
[Fortess Craft] 스프레드 시트와 연결 (0) | 2025.02.05 |
[Fortress Craft] Castle 생성 UI, 가격 설정 (0) | 2025.02.05 |
[Fortress Craft] ** Network Object Pooling (Photon Fusion2, Shared Mode) ** (0) | 2025.02.05 |
[Fortress Craft] Target Setting / Attack Enabled (0) | 2025.02.05 |