2025-09-14 05:09:31 +00:00
|
|
|
using GUPS.AntiCheat.Protected;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
2025-09-15 00:52:36 +00:00
|
|
|
public enum eMiniGameObtacleType { White, Red, HpHeal, AlbumOpen, ChatCoin, GachaCoin, ItemBomb, ItemUmbrella, ItemDildo }
|
2025-09-14 05:09:31 +00:00
|
|
|
|
|
|
|
|
public class MiniGameObtacle : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public RectTransform m_RectTransform;
|
|
|
|
|
public Rigidbody2D m_Rigidbody2D;
|
|
|
|
|
public Image i_img;
|
|
|
|
|
|
|
|
|
|
eMiniGameObtacleType m_Type;
|
|
|
|
|
ProtectedInt32 m_Dmg;
|
|
|
|
|
|
|
|
|
|
public void Set(Dictionary<eMiniGameObtacleType, int> dic_weight)
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
|
SetRandomTypeByWeight(dic_weight);
|
|
|
|
|
m_Rigidbody2D.gravityScale = Random.Range(table_GlobalValue.Ins.Get_Float("MiniGameSpeedMin"),
|
|
|
|
|
table_GlobalValue.Ins.Get_Float("MiniGameSpeedMax"));
|
|
|
|
|
|
|
|
|
|
var x = (Screen.width >> 1) - 50;
|
|
|
|
|
m_RectTransform.anchoredPosition = new Vector2(Random.Range(-x, x), 0f);
|
|
|
|
|
|
|
|
|
|
i_img.color = Color.white;
|
|
|
|
|
switch (m_Type)
|
|
|
|
|
{
|
|
|
|
|
case eMiniGameObtacleType.White:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("whitecircle");
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_White_DMG");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.Red:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("whitecircle");
|
|
|
|
|
i_img.color = Color.red;
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_Red_DMG");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.AlbumOpen:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite(eMoney.AlbumOpen);
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_Heart_Amount");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.ChatCoin:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite(eMoney.Chat);
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_ChatCoin_Amount");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.GachaCoin:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite(eMoney.Gacha);
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_GachaCoin_Amount");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.HpHeal:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("hp");
|
2025-09-14 18:55:59 +00:00
|
|
|
m_Dmg = table_GlobalValue.Ins.Get_Int("MiniGame_Heal");
|
2025-09-14 05:09:31 +00:00
|
|
|
break;
|
2025-09-15 00:52:36 +00:00
|
|
|
case eMiniGameObtacleType.ItemBomb:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("item_bomb");
|
|
|
|
|
m_Dmg = 1;
|
|
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.ItemUmbrella:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("item_umbrella");
|
|
|
|
|
m_Dmg = 1;
|
|
|
|
|
break;
|
|
|
|
|
case eMiniGameObtacleType.ItemDildo:
|
|
|
|
|
i_img.sprite = UIAtlasMgr.Ins.Get_Sprite("item_dildo");
|
|
|
|
|
m_Dmg = 1;
|
|
|
|
|
break;
|
2025-09-14 05:09:31 +00:00
|
|
|
}
|
2025-09-15 00:52:36 +00:00
|
|
|
m_Dmg.Obfuscate();
|
2025-09-14 05:09:31 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (m_RectTransform.anchoredPosition.y < -Screen.height)
|
|
|
|
|
{
|
2025-09-14 07:05:38 +00:00
|
|
|
Off(false);
|
2025-09-14 05:09:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-14 07:05:38 +00:00
|
|
|
void Off(bool showeffect)
|
2025-09-14 05:09:31 +00:00
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
2025-09-14 07:05:38 +00:00
|
|
|
if (showeffect)
|
|
|
|
|
{
|
|
|
|
|
LobbyUI.Ins.m_Game_Mini.Show_HitEffect(m_RectTransform.position);
|
|
|
|
|
SoundInfo.Ins.Play_OneShot(eSound.s002_Bubble, 1f);
|
|
|
|
|
}
|
2025-09-14 05:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
|
{
|
|
|
|
|
if (collision.tag.Equals("Player"))
|
|
|
|
|
{
|
2025-09-14 07:05:38 +00:00
|
|
|
Off(true);
|
2025-09-14 18:34:04 +00:00
|
|
|
LobbyUI.Ins.m_Game_Mini.Hit(m_Type, m_Dmg);
|
2025-09-14 05:09:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|