mirror of
https://github.com/lllyasviel/YGOProUnity_V2.git
synced 2026-10-20 16:07:11 +08:00
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
//----------------------------------------------
|
|
// NGUI: Next-Gen UI kit
|
|
// Copyright © 2011-2014 Tasharen Entertainment
|
|
//----------------------------------------------
|
|
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Equip the specified items on the character when the script is started.
|
|
/// </summary>
|
|
|
|
[AddComponentMenu("NGUI/Examples/Equip Items")]
|
|
public class EquipItems : MonoBehaviour
|
|
{
|
|
public int[] itemIDs;
|
|
|
|
void Start ()
|
|
{
|
|
if (itemIDs != null && itemIDs.Length > 0)
|
|
{
|
|
InvEquipment eq = GetComponent<InvEquipment>();
|
|
if (eq == null) eq = gameObject.AddComponent<InvEquipment>();
|
|
|
|
int qualityLevels = (int)InvGameItem.Quality._LastDoNotUse;
|
|
|
|
for (int i = 0, imax = itemIDs.Length; i < imax; ++i)
|
|
{
|
|
int index = itemIDs[i];
|
|
InvBaseItem item = InvDatabase.FindByID(index);
|
|
|
|
if (item != null)
|
|
{
|
|
InvGameItem gi = new InvGameItem(index, item);
|
|
gi.quality = (InvGameItem.Quality)Random.Range(0, qualityLevels);
|
|
gi.itemLevel = NGUITools.RandomRange(item.minItemLevel, item.maxItemLevel);
|
|
eq.Equip(gi);
|
|
}
|
|
else
|
|
{
|
|
//Debug.LogWarning("Can't resolve the item ID of " + index);
|
|
}
|
|
}
|
|
}
|
|
Destroy(this);
|
|
}
|
|
} |