WXGame/box1/Assets/Script/UI/HomePanel.cs
2024-11-26 15:44:50 +08:00

111 lines
2.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Spine.Unity;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class HomePanel : MonoBehaviour
{
[SerializeField] private SkeletonGraphic window;
[SerializeField] private SkeletonGraphic light;
[SerializeField] private SkeletonGraphic carpet;
[SerializeField] private SkeletonGraphic closet;
[SerializeField] private SkeletonGraphic chair;
[SerializeField] private Button TourButton;
[SerializeField] private List<BuildButton> _buildButtons;
[SerializeField] private TextMeshProUGUI star;
public void ResetImage()
{
var windowLv = DataManager.GetHomeFurnitureID("window");
var lightLv = DataManager.GetHomeFurnitureID("light");
var carpetLv = DataManager.GetHomeFurnitureID("carpet");
var closetLv = DataManager.GetHomeFurnitureID("closet");
var chairLv = DataManager.GetHomeFurnitureID("chair");
if (windowLv==0)
{
windowLv = 5001021;
DataManager.SetHomeFurnitureID("window", windowLv);
}
if (lightLv==0)
{
lightLv = 5001031;
DataManager.SetHomeFurnitureID("light", lightLv);
}
if (carpetLv==0)
{
carpetLv = 5001051;
DataManager.SetHomeFurnitureID("carpet", carpetLv);
}
if (closetLv==0)
{
closetLv = 5001041;
DataManager.SetHomeFurnitureID("closet", closetLv);
}
if (chairLv==0)
{
chairLv = 5001011;
DataManager.SetHomeFurnitureID("chair", chairLv);
}
foreach (var button in _buildButtons)
{
button.RestGameObject(this);
}
SetAniRest(window, windowLv);
SetAniRest(light, lightLv);
SetAniRest(carpet, carpetLv);
SetAniRest(closet, closetLv);
SetAniRest(chair, chairLv);
star.text = DataManager.GetStar().ToString();
}
private void SetAniRest(SkeletonGraphic ani,int id)
{
var data = JsonTab.Instance.tables.BuildLevelUp.Get(id);
ani.Skeleton.SetSkin(data.Buildingicon);
ani.Skeleton.SetSlotsToSetupPose();
}
private void OnEnable()
{
TourButton.onClick.AddListener(TourPanel);
}
private void OnDisable()
{
TourButton.onClick.RemoveListener(TourPanel);
}
bool OpenLevel(string key)
{
return false;
}
void TourPanel()
{
MainPanel.ins.ClosePanelEvent();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}