public void onWeaponDestroy(KBEngine.Entity entity, UInt16 explodeTime)//销毁武器,添加爆炸特效 { if (gameObject == null || entity.renderObj == null || entity.className != "Weapon") { return; } UInt32 weaponModeID = ((KBEngine.Weapon)entity).uid; if (weaponModeID == 40001)//如果是激光等特效放完 { explode sript_explode = ((UnityEngine.GameObject)entity.renderObj).AddComponent <explode>(); sript_explode.Duration = explodeTime / 1.0f; entity.renderObj = null; } else { UnityEngine.GameObject.Destroy((UnityEngine.GameObject)entity.renderObj); entity.renderObj = null; CONF.conf_bullet bullet_conf = (CONF.conf_bullet)CSVHelper.Instance.GetItem("conf_bullet", weaponModeID); addEffect(entity.position, entity.direction, bullet_conf.Explode, explodeTime); } Debug.Log("World::onReqWeaponDestroyTime: " + entity.id + ",className:" + entity.className); }
public void onEnterWorld(KBEngine.Entity entity) { if (gameObject == null || entity.isPlayer()) { createPlayer(); return; } GameObject perfab = null; Debug.Log("onEnterWorld." + entity.id + ",position:" + entity.position + ",direction:" + entity.direction); if (entity.className == "Avatar") { perfab = ChooseShip(entity); } else if (entity.className == "Weapon") { KBEngine.Weapon arsenal = (KBEngine.Weapon)entity; CONF.conf_bullet bullet_conf = (CONF.conf_bullet)CSVHelper.Instance.GetItem("conf_bullet", arsenal.uid); if (bullet_conf == null) { Debug.LogError("world::bullet_conf not found arsenal.uid:" + arsenal.uid); return; } perfab = Resources.Load <GameObject>(bullet_conf.Perfab); } else if (entity.className == "Mine") { perfab = minePerfab; } else if (entity.className == "SupplyBox") { perfab = supplyBoxPerfab; } if (perfab == null) { Debug.LogError("entity." + entity.id + ",className:" + entity.className + ",SelectIndex:" + PlayerData.Instance.SelectIndex); return; } entity.renderObj = Instantiate(perfab, entity.position, Quaternion.Euler(entity.direction), transform) as UnityEngine.GameObject; ((GameObject)entity.renderObj).name = entity.className + "_" + entity.id; Debug.Log("onEnterWorld." + entity.id + ",rederObj:" + (UnityEngine.GameObject)entity.renderObj + ",position:" + ((UnityEngine.GameObject)entity.renderObj).transform.position + ",eulerAngles:" + ((UnityEngine.GameObject)entity.renderObj).transform.rotation.eulerAngles); if (entity.className == "Avatar") { ((GameObject)entity.renderObj).GetComponent <ShipBase>()._attri.Id = entity.id; } // ((UnityEngine.GameObject)entity.renderObj).transform.parent = transform; }
//配置表第三行开始 public override Dictionary <UInt32, object> ReadOneExcel(string filename) { Unity.Logout.Log("conf_bullet::ReadOneExcel," + filename); FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read); //IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); System.Data.DataSet result = excelReader.AsDataSet(); DataRowCollection rows = result.Tables[0].Rows; int columns = result.Tables[0].Columns.Count; Dictionary <UInt32, object> conf_table = new Dictionary <uint, object>(); //excelReader.GetInt32(0); for (int i = 3; i < rows.Count; i++) { int index = 0; conf_bullet weapon = new conf_bullet(); weapon.init = true; weapon.nID = (UInt32)Convert.ChangeType(rows[i][index++].ToString(), typeof(UInt32)); weapon.name = (string)Convert.ChangeType(rows[i][index++].ToString(), typeof(string)); weapon.cooldownTime = (float)Convert.ChangeType(rows[i][index++].ToString(), typeof(float)); weapon.attackDistance = (float)Convert.ChangeType(rows[i][index++].ToString(), typeof(float)); weapon.speed = (float)Convert.ChangeType(rows[i][index++].ToString(), typeof(float)); weapon.damage = (float)Convert.ChangeType(rows[i][index++].ToString(), typeof(float)); weapon.explodeTime = (float)Convert.ChangeType(rows[i][index++].ToString(), typeof(float)); weapon.barNode = (string)Convert.ChangeType(rows[i][index++].ToString(), typeof(string)); weapon.perfab = (string)Convert.ChangeType(rows[i][index++].ToString(), typeof(string)); weapon.explode = (string)Convert.ChangeType(rows[i][index++].ToString(), typeof(string)); Debug.Assert(index == columns); if (!conf_table.ContainsKey(weapon.NID)) { conf_table[weapon.NID] = weapon; } } excelReader.Close(); stream.Close(); return(conf_table); }