/// <summary> /// 拖拽开始 /// </summary> /// <param name="eventData"></param> public void OnBeginDrag(PointerEventData eventData) { if (!active) { return; } //如果光标层已经存在物体,则无法触发拖拽 if (InventoryModule.Instance.PickUpEntity.GetComponentInChildren <ItemEntity>() != null) { return; } switch (itemState) { case ItemState.Common: cacheSlot = transform.parent.GetComponent <SlotEntity>() ?? throw new Exception("null"); //缓存当前格子,拖拽失败时返回 InventoryModule.Instance.PickUpEntity.SetPickUpItem(this); //设置当前跟随鼠标 break; case ItemState.Instore: cacheSlot = transform.parent.GetComponent <SlotEntity>() ?? throw new Exception("null"); //缓存当前格子,拖拽失败时返回 var item = ItemModule.Instance.GetItemEntity(data.id); //复制商店的物品 item.itemState = ItemState.Instore; //设置复制品的状态 InventoryModule.Instance.PickUpEntity.SetPickUpItem(this); //将商店的物品放在光标层 cacheSlot.AddItem(item); //将复制品放商店 break; case ItemState.Check: break; } }
//************************************************************************************** //Basic Targeting Schemes protected SlotEntity OrderBasedTargeting(string[] choices) { SlotEntity chosen = null; bool found = false; for (int i = 0; i < choices.Length && (!found); i++) { SlotEntity possibleChoice; if (side) { possibleChoice = Slot.ENEMY_SLOTS[choices[i]].GetTarget(); } else { possibleChoice = Slot.ALLY_SLOTS[choices[i]].GetTarget(); } if (possibleChoice != null) { chosen = possibleChoice; found = true; } } return(chosen); }
public override Vector2 GetLocation(SlotEntity s) { if (s == entity) { return(transform.position); } return(new Vector2(Random.Range(-1, 1) * width + transform.position.x, Random.Range(-1, 1) * Slot.WIGGLE_ROOM + transform.position.y)); }
void OnCollisionEnter2D(Collision2D coll) { if (active) { SlotEntity target = coll.gameObject.GetComponent <SlotEntity>(); if (target && target.side != friendly) { target.TakeAttack(attack); } } }
private void FallChipsToColumnBellow(HashSet <int> columnToUpdate) { for (int i = 0; i < BoardHeight; i++) { // rowIndex * numberOfColumns + columnIndex. int previousSlotIndex = i; for (int j = 0; j < BoardWidth; j++) { // rowIndex * numberOfColumns + columnIndex. int index = (j * BoardWidth) + i; Entity currentSlotEntity = _generatedSlots[index]; Entity previousSlotEntity = _generatedSlots[previousSlotIndex]; SlotEntity currentSlot = _entityManager.GetComponentData <SlotEntity>(currentSlotEntity); SlotEntity previousSlot = _entityManager.GetComponentData <SlotEntity>(previousSlotEntity); if (previousSlot.m_Chip == Entity.Null && currentSlot.m_Chip != Entity.Null) { var fallingChip = currentSlot.m_Chip; _entityManager.SetComponentData(currentSlotEntity, new SlotEntity { m_Chip = Entity.Null }); _entityManager.SetComponentData(previousSlotEntity, new SlotEntity { m_Chip = fallingChip }); if (!_entityManager.HasComponent <MoveToTargetComponent>(fallingChip)) { _entityManager.AddComponent(fallingChip, typeof(MoveToTargetComponent)); } else { Debug.LogError($"{nameof(MoveToTargetComponent)} Component already exist"); } _entityManager.SetComponentData(fallingChip, new MoveToTargetComponent { Target = previousSlotEntity }); previousSlotIndex += BoardWidth; Debug.Log("Adding move to target component"); } else if (previousSlot.m_Chip != Entity.Null) { previousSlotIndex = index; } } } }
protected void btnSave_Click(object sender, EventArgs e) { if (ValidateSlot()) { var lst = GetSlotCosts; //foreach (var t in lst) //{ //if(new OnHireBLL().ValidateSlotOnHire(t.ContainerNo, rdTransactionType.SelectedValue)){ // ScriptManager.RegisterStartupScript(this,this.GetType(),DateTime.Now.Ticks.ToString(),string.Format("alert('{0} already exist in Table');",t.ContainerNo),true); //return; //} //} //var feu = CountFEU(); ISlot slots = new SlotEntity { CreatedOn = DateTime.Now, CompanyID = 1,// user.CompanyId ModifiedOn = DateTime.Now, SlotOperatorID = ddlOperator.SelectedValue.ToInt(), LineID = ddlLineCode.SelectedValue.ToInt(), PODID = hdnPOD.Value.ToInt(), POLID = hdnPOL.Value.ToInt(), MovOrigin = ddlTerm1.SelectedValue.ToInt(), MovDestination = ddlTerm2.SelectedValue.ToInt(), EffectDt = txtEffectDate.Text.ToDateTime(), CreatedBy = user.Id, ModifiedBy = user.Id, }; var retrunVal = 0; if (ViewState["SlotId"] != null) { slots.SlotID = ViewState["SlotId"].ToInt(); retrunVal = new SlotBLL().SaveSlot(slots, 1); } else { retrunVal = new SlotBLL().SaveSlot(slots, 0); } if (retrunVal > 0) { Session.Remove("ISlotCost"); ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Saved successfully.');", true); Response.Redirect("ManageSlotCost.aspx"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Error! Please try again.')", true); } } }
//Move a new entity into this slot public override void moveEntity(SlotEntity entity_in) { if (entity_in is SingularEntity && entity_in != entity) { //Bump off last entity if (entity != null) { entity.Bump(entity_in.container); } //Set new entity entity_in.container = this; entity = (SingularEntity)entity_in; } else { minorEntities.Add(entity_in); entity_in.container = this; } entity_in.side = friendly; }
public override void moveEntity(SlotEntity entity_in) { entities.Add(entity_in); entity_in.side = friendly; }
/// <summary> /// 储存物品 假设每次最多存入一组物品 /// </summary> /// <param name="item"></param> /// <returns>剩余物品</returns> public virtual ItemEntity SetItem(ItemEntity item) { if (item == null || item.data == null) { throw new Exception("null"); } //无法堆叠的物品 if (item.data.capacity == 1) { //创建新itemUI SlotEntity s = FindSlot(); if (s == null) { Debug.Log("没有储存空间"); return(item); } s.AddItem(item);//将物品放置在格子上 } //是否存在未满相同id物品 else { var slotEntity = FindSlotById(item.data.id);//查找相同id的格子 //存在没有装满的相同id物品 if (slotEntity != null && slotEntity.data != null) { //存入item后 没有超过最大堆叠 if (slotEntity.data.amount + item.data.amount <= slotEntity.data.capacity) { slotEntity.data.amount += item.data.amount; slotEntity.OnRefresh();//刷新数据 item.OnRefresh(); } //超过了最大堆叠 else { item.data.amount -= item.data.capacity - slotEntity.data.amount; //传入的物品数量减少 slotEntity.data.amount = item.data.capacity; //格子中存满 slotEntity.OnRefresh(); //刷新数据 item.OnRefresh(); //创建新itemUI SlotEntity s1 = FindSlot();//没有位置了 if (s1 == null) { return(item); } s1.AddItem(item);//存入+刷新 } } //不存在未装满的相同id物品 else { var s = FindSlot(); if (s == null) { return(item); } s.AddItem(item); } } return(null); }
//Return a location suitable for the given SlotEntity public abstract Vector2 GetLocation(SlotEntity s);
//Move an entity to this slot, swapping if necessary public abstract void moveEntity(SlotEntity entity_in);
protected void FrontFirstAttack(Attack a) { SlotEntity chosenTarget = FrontFirstTargeting(); chosenTarget.TakeAttack(a); }