parent
fc67a8927c
commit
d7144a20b2
|
|
@ -295,6 +295,7 @@ public class Game_Mini : MonoBehaviour
|
|||
StartCoroutine(Co_Shiled());
|
||||
break;
|
||||
case eMiniGameObtacleType.ItemDildo:
|
||||
list_MiniGameObtacle.ForEach(f => f.Change_Item(dic_weight));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,38 @@ public class MiniGameObtacle : MonoBehaviour
|
|||
var x = (Screen.width >> 1) - 50;
|
||||
m_RectTransform.anchoredPosition = new Vector2(Random.Range(-x, x), 0f);
|
||||
|
||||
Set_Item();
|
||||
i_img.transform.eulerAngles = Vector3.zero;
|
||||
|
||||
void SetRandomTypeByWeight(Dictionary<eMiniGameObtacleType, int> dic_weight)
|
||||
{
|
||||
// 총합
|
||||
int totalWeight = dic_weight.Values.Sum();
|
||||
if (totalWeight <= 0)
|
||||
{
|
||||
Debug.LogWarning("가중치 총합이 0 이하입니다. 기본값으로 White 선택.");
|
||||
m_Type = eMiniGameObtacleType.White;
|
||||
return;
|
||||
}
|
||||
|
||||
// 랜덤 뽑기
|
||||
int rand = Random.Range(0, totalWeight);
|
||||
int cumulative = 0;
|
||||
|
||||
foreach (var pair in dic_weight)
|
||||
{
|
||||
cumulative += pair.Value;
|
||||
if (rand < cumulative)
|
||||
{
|
||||
m_Type = pair.Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Set_Item()
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case eMiniGameObtacleType.White:
|
||||
|
|
@ -66,40 +98,62 @@ public class MiniGameObtacle : MonoBehaviour
|
|||
m_Dmg = 1;
|
||||
break;
|
||||
}
|
||||
m_Dmg.Obfuscate();
|
||||
i_img.SetNativeSize();
|
||||
if (m_Type == eMiniGameObtacleType.AlbumOpen || m_Type == eMiniGameObtacleType.ChatCoin ||
|
||||
m_Type == eMiniGameObtacleType.GachaCoin)
|
||||
i_img.transform.localScale = Vector3.one * 0.5f;
|
||||
else
|
||||
i_img.transform.localScale = Vector3.one;
|
||||
i_img.transform.eulerAngles = Vector3.zero;
|
||||
m_Dmg.Obfuscate();
|
||||
|
||||
void SetRandomTypeByWeight(Dictionary<eMiniGameObtacleType, int> dic_weight)
|
||||
{
|
||||
// 총합
|
||||
int totalWeight = dic_weight.Values.Sum();
|
||||
if (totalWeight <= 0)
|
||||
{
|
||||
Debug.LogWarning("가중치 총합이 0 이하입니다. 기본값으로 White 선택.");
|
||||
m_Type = eMiniGameObtacleType.White;
|
||||
return;
|
||||
}
|
||||
|
||||
// 랜덤 뽑기
|
||||
int rand = Random.Range(0, totalWeight);
|
||||
int cumulative = 0;
|
||||
|
||||
foreach (var pair in dic_weight)
|
||||
{
|
||||
cumulative += pair.Value;
|
||||
if (rand < cumulative)
|
||||
{
|
||||
m_Type = pair.Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Change_Item(Dictionary<eMiniGameObtacleType, int> dic_weight)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case eMiniGameObtacleType.White:
|
||||
case eMiniGameObtacleType.Red:
|
||||
case eMiniGameObtacleType.HpHeal:
|
||||
case eMiniGameObtacleType.ItemBomb:
|
||||
case eMiniGameObtacleType.ItemUmbrella:
|
||||
case eMiniGameObtacleType.ItemDildo:
|
||||
{
|
||||
// 후보 아이템 리스트
|
||||
var candidates = new List<eMiniGameObtacleType>
|
||||
{
|
||||
eMiniGameObtacleType.AlbumOpen,
|
||||
eMiniGameObtacleType.ChatCoin,
|
||||
eMiniGameObtacleType.GachaCoin
|
||||
};
|
||||
|
||||
// 총 가중치 합
|
||||
int totalWeight = 0;
|
||||
foreach (var c in candidates)
|
||||
{
|
||||
if (dic_weight.TryGetValue(c, out int w))
|
||||
totalWeight += w;
|
||||
}
|
||||
|
||||
if (totalWeight <= 0) return; // 가중치가 전혀 없으면 리턴
|
||||
|
||||
// 랜덤 값
|
||||
int rand = Random.Range(0, totalWeight);
|
||||
|
||||
// 가중치 누적하면서 선택
|
||||
foreach (var c in candidates)
|
||||
{
|
||||
if (!dic_weight.TryGetValue(c, out int w)) continue;
|
||||
if (rand < w)
|
||||
{
|
||||
m_Type = c; // 선택된 아이템으로 교체
|
||||
break;
|
||||
}
|
||||
rand -= w;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Set_Item();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
사운드 및 BGM 요청
|
||||
|
||||
미니게임 만들기
|
||||
- 아이템 기능 구현
|
||||
광고 제거권
|
||||
훔쳐보기
|
||||
프로필 카드
|
||||
Loading…
Reference in New Issue