private void ProcDigVoxels(SkEntity caster) { SkInst inst = SkRuntimeInfo.Current as SkInst; IDigTerrain digTerrain = caster as IDigTerrain; IntVector4 digPos = null; if (null == digTerrain || (digPos = digTerrain.digPosType) == IntVector4.Zero || (inst != null && !(inst._target is VFVoxelTerrain))) { return; } float damage = caster.GetAttribute((int)AttribType.Atk) * (1f + caster.GetAttribute((int)AttribType.ResDamage)); float radius = caster.GetAttribute((int)AttribType.ResRange); float resourceBonus = caster.GetAttribute((int)AttribType.ResBouns); float height = caster.GetAttribute((int)AttribType.ResDamage); bool returnResource = digPos.w == 1; IntVector3 intPos = digPos.XYZ; if (!GameConfig.IsMultiMode) { //VFVoxel getVoxel = VFVoxelTerrain.self.Voxels.SafeRead(intPos.x, intPos.y, intPos.z); List <VFVoxel> removeList = new List <VFVoxel>(); DigTerrainManager.DigTerrain(intPos, damage * (returnResource ? 5f : 1f), radius, height, ref removeList, returnResource); if (returnResource) { bool bGetSpItems = false; if (caster is SkAliveEntity) { SkAliveEntity alive = (SkAliveEntity)caster; SkillTreeUnitMgr mgr = alive.Entity.GetCmpt <SkillTreeUnitMgr>(); bGetSpItems = mgr.CheckMinerGetRare(); } Dictionary <int, int> itemGet = DigTerrainManager.GetResouce(removeList, resourceBonus, bGetSpItems); if (itemGet.Count > 0) { List <int> itemsArray = new List <int>(itemGet.Count * 2); foreach (int intemID in itemGet.Keys) { itemsArray.Add(intemID); itemsArray.Add(itemGet[intemID]); } caster.Pack += itemsArray.ToArray(); } } } else { if (caster != null && caster._net != null) { //VFVoxel getVoxel = VFVoxelTerrain.self.Voxels.SafeRead(intPos.x,intPos.y, intPos.z); bool bGetSpItems = false; if (returnResource) { if (caster is SkAliveEntity) { SkAliveEntity alive = (SkAliveEntity)caster; SkillTreeUnitMgr mgr = alive.Entity.GetCmpt <SkillTreeUnitMgr>(); bGetSpItems = mgr.CheckMinerGetRare(); } } DigTerrainManager.DigTerrainNetwork((SkNetworkInterface)(caster._net), intPos, damage * (returnResource ? 5f : 1f), radius, resourceBonus, returnResource, bGetSpItems, 0.3f); } } }
private void onAlterAttribs(int idx, float oldValue, float newValue) { // if(_targetTree == null) return; // Debug.Log("Cutting a tree........"); /* when the tree's hp has been cut to zero * if (null != LSubTerrainMgr.Instance) * { * LSubTerrainMgr.DeleteTree(mGroundItem); * LSubTerrainMgr.RefreshAllLayerTerrains(); * } * else if (null != RSubTerrainMgr.Instance) * { * RSubTerrainMgr.DeleteTree(mGroundItem._treeInfo); * RSubTerrainMgr.RefreshAllLayerTerrains(); * } */ if (idx != 2) { return; } float damage = _attribs.sums[0]; float resourceBonus = _attribs.sums[1]; bool returnResource = _attribs.sums[2] > 0.0f; SkEntity caster = GetCasterToModAttrib(idx); if (null != caster) { ISkSubTerrain subTerrain = caster as ISkSubTerrain; if (null != subTerrain && null != subTerrain.treeInfo) { treeHPInfos[subTerrain.treeInfo.WorldPos] = DigTerrainManager.Fell(subTerrain.treeInfo, damage, GetTreeHP(subTerrain.treeInfo.WorldPos)); if (GameConfig.IsMultiMode) { caster.SendFellTree(subTerrain.treeInfo._treeInfo.m_protoTypeIdx, subTerrain.treeInfo.WorldPos, subTerrain.treeInfo._treeInfo.m_heightScale, subTerrain.treeInfo._treeInfo.m_widthScale); } else { if (treeHPInfos[subTerrain.treeInfo.WorldPos] <= 0) { OnTreeCutDown(caster, subTerrain.treeInfo); DigTerrainManager.RemoveTree(subTerrain.treeInfo); if (returnResource) { bool bGetSpItems = false; if (caster is SkAliveEntity) { SkAliveEntity alive = (SkAliveEntity)caster; if (alive.Entity.proto == EEntityProto.Player) { SkillTreeUnitMgr mgr = alive.Entity.GetCmpt <SkillTreeUnitMgr>(); bGetSpItems = mgr.CheckMinerGetRare(); } } Dictionary <int, int> itemGet = DigTerrainManager.GetTreeResouce(subTerrain.treeInfo, resourceBonus, bGetSpItems); if (itemGet.Count > 0) { List <int> itemsArray = new List <int>(itemGet.Count * 2); foreach (int intemID in itemGet.Keys) { itemsArray.Add(intemID); itemsArray.Add(itemGet[intemID]); } GetSpecialItem.PlantItemAdd(ref itemsArray); //植物特殊道具添加 caster._attribs.pack += itemsArray.ToArray(); } } } } } } }