Compare commits
2 Commits
f11c0ebcf4
...
91e704b971
Author | SHA1 | Date | |
---|---|---|---|
91e704b971 | |||
7226ab98e1 |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
8
TheStrongestSnail/Assets/Scripts/Racing.meta
Normal file
8
TheStrongestSnail/Assets/Scripts/Racing.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68161802736c17a4085eacbeb5ae1677
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
53
TheStrongestSnail/Assets/Scripts/Racing/BetBtn.cs
Normal file
53
TheStrongestSnail/Assets/Scripts/Racing/BetBtn.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class BetBtn : MonoBehaviour
|
||||
{
|
||||
public static BetBtn instance;
|
||||
public GameObject BetList;
|
||||
public Text BetText;
|
||||
public float BetValue;//投注的值
|
||||
public float AllBetValue;//投注总值
|
||||
public Button BetButton;//投注的按钮
|
||||
|
||||
public int BethourseNo;//马匹id
|
||||
public Button NumBtn;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
instance = this;
|
||||
BetList.SetActive(false);
|
||||
NumBtn.onClick.AddListener(OnClickNumBtn);
|
||||
BetValue = 50;//默认50
|
||||
SetBet();
|
||||
BetButton.onClick.AddListener(Bet_523);
|
||||
}
|
||||
|
||||
public void Bet_523()//下注
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnClickNumBtn()
|
||||
{
|
||||
BetList.SetActive(true);
|
||||
|
||||
}
|
||||
void SetBet()
|
||||
{
|
||||
// 获取所有的Button组件
|
||||
Button[] buttons = BetList.GetComponentsInChildren<Button>();
|
||||
|
||||
// 遍历每一个Button,添加点击事件
|
||||
foreach (Button button in buttons)
|
||||
{
|
||||
button.onClick.AddListener(() => {
|
||||
BetText.text = button.transform.GetComponentInChildren<Text>().text;
|
||||
BetValue = float.Parse(BetText.text);
|
||||
BetList.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
11
TheStrongestSnail/Assets/Scripts/Racing/BetBtn.cs.meta
Normal file
11
TheStrongestSnail/Assets/Scripts/Racing/BetBtn.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 570d7c8f2498985458356fb23ab77050
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
167
TheStrongestSnail/Assets/Scripts/Racing/RacingPanel.cs
Normal file
167
TheStrongestSnail/Assets/Scripts/Racing/RacingPanel.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RacingPanel : MonoBehaviour
|
||||
{
|
||||
//帮助
|
||||
public Button btnHelp;
|
||||
//投入蜗蛋
|
||||
public Button btnPut;
|
||||
//冠军记录
|
||||
public Button btnFirst;
|
||||
//任务
|
||||
public Button btnTask;
|
||||
//关闭
|
||||
public Button btnClose;
|
||||
|
||||
//美队
|
||||
public Button btnMei;
|
||||
//蜘蛛侠
|
||||
public Button btnPig;
|
||||
//毒液
|
||||
public Button btnDu;
|
||||
//钢铁侠
|
||||
public Button btnGang;
|
||||
//蝙蝠侠
|
||||
public Button btnBian;
|
||||
//超人
|
||||
public Button btnChao;
|
||||
//雷神
|
||||
public Button btnLei;
|
||||
//灭霸
|
||||
public Button btnMie;
|
||||
|
||||
public RectTransform imgMei;
|
||||
public RectTransform imgPig;
|
||||
public RectTransform imgDu;
|
||||
public RectTransform imgGang;
|
||||
public RectTransform imgBian;
|
||||
public RectTransform imgChao;
|
||||
public RectTransform imgLei;
|
||||
public RectTransform imgMie;
|
||||
//当前选中的图片位置
|
||||
private RectTransform nowImg;
|
||||
|
||||
public GameObject imgMeiQ;
|
||||
public GameObject imgPigQ;
|
||||
public GameObject imgDuQ;
|
||||
public GameObject imgGangQ;
|
||||
public GameObject imgBianQ;
|
||||
public GameObject imgChaoQ;
|
||||
public GameObject imgLeiQ;
|
||||
public GameObject imgMieQ;
|
||||
|
||||
public Text imgMeiT;
|
||||
public Text imgPigT;
|
||||
public Text imgDuT;
|
||||
public Text imgGangT;
|
||||
public Text imgBianT;
|
||||
public Text imgChaoT;
|
||||
public Text imgLeiT;
|
||||
public Text imgMieT;
|
||||
//当前选中蜗牛的钱
|
||||
private GameObject nowObj;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//美队
|
||||
btnMei.onClick.AddListener(() =>
|
||||
{
|
||||
//更新按钮图片上滑
|
||||
ImgUpward(imgMei, imgMeiQ);
|
||||
//当前选中的蜗牛
|
||||
BetBtn.instance.BethourseNo = 1;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgMeiT.text),BettingBtn.instance.AllBetValue,0.5f,imgMieT));
|
||||
});
|
||||
//蜘蛛侠
|
||||
btnPig.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgPig, imgPigQ);
|
||||
BetBtn.instance.BethourseNo = 2;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgPigT.text), BettingBtn.instance.AllBetValue, 0.5f, imgPigT));
|
||||
});
|
||||
//毒液
|
||||
btnDu.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgDu, imgDuQ);
|
||||
BetBtn.instance.BethourseNo = 3;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgDuT.text), BettingBtn.instance.AllBetValue, 0.5f, imgDuT));
|
||||
});
|
||||
//钢铁侠
|
||||
btnGang.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgGang, imgGangQ);
|
||||
BetBtn.instance.BethourseNo = 4;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgGangT.text), BettingBtn.instance.AllBetValue, 0.5f, imgGangT));
|
||||
});
|
||||
//蝙蝠侠
|
||||
btnBian.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgBian, imgBianQ);
|
||||
BetBtn.instance.BethourseNo = 5;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgBianT.text), BettingBtn.instance.AllBetValue, 0.5f, imgBianT));
|
||||
});
|
||||
//超人
|
||||
btnChao.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgChao, imgChaoQ);
|
||||
BetBtn.instance.BethourseNo = 6;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgChaoT.text), BettingBtn.instance.AllBetValue, 0.5f, imgChaoT));
|
||||
});
|
||||
//雷神
|
||||
btnLei.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgLei, imgLeiQ);
|
||||
BetBtn.instance.BethourseNo = 7;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgLeiT.text), BettingBtn.instance.AllBetValue, 0.5f, imgLeiT));
|
||||
});
|
||||
//灭霸
|
||||
btnMie.onClick.AddListener(() =>
|
||||
{
|
||||
ImgUpward(imgMie, imgMieQ);
|
||||
BetBtn.instance.BethourseNo = 8;
|
||||
//StartCoroutine(Tools.AnimateText(float.Parse(imgMieT.text), BettingBtn.instance.AllBetValue, 0.5f, imgMieT));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ImgUpward(RectTransform rec,GameObject obj)
|
||||
{
|
||||
//首先判断当前图片是否为空 不为空才处理
|
||||
if (nowImg!=null)
|
||||
{
|
||||
nowImg.localPosition = Vector3.zero;
|
||||
}
|
||||
//判断当前选中的游戏对象是否为空 不为空才处理
|
||||
if (nowObj!=null)
|
||||
{
|
||||
nowObj.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
//判断是否点击的是同一个按钮
|
||||
if (nowObj == obj && nowImg == rec)
|
||||
{
|
||||
nowImg = null;
|
||||
nowObj = null;
|
||||
return;
|
||||
}
|
||||
|
||||
rec.localPosition = new Vector3(0,50,0);
|
||||
obj.SetActive(true);
|
||||
|
||||
//重新赋值
|
||||
nowImg=rec;
|
||||
nowObj=obj;
|
||||
|
||||
}
|
||||
}
|
11
TheStrongestSnail/Assets/Scripts/Racing/RacingPanel.cs.meta
Normal file
11
TheStrongestSnail/Assets/Scripts/Racing/RacingPanel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a8134172bc78f94aa50f146489df901
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2200
TheStrongestSnail/Assets/prefabs/GLPrefabs/BettingBtns.prefab
Normal file
2200
TheStrongestSnail/Assets/prefabs/GLPrefabs/BettingBtns.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d863d9ca9e3509e4c9803f57ea119d01
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
2143
TheStrongestSnail/Assets/prefabs/GLPrefabs/LoadPanel.prefab
Normal file
2143
TheStrongestSnail/Assets/prefabs/GLPrefabs/LoadPanel.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b637be47d7d31847a01329c4aff9edd
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user