1
This commit is contained in:
72
unity/Assets/Script/LotterySystem/UILottery.cs
Normal file
72
unity/Assets/Script/LotterySystem/UILottery.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum LotteryType
|
||||
{
|
||||
None,
|
||||
Hp,
|
||||
Mp,
|
||||
Attack,
|
||||
UpHp,//Ôö¼Ó»ØÑª
|
||||
UpMaxHp,//Ôö¼Ó×î´óѪÁ¿
|
||||
UpAttack,//
|
||||
|
||||
}
|
||||
public class UILottery : UIWindow
|
||||
{
|
||||
//public AvtarInfo avtar;
|
||||
public string lotterytype;
|
||||
public float lotteryvalue;
|
||||
public LotteryType LotteryTypes;
|
||||
|
||||
public CombaSystem ch;
|
||||
|
||||
public void OnClickLotteryType(string type)
|
||||
{
|
||||
|
||||
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
|
||||
|
||||
ch = GameObject.FindWithTag("Player").GetComponentInChildren<CombaSystem>();
|
||||
|
||||
Debug.Log("Lottery");
|
||||
lotterytype = type;
|
||||
if (lotterytype=="Hp")
|
||||
{
|
||||
LotteryTypes = LotteryType.Hp;
|
||||
}
|
||||
else if (lotterytype=="Mp")
|
||||
{
|
||||
LotteryTypes = LotteryType.Mp;
|
||||
}
|
||||
else if (lotterytype=="Attack")
|
||||
{
|
||||
LotteryTypes = LotteryType.Attack;
|
||||
}
|
||||
CheckLottery();
|
||||
}
|
||||
public void OnClickLotteryValue(float value)
|
||||
{
|
||||
lotteryvalue = value;
|
||||
}
|
||||
public void CheckLottery()
|
||||
{
|
||||
switch (LotteryTypes)
|
||||
{
|
||||
case LotteryType.Hp:
|
||||
ch.currentHp += lotteryvalue;
|
||||
ch.OnHit?.Invoke(ch.currentHp);
|
||||
break;
|
||||
case LotteryType.Mp:
|
||||
ch.maxHp += lotteryvalue;
|
||||
ch.OnHit?.Invoke(ch.currentHp);
|
||||
break;
|
||||
case LotteryType.Attack:
|
||||
ch.attack += lotteryvalue;
|
||||
ch.OnHit?.Invoke(ch.currentHp);
|
||||
break;
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/LotterySystem/UILottery.cs.meta
Normal file
11
unity/Assets/Script/LotterySystem/UILottery.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16fc6c7e67c4b3b49abbc04da26b2393
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
unity/Assets/Script/LotterySystem/UITip.cs
Normal file
30
unity/Assets/Script/LotterySystem/UITip.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class UITip : UIWindow
|
||||
{
|
||||
public GameObject tip;
|
||||
public int id;
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if(collision.CompareTag("Player"))
|
||||
{
|
||||
tip.SetActive(true);
|
||||
if(id==1)//Éý¼¶Npc
|
||||
{
|
||||
UIManager.Instance.Show<UILevelUp>();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit2D(Collider2D collision)
|
||||
{
|
||||
if (collision.CompareTag("Player"))
|
||||
{
|
||||
tip.SetActive(false);
|
||||
}
|
||||
}
|
||||
public int GetNpcId() => id;
|
||||
}
|
||||
11
unity/Assets/Script/LotterySystem/UITip.cs.meta
Normal file
11
unity/Assets/Script/LotterySystem/UITip.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bcae01b9558d814cb9d1b61be3342bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
unity/Assets/Script/LotterySystem/UIlottertOpen.cs
Normal file
34
unity/Assets/Script/LotterySystem/UIlottertOpen.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Manager;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIlottertOpen : MonoBehaviour
|
||||
{
|
||||
private Animator animator;
|
||||
private bool isOpen=true;
|
||||
private void Awake()
|
||||
{
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
}
|
||||
private void OnTriggerStay2D(Collider2D collision)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E)&&isOpen)
|
||||
{
|
||||
Debug.Log("Open Box");
|
||||
isOpen = false;
|
||||
animator.Play("Box");
|
||||
SoundManager.Instance.PlaySound(SoundDefine.BoxOpen);
|
||||
StartCoroutine(nameof(Open));
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit2D(Collider2D collision)
|
||||
{
|
||||
StopCoroutine(nameof(Open));
|
||||
}
|
||||
IEnumerator Open()
|
||||
{
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
UIManager.Instance.Show<UILottery>();
|
||||
}
|
||||
}
|
||||
11
unity/Assets/Script/LotterySystem/UIlottertOpen.cs.meta
Normal file
11
unity/Assets/Script/LotterySystem/UIlottertOpen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a972384b74231640877362a7e591cdf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user