using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class logic : MonoBehaviour {
public static logic sharedInstance = null;
public string finalLevelName = "Level01";
public GameObject hand = null;
public GameObject weapon = null;
public string weapon_name = null;
public GameObject chat_Panel;
public GameObject cherry_Panel = null;
[HideInInspector]
public static int cherry_num = 0;
//public List<BackpacItem> bag_items = null;
public ArrayList bag_items = null;
public GameObject bag_Panel = null;
public GameObject hand_Panel = null;
public GameObject life_Panel = null;
public int lifeNum = 5;
public class weaponItem : MonoBehaviour
{
public string nam = null;
public Sprite icon = null;
public GameObject prefab = null;
//public int numInList = 0;
public virtual void trigger(GameObject obj)
{//根据物体不同反应
//logic.sharedInstance.weapon.GetComponent<weapon> ().trigger ();
}
}
public void createWeapon (weaponItem item){
if (weapon != null) {
weapon_name = null;
Destroy (weapon.gameObject);
}
GameObject new_weapon = GameObject.Instantiate (item.prefab);
//Debug.Log("生成了");
weapon_name = item.nam;
new_weapon.transform.position = hand.transform.position;
new_weapon.transform.parent = hand.transform;
Debug.Log(new_weapon.transform.position);
weapon = new_weapon;
}
public void removeWeapon (){
if (weapon != null) {
weapon_name = null;
Destroy (weapon.gameObject);
}
}
//public weaponItem[] weaponList = null;
void Awake(){
sharedInstance = this;
// NewItemManager.Instance.LoadItemConfigData();
//this.bag_items = NewItemManager.Instance.BackPackItemList;
}
private void Start()
{
hand = GameObject.Find("Hand");
}
void FixedUpdate () {
if (life_Panel)
{
setLife();
}
//if (bag_Panel)
//{
// setGrid();
//}
}
public void setLife()
{
for(int i =0; i < lifeNum; i++)
{
life_Panel.transform.GetChild(i).gameObject.SetActive(true);
}
for (int j = lifeNum; j < 5; j++)
{
life_Panel.transform.GetChild(j).gameObject.SetActive(false);
}
}
//public void setGrid(){
// int it = 0;
// foreach(weaponItem i in bag_items){
// if (i != null)
// {
// bag_Panel.transform.GetChild(it).GetChild(0).GetComponent<UnityEngine.UI.Image>().sprite = i.prefab.GetComponent<SpriteRenderer>().sprite;
// bag_Panel.transform.GetChild(it).GetChild(0).gameObject.SetActive(true);
// bag_Panel.transform.GetChild(it).GetChild(0).GetComponent<DragMe>().item = i;
// it++;
// }
// }
// for (int j = it; j < 15; j++) {
// bag_Panel.transform.GetChild(j).GetChild(0).GetComponent<UnityEngine.UI.Image>().sprite = null;
// bag_Panel.transform.GetChild(j).GetChild(0).gameObject.SetActive(false);
// bag_Panel.transform.GetChild(j).GetChild(0).GetComponent<DragMe>().item = null;
// }
//}
}