public void onPhantomDele(headPhantom phantom) { string message = "刪除幻影時gird物件數量為:" + phantom.girdsAttach.Count; if (phantom.girdsAttach.Count > 0) { gird nearest = phantom.girdsAttach[0].GetComponent <gird>(); float min_dist = (phantom.transform.position - nearest.transform.position).magnitude; foreach (GameObject gird in phantom.girdsAttach) { float dist = (gird.transform.position - phantom.transform.position).magnitude; if (dist < min_dist) { nearest = gird.GetComponent <gird>(); min_dist = dist; } //message += " " + gird.gameObject.name + "pos:(" + script.x + "," + script.y + ")"; phantom.data.location = new vec2i(nearest.x, nearest.y); } } else { phantom.data.location = null; } updatePanel(dataWarehouse.main.nowData); Debug.Log(message); }
void onPhantomDelete(headPhantom phant) { if (phant.girdsAttach.Count > 0) { upgradeBox box = phant.girdsAttach[0].GetComponent <upgradeBox>(); if (box != null) { box.onPick(roleInf); } } }