public void SpawnItemBox(RefItemSpawn[] refDropItems, Vector3 pos) { if (refDropItems == null) { refDropItems = GetCurrentWave().itemSpawn.defaultItem; } float goldAlpha = m_wave*0.1f; int spawnedItemCount = 0; float ratioAlpha = 0; foreach(RefItemSpawn desc in refDropItems) { for(int i = 0; i < desc.count; ++i) { float ratio = Random.Range(0f, 1f); ratioAlpha = 0f; if (desc.refItem.type == ItemData.Type.WeaponParts) { ratioAlpha = Mathf.Min(Mathf.Max(0, m_wave-Const.MaxWave)/10000f, 0.1f); } else if (desc.refItem.type == ItemData.Type.WeaponDNA) { if (GetStage() < GetCurrentWave().mobSpawns.Length) ratio = 0f; } if (ratio > 0 && ratio <= (desc.ratio+ratioAlpha)) { float scale = 1f; ItemData item = null; switch(desc.refItem.type) { case ItemData.Type.Gold: item = new ItemGoldData(1); if (m_champ != null) { item.Count *= m_champ.GoldLevel; int extraCount = (int)(item.Count*m_champ.m_creatureProperty.GainExtraGold); item.Count += extraCount; } break; case ItemData.Type.HealPosion: item = new ItemHealPosionData(Random.Range(desc.minValue, desc.maxValue)); break; case ItemData.Type.Weapon: item = new ItemWeaponData(desc.refItem.id); break; case ItemData.Type.WeaponParts: if (m_champ != null && m_champ.WeaponHolder.MainWeapon != null) { ItemObject hasItem = Warehouse.Instance.FindItem(desc.refItemId); if (hasItem == null) item = new ItemWeaponPartsData(desc.refItemId); else if (hasItem != null && hasItem.Item.Level < hasItem.Item.RefItem.maxLevel) item = new ItemWeaponPartsData(desc.refItemId); } break; case ItemData.Type.WeaponDNA: item = new ItemWeaponDNAData(desc.refItem.id); break; case ItemData.Type.Accessory: item = new ItemAccessoryData(desc.refItem.id); break; case ItemData.Type.GoldMedal: { item = new ItemGoldMedalData(Random.Range(desc.minValue, desc.maxValue)); } break; case ItemData.Type.Skill: item = new ItemSkillData(Random.Range(desc.minValue, desc.maxValue+1)); break; case ItemData.Type.XPPotion: item = new ItemXPPotionData(Random.Range(desc.minValue, desc.maxValue)); item.Count += (int)(item.Count*goldAlpha); if (m_champ != null) item.Count += (int)(item.Count*m_champ.m_creatureProperty.GainExtraExp); break; case ItemData.Type.MobEgg: break; } if (item != null) { ++spawnedItemCount; GameObject itemBoxObj = (GameObject)Instantiate(m_prefItemBox, pos, Quaternion.Euler(0f, 0f, 0f)); ItemBox itemBox = itemBoxObj.GetComponent<ItemBox>(); itemBox.Item = item; itemBox.PickupCallback = (Creature obj)=>{ }; GameObject itemSkinObj = (GameObject)Instantiate(m_prefItemBoxSkins[(int)desc.refItem.type], pos, Quaternion.Euler(0f, 0f, 0f)); if (desc.refItem.type == ItemData.Type.Skill) { itemSkinObj.transform.Find(item.RefItem.codeName).gameObject.SetActive(true); itemBox.LifeTime = 60f; } else if (desc.refItem.type == ItemData.Type.WeaponParts) { itemSkinObj.transform.Find(item.RefItem.codeName).gameObject.SetActive(true); } itemSkinObj.transform.parent = itemBoxObj.transform; itemSkinObj.transform.localPosition = Vector3.zero; itemSkinObj.transform.localRotation = m_prefItemBoxSkins[(int)desc.refItem.type].transform.rotation; itemBoxObj.transform.localScale = Vector3.one * scale; itemBoxObj.SetActive(false); StartCoroutine(EffectSpawnItemBox(itemBox, 0.15f*spawnedItemCount)); } } } } }
public void Init(RefMob refMob, int mobLevel, RefItemSpawn[] refDropItems, bool boss) { base.Init(refMob, mobLevel, 0); RefMob = refMob; RefDropItems = refDropItems; Boss = boss; if (Random.Range(0f, 1f) < 0.3f) m_creatureProperty.BetaMoveSpeed = 1.7f; /* if (true == Boss) { transform.Find("FloatingHealthBarGUI").gameObject.SetActive(true); }*/ GameObject prefDeathEffect = Resources.Load<GameObject>("Pref/mon_skin/"+refMob.prefBody+"_death"); if (prefDeathEffect != null) { m_prefDeathEffect = prefDeathEffect; } foreach(RefMob.WeaponDesc weaponDesc in refMob.refWeaponItems) { if (weaponDesc.reqLevel > mobLevel) continue; if (weaponDesc.passive == true) { EquipPassiveSkillWeapon(new ItemWeaponData(weaponDesc.refItemId), weaponDesc); } else { EquipWeapon(new ItemWeaponData(weaponDesc.refItemId), weaponDesc); } } switch(refMob.mobAI) { case MobAIType.Normal: m_ai = new MobAINormal(); break; case MobAIType.Rotation: m_ai = new MobAIRotation(); break; case MobAIType.FlyingAround: m_ai = new MobAIFlyingAround(); CreatureType = Type.MobNpc; break; case MobAIType.ItemShuttle: m_ai = new MobAIItemShuttle(); break; case MobAIType.Dummy: m_ai = new MobAIDummy(); break; case MobAIType.Bomber: m_ai = new MobAIBomber(); break; case MobAIType.Egg: m_ai = new MobAIEgg(); break; } m_ai.Init(this); }