WXGame/b1/Assets/脚本/材料组/MaterialGroup_Mon.cs
2024-10-23 09:14:01 +08:00

61 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.ParticleSystem;
/// <summary>
/// 材料组:子对象都是储存的材料
/// </summary>
public class MaterialGroup_Mon : MonoBehaviour
{
/// <summary>
/// 材料组预制件
/// </summary>
private GameObject MaterialGameObject;
private void LoadGame()
{
this.MaterialGameObject= Resources.Load<GameObject>("预制件/材料");
}
/// <summary>
/// 传入道具背包
/// </summary>
/// <param name="articles_">道具包</param>
public void set_material(Dictionary<Article,int> articles_)
{
foreach (Transform tra_ in this.transform){
Destroy(tra_.gameObject);
}
foreach (KeyValuePair<Article, int> entry_ in articles_)
{
this.add_material(entry_.Key, entry_.Value);
}
}
/// <summary>
/// 添加道具实力换显示
/// </summary>
/// <param name="article_">物品</param>
/// <param name="mun_">数量</param>
private void add_material(Article article_ ,int mun_)
{
GameObject go_= Instantiate(this.MaterialGameObject);
go_.transform.SetParent(this.transform);
go_.transform.localScale = new Vector3(1, 1, 1);
go_.GetComponent<ForgingMaterial_Mon>().setArticle(article_, mun_);
}
private void Awake()
{
this.LoadGame();
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}