public void AddNewCardToBag(ConcreteCard card) { GameObject bagSlotGO = Instantiate(_bagSlotPrefab) as GameObject; bagSlotGO.GetComponent <UIDragScrollView> ().scrollView = _scrollView; BagSlot bagSlot = bagSlotGO.GetComponent <BagSlot> (); bagSlot.LoadConcreteCard(card); _grid.AddChild(bagSlotGO.transform); bagSlotGO.transform.localScale = Vector3.one; _bagSlots.Add(bagSlot); }
public void SlotClick(BagSlot bagSlot) { if (_selectBattleSlot == null) { if (_selectBagSlot != null) { _selectBagSlot.Deselect(); } _selectBagSlot = bagSlot; _selectBagSlot.Select(); } else { _selectBattleSlot.Deselect(); ConcreteCard first = _selectBattleSlot.concreteCard, second = bagSlot.concreteCard; int index = _selectBattleSlot.Index; _player.playCardSet [index] = second; _player.cardBag.Remove(second); if (first != null) { _player.cardBag.Add(first); } HOTween.To(_selectBattleSlot.slotBody, _fadeDuration, new TweenParms().Prop("alpha", 0f).Ease(EaseType.Linear).OnStart(() => { _shieldPanel.Activate(); }).OnComplete(() => { _selectBattleSlot.LoadConcreteCard(second); HOTween.To(_selectBattleSlot.slotBody, _fadeDuration, new TweenParms().Prop("alpha", 1f).Ease(EaseType.Linear).OnComplete(() => { _shieldPanel.Deactivate(); _selectBattleSlot = null; })); })); Debug.Log(bagSlot.slotBody == null); HOTween.To(bagSlot.slotBody, _fadeDuration, new TweenParms().Prop("alpha", 0f).Ease(EaseType.Linear).OnStart(() => { _shieldPanel.Activate(); }).OnComplete(() => { if (first != null) { bagSlot.LoadConcreteCard(first); HOTween.To(bagSlot.slotBody, _fadeDuration, new TweenParms().Prop("alpha", 1f).Ease(EaseType.Linear).OnComplete(() => { _shieldPanel.Deactivate(); })); } else { _shieldPanel.Deactivate(); _grid.RemoveChild(bagSlot.transform); _bagSlots.Remove(bagSlot); Destroy(bagSlot.gameObject); } })); } }