99 lines
2.8 KiB
C#
99 lines
2.8 KiB
C#
using Assets.MyGame.Scripts.Net.API;
|
|
using Spine.Unity;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SitPosData : MonoBehaviour
|
|
{
|
|
[Header("用户id")]
|
|
public string user;
|
|
[Header("座位id")]
|
|
public int posID;
|
|
[Header("金币")]
|
|
public TextMeshProUGUI tMP_TurretConsumeNum;
|
|
public TextMeshProUGUI tMP_GoldNum;
|
|
public long goldNum;
|
|
public long consumeGoldNum;
|
|
[Header("炮台")]
|
|
public Dictionary<string, TurretData> dic_Turrets=new Dictionary<string, TurretData>();
|
|
public List<TurretData> list_Turrets=new List<TurretData>();
|
|
public int currentTurretIndex = 0;
|
|
public string currentTurretID = "";
|
|
public TurretData currentTurret;
|
|
[Header("锁定")]
|
|
public MonsterContral monCotl_Lock;
|
|
public bool isLock=false;
|
|
public GameObject lockFX;
|
|
|
|
[Header("当前炮塔")]
|
|
public SkeletonGraphic skeletonAnimation;
|
|
public Animation old_CurrAnimation;
|
|
public Transform tra_CurrTurret;
|
|
public Transform tra_CurrFly; //星际迷航特有
|
|
|
|
public GameObject changeTurretList;
|
|
|
|
public void Awake()
|
|
{
|
|
//list_Turrets.Sort((td1,td2) =>
|
|
//{
|
|
// return td1.turretID.CompareTo(td2.turretLevel);
|
|
//});
|
|
dic_Turrets = list_Turrets.ToDictionary(td => td.turretID);
|
|
}
|
|
public void Update()
|
|
{
|
|
|
|
}
|
|
public void ChangeTurret(int n=0)
|
|
{
|
|
|
|
if (currentTurretIndex>list_Turrets.Count|| currentTurretIndex<0)
|
|
{
|
|
//currentTurretIndex = currentTurretIndex;
|
|
}
|
|
else
|
|
{
|
|
currentTurretIndex = n;
|
|
}
|
|
if (currentTurret != null)
|
|
{
|
|
currentTurret.gameObject.SetActive(false);
|
|
}
|
|
|
|
currentTurretID = list_Turrets[currentTurretIndex].turretID; //dic_Turrets[currentTurretID];
|
|
currentTurret=dic_Turrets[currentTurretID];
|
|
currentTurret.gameObject.SetActive(true);
|
|
|
|
|
|
gameObject.SetActive(true);
|
|
tra_CurrTurret =currentTurret.transform.GetChild(0);
|
|
tra_CurrFly = currentTurret.transform.GetChild(1);
|
|
skeletonAnimation = currentTurret.obj_Animation.GetComponent<SkeletonGraphic>();
|
|
old_CurrAnimation = currentTurret.obj_Animation.GetComponent<Animation>();
|
|
|
|
}
|
|
public void ChangeTurretConsumeNum(int n = 0)
|
|
{
|
|
consumeGoldNum = n;
|
|
tMP_TurretConsumeNum.text = consumeGoldNum.ToString();
|
|
|
|
}
|
|
public bool ConsumeGold(int bl=1)
|
|
{
|
|
long temp = goldNum - consumeGoldNum*bl;
|
|
if (temp > 0)
|
|
{
|
|
goldNum = temp;
|
|
tMP_GoldNum.text = goldNum.ToString();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|