bool ExtractBundle(ItemAsset.Bundle bundle) { if (null == bundle) { return(false); } PackageCmpt pkg = Entity.GetCmpt <PackageCmpt>(); if (null == pkg) { return(false); } IEnumerable <ItemAsset.ItemObject> items = bundle.Extract(); if (null == items) { return(false); } List <ItemAsset.ItemObject> itemList = new List <ItemAsset.ItemObject>(items); if (!pkg.CanAddItemList(itemList)) { return(false); } pkg.AddItemList(itemList); return(true); }
public override void Start() { base.Start(); mPkg = Entity.GetCmpt <PackageCmpt>(); if (NetworkInterface.IsClient) { mNet = Entity.GetCmpt <NetCmpt>(); } }
public override void Start() { base.Start(); m_MoveState = new List <Vector3> (MoveRecordCount); m_MoveRequest = new List <Vector3> (MoveRequestCount); gMainPlayer = this; gameObject.AddComponent <Scanner> (); mMove = Entity.GetCmpt <Motion_Move_Human> (); mEquip = Entity.motionEquipment; mView = Entity.biologyViewCmpt; mTrans = Entity.peTrans; mIK = Entity.GetCmpt <IKCmpt> (); m_Skill = Entity.aliveEntity; mPackage = Entity.GetCmpt <PackageCmpt> (); mPassenger = Entity.passengerCmpt; mMotionMgr = Entity.motionMgr; mMotionMgr.onActionStart += OnActionStart; mMotionMgr.onActionEnd += OnActionEnd; m_Abnormalcmpt = Entity.Alnormal; if (null != m_Abnormalcmpt) { m_Abnormalcmpt.evtStart += OnStartAbnormal; m_Abnormalcmpt.evtEnd += OnEndAbnormal; } if (null != m_Skill) { m_Skill.onHpReduce += OnDamage; m_Skill.attackEvent += OnAttack; m_Skill.deathEvent += OnDeath; m_Skill.onSkillEvent += OnSkillTarget; m_Skill.onWeaponAttack += OnWeaponAttack; m_Skill.OnBeEnemyEnter += OnBeEnemyEnter; } if (!PeGameMgr.IsTutorial) { StartCoroutine(UpdateAbnormalNotice()); } //历险模式下此时初始化声望系统,ForceSetting并未加载,会导致声望系统不能正常起作用 //InitReputationSystem(); Invoke("CheckAbnormalState", 5f); }
void RPC_S2C_PlayerMoney(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int money = stream.Read <int>(); if (Equals(null, entity)) { return; } Pathea.PackageCmpt package = entity.GetCmpt <Pathea.PackageCmpt>(); if (null == package) { return; } package.money.current = money; }
void Update() { if (Pathea.PeCreature.Instance.mainPlayer == null) { return; } // Has player enough items ? Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PackageCmpt>(); if (mCbTexture.isChecked) { foreach (UIBuildWndItem item in mVoxelMatList) { item.SetNumber(pkg.GetItemCount(item.ItemId).ToString()); } } else if (mCbBlock.isChecked) { foreach (UIBuildWndItem item in mBlockMatList) { item.SetNumber(pkg.GetItemCount(item.ItemId).ToString()); } } }
protected void RemoveFromBag() { Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.packageCmpt; //some item stack count > 1, seed eg. if (itemDragging.itemObj.stackCount > 1) { pkg.DestroyItem(itemDragging.itemObj, 1); } else { pkg.Remove(itemDragging.itemObj); } if (Pathea.PlayerPackageCmpt.LockStackCount && !ItemAsset.ItemMgr.IsCreationItem(itemDragging.itemObj.protoId)) { Pathea.PlayerPackageCmpt playerPkg = pkg as Pathea.PlayerPackageCmpt; if (playerPkg != null) { playerPkg.package.Add(itemDragging.itemObj.protoId, 1); } } }
void Update() { if (DragObejct != null) { if (Input.GetMouseButtonUp(0)) { Destroy(DragObejct); DragObejct = null; if (DragItem != null) { if (DragItem.mItemType == UIBuildWndItem.ItemType.mMenu) { UIBlockSaver.Instance.RemoveData((mBoxBars.PageIndex - 1) * c_MaxMenuItems + DragItem.mIndex); UpdateMenuItems(mBoxBars.PageIndex); DragItem = null; } } } } // ShortCut if (PeInput.Get(PeInput.LogicFunction.QuickBar1)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[0]); } mMenuList[0].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar2)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[1]); } mMenuList[1].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar3)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[2]); } mMenuList[2].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar4)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[3]); } mMenuList[3].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar5)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[4]); } mMenuList[4].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar6)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[5]); } mMenuList[5].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar7)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[6]); } mMenuList[6].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar8)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[7]); } mMenuList[7].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar9)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[8]); } mMenuList[8].PlayGridEffect(); } else if (PeInput.Get(PeInput.LogicFunction.QuickBar10)) { if (onQuickBarFunc != null) { onQuickBarFunc(mMenuList[9]); } mMenuList[9].PlayGridEffect(); } // Short Cut For Brush if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut1)) { if (!mPointBtn.checkBox.isChecked) { mPointBtn.checkBox.isChecked = true; BtnBrush1_OnClick(); } } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut2)) { if (!mBoxBtn.checkBox.isChecked) { mBoxBtn.checkBox.isChecked = true; BtnBrush2_OnClick(); } } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut3)) { if (!mDiagonalBtn.checkBox.isChecked) { UISkillWndCtrl uiSkill = GameUI.Instance.mSkillWndCtrl; if (uiSkill._SkillMgr != null) { if (!uiSkill._SkillMgr.CheckUnlockBuildBlockBevel()) { return; } } mDiagonalBtn.checkBox.isChecked = true; BtnBrush3_OnClick(); } } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut4)) { if (!mSelectBtn.checkBox.isChecked) { mSelectBtn.checkBox.isChecked = true; BtnBrush4_OnClick(); } } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut5)) { if (!mSelectBlockBtn.checkBox.isChecked) { mSelectBlockBtn.checkBox.isChecked = true; BtnBrush5_OnClick(); } } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut6)) { BtnSaveOnClick(); } else if (PeInput.Get(PeInput.LogicFunction.Build_Shortcut7)) { BtnMenuOnClick(); } if (PeInput.Get(PeInput.LogicFunction.PrevQuickBar)) { mBoxBars.BtnPageUpOnClick(); } if (PeInput.Get(PeInput.LogicFunction.NextQuickBar)) { mBoxBars.BtnPageDnOnClick(); } //if (Input.GetKeyDown(KeyCode.Tab)) //{ // if (mPointBtn.checkBox.isChecked) // { // if (onQuickSwitchPointBrush != null) // onQuickSwitchPointBrush(); // } // //else if (mDiagonalBtn.checkBox.isChecked) // //{ // // if (onQuickSwitchDiagonalBrush != null) // // onQuickSwitchDiagonalBrush(); // //} // else if (mBoxBtn.checkBox.isChecked) // { // if (onQuickSwitchBoxBrush != null) // onQuickSwitchBoxBrush(); // } //} // if (Pathea.PeCreature.Instance.mainPlayer != null) { Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PackageCmpt>(); foreach (UIBuildWndItem item in mMenuList) { if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockMat) { item.SetNumber(pkg.GetItemCount(item.ItemId).ToString()); } else if (item.mTargetItemType == UIBuildWndItem.ItemType.mVoxelType) { int proto_id = PEBuildingMan.GetVoxelItemProtoID((byte)item.ItemId); item.SetNumber(pkg.GetItemCount(proto_id).ToString()); } else if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockPattern) { item.SetNumber(mBulidWnd.mBlockPatternList[item.mTargetIndex].mNumber.text); } else { item.SetNumber(""); } } } }
/// <summary> /// voxel modify check event before really undo and redo. Call by BSVoxelModify /// </summary> bool OnCheckVoxelModify(int opType, IntVector3[] indexes, BSVoxel[] voxels, BSVoxel[] oldvoxels, EBSBrushMode mode, IBSDataSource ds) { if (IsGod) { return(true); } if (Pathea.PeCreature.Instance.mainPlayer == null) { return(false); } bool result = true; if (mode == EBSBrushMode.Add) { Dictionary <int, int> items = new Dictionary <int, int>(); // Calculate the needed items; int adder = 1; foreach (BSVoxel voxel in voxels) { int id = 0; if (ds == BuildingMan.Blocks) { if (voxel.IsExtendable()) { if (!voxel.IsExtendableRoot()) { id = GetBlockItemProtoID((byte)(voxel.materialType >> 2)); adder = 1; } else { adder = 0; } } else { id = GetBlockItemProtoID(voxel.materialType); } } else if (ds == BuildingMan.Voxels) { id = GetVoxelItemProtoID(voxel.materialType); } if (id <= 0) { continue; } if (id != 0) { if (items.ContainsKey(id)) { items[id] += adder; } else { items.Add(id, adder); } } } _costsItems = items; float divisor = 1.0f; if (ds == BuildingMan.Blocks) { divisor = (float)(1 << BSBlock45Data.s_ScaleInverted); } // Has player enough items ? Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PackageCmpt>(); _playerItems.Clear(); foreach (KeyValuePair <int, int> kvp in items) { _playerItems.Add(kvp.Key, pkg.GetItemCount(kvp.Key)); if (pkg.GetItemCount(kvp.Key) < Mathf.CeilToInt(kvp.Value / divisor)) { result = false; } } // now delete if (result) { if (GameConfig.IsMultiMode) { if (null == PlayerNetwork.mainPlayer) { return(false); } if (!Pathea.PeGameMgr.IsMultiCoop && VArtifactUtil.IsInTownBallArea(PlayerNetwork.mainPlayer._pos)) { new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning); return(false); } //if (!PlayerNetwork.OnLimitBoundsCheck(brushBound)) //{ // new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning); // return false; //} PlayerNetwork.mainPlayer.RequestRedo(opType, indexes, oldvoxels, voxels, mode, ds.DataType, ds.Scale); DigTerrainManager.BlockClearGrass(ds, indexes); return(true); } else { string debug_log = ""; foreach (KeyValuePair <int, int> kvp in items) { if (pkg.Destory(kvp.Key, Mathf.CeilToInt(kvp.Value / divisor))) { debug_log += "\r\n Rmove Item from player package ID[" + kvp.Key.ToString() + "]" + " count - " + kvp.Value.ToString(); } } if (ds == BuildingMan.Blocks) { for (int i = 0; i < indexes.Length; i++) { Vector3 pos = new Vector3(indexes[i].x * ds.Scale, indexes[i].y * ds.Scale, indexes[i].z * ds.Scale) - ds.Offset; PeGrassSystem.DeleteAtPos(pos); PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y - 1, pos.z)); //PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y + 1, pos.z)); } } else if (ds == BuildingMan.Voxels) { for (int i = 0; i < indexes.Length; i++) { Vector3 pos = new Vector3(indexes[i].x, indexes[i].y, indexes[i].z); PeGrassSystem.DeleteAtPos(pos); PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y - 1, pos.z)); //PeGrassSystem.DeleteAtPos(new Vector3(pos.x, pos.y + 1, pos.z)); } } //Debug.LogWarning(debug_log); } } else { new PeTipMsg(PELocalization.GetString(821000001), PeTipMsg.EMsgLevel.Warning); } } else if (mode == EBSBrushMode.Subtract) { Dictionary <int, int> items = new Dictionary <int, int>(); // Calculate the needed items; int adder = 1; foreach (BSVoxel voxel in oldvoxels) { int id = 0; if (ds == BuildingMan.Blocks) { if (voxel.IsExtendable()) { if (!voxel.IsExtendableRoot()) { id = GetBlockItemProtoID((byte)(voxel.materialType >> 2)); adder = 1; } else { adder = 0; } } else { if (!BuildingMan.Blocks.VoxelIsZero(voxel, 0)) { id = GetBlockItemProtoID((byte)(voxel.materialType)); } } } else if (ds == BuildingMan.Voxels) { if (!BuildingMan.Voxels.VoxelIsZero(voxel, 1)) { id = GetVoxelItemProtoID(voxel.materialType); } } if (id <= 0) { continue; } if (items.ContainsKey(id)) { items[id] += adder; } else { items.Add(id, adder); } } float divisor = 1.0f; if (ds == BuildingMan.Blocks) { divisor = (float)(1 << BSBlock45Data.s_ScaleInverted); } // Has player enough package ? Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>(); MaterialItem[] array = new MaterialItem[items.Count]; int i = 0; foreach (KeyValuePair <int, int> kvp in items) { array[i] = new MaterialItem() { protoId = kvp.Key, count = Mathf.FloorToInt(kvp.Value / divisor) }; i++; } result = pkg.package.CanAdd(array); // Really add if (result) { if (GameConfig.IsMultiMode) { if (null == PlayerNetwork.mainPlayer) { return(false); } //if (!PlayerNetwork.OnLimitBoundsCheck(brushBound)) //{ // new PeTipMsg(PELocalization.GetString(8000864), PeTipMsg.EMsgLevel.Warning); // return false; //} PlayerNetwork.mainPlayer.RequestRedo(opType, indexes, oldvoxels, voxels, mode, ds.DataType, ds.Scale); return(true); } else { string debug_log = ""; foreach (MaterialItem mi in array) { if (mi.count != 0) { pkg.Add(mi.protoId, mi.count); } debug_log += "Add Item from player package ID[" + mi.protoId.ToString() + "]" + " count - " + mi.count.ToString() + "\r\n"; } Debug.LogWarning(debug_log); } } } if (result) { if (onVoxelMotify != null) { onVoxelMotify(indexes, voxels, oldvoxels, mode, ds); } } return(result); }
void Update() { if (_manipulator.BrushType == BuildingMan.EBrushType.Select) { // Select mode for voxels if (selectVoxel) { _manipulator.pattern = BSPattern.DefaultV1; } // Select mode for block else { _manipulator.pattern = BSPattern.DefaultB1; } } else if (_manipulator.BrushType == BuildingMan.EBrushType.Point || _manipulator.BrushType == BuildingMan.EBrushType.Box || _manipulator.BrushType == BuildingMan.EBrushType.B45Diagonal) { #if TEST_CODE UpdateTest(); #endif if (m_Pattern != null) { _manipulator.pattern = m_Pattern; } } else { _manipulator.pattern = null; } if (_manipulator.BrushType == BuildingMan.EBrushType.Box) { BSBoxBrush brush = _manipulator.activeBrush as BSBoxBrush; if (brush != null) { Vector3 size = brush.Size; int count = Mathf.RoundToInt(size.x) * Mathf.RoundToInt(size.y) * Mathf.RoundToInt(size.z) * brush.pattern.size; if (Pathea.PeCreature.Instance.mainPlayer == null) { return; } Pathea.PackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PackageCmpt>(); if (brush.dataSource == BuildingMan.Blocks) { int itemId = GetBlockItemProtoID((byte)(brush.materialType)); if (pkg.GetItemCount(itemId) >= (Mathf.CeilToInt((float)count / 4))) { brush.forceShowRemoveColor = false; } else { brush.forceShowRemoveColor = true; } } else if (brush.dataSource == BuildingMan.Voxels) { int itemId = GetVoxelItemProtoID(brush.materialType); if (pkg.GetItemCount(itemId) >= count) { brush.forceShowRemoveColor = false; } else { brush.forceShowRemoveColor = true; } } } } }
void InitAction() { m_Trans = Entity.peTrans; m_Skill = Entity.aliveEntity; m_Skill.onSheildReduce += OnSheildReduce; m_View = Entity.biologyViewCmpt; m_EquipCmpt = Entity.equipmentCmpt; m_Package = Entity.packageCmpt; m_NPC = Entity.NpcCmpt; m_Anim = Entity.animCmpt; m_MotionMgr = Entity.motionMgr; Invoke("CheckGloves", 0.5f); m_HeavyEquipmentCtrl.moveCmpt = Entity.motionMove as Motion_Move_Human; m_HeavyEquipmentCtrl.ikCmpt = Entity.IKCmpt; m_HeavyEquipmentCtrl.motionMgr = m_MotionMgr; // m_ChainSawActive.anim = anim; m_SwordAttack.m_UseStamina = isMainPlayer; m_TwoHandWeaponAttack.m_UseStamina = isMainPlayer; //Gun m_GunFire.m_gunHold = m_GunHold; m_HandChangeHold.onActiveEvt += OnActiveEquipment; m_HandChangeHold.onDeactiveEvt += OnDeactiveEquipment; m_TwoHandWeaponHold.onActiveEvt += OnActiveEquipment; m_TwoHandWeaponHold.onDeactiveEvt += OnDeactiveEquipment; m_GunHold.onActiveEvt += OnActiveEquipment; m_GunHold.onDeactiveEvt += OnDeactiveEquipment; m_BowHold.onActiveEvt += OnActiveEquipment; m_BowHold.onDeactiveEvt += OnDeactiveEquipment; m_AimEquipHold.onActiveEvt += OnActiveEquipment; m_AimEquipHold.onDeactiveEvt += OnDeactiveEquipment; if (null != m_MotionMgr) { m_MotionMgr.onActionEnd += OnActionEnd; m_MotionMgr.AddAction(m_HandChangeHold); m_MotionMgr.AddAction(m_HandChangePutOff); m_MotionMgr.AddAction(m_SwordAttack); m_MotionMgr.AddAction(m_TwoHandWeaponHold); m_MotionMgr.AddAction(m_TwoHandWeaponPutOff); m_MotionMgr.AddAction(m_TwoHandWeaponAttack); m_MotionMgr.AddAction(m_SheildHold); m_MotionMgr.AddAction(m_GunHold); m_MotionMgr.AddAction(m_GunPutOff); m_MotionMgr.AddAction(m_GunFire); m_MotionMgr.AddAction(m_GunReload); m_MotionMgr.AddAction(m_GunMelee); m_MotionMgr.AddAction(m_BowHold); m_MotionMgr.AddAction(m_BowPutOff); m_MotionMgr.AddAction(m_BowShoot); m_MotionMgr.AddAction(m_BowReload); m_MotionMgr.AddAction(m_AimEquipHold); m_MotionMgr.AddAction(m_AimEquipPutOff); m_MotionMgr.AddAction(m_DigTerrain); m_MotionMgr.AddAction(m_Fell); m_MotionMgr.AddAction(m_JetPackAction); m_MotionMgr.AddAction(m_ParachuteAction); m_MotionMgr.AddAction(m_GliderAction); m_MotionMgr.AddAction(m_DrawWater); m_MotionMgr.AddAction(m_PumpWater); m_MotionMgr.AddAction(m_ThrowGrenade); m_MotionMgr.AddAction(m_FlashLightAction); m_MotionMgr.AddAction(m_RopeGunAction); } }