private void updateHovering() { if (isAppliedChanged()) { draggingBuff = null; } }
void Start() { buffCardModel = GameObjectHelper.getScriptFromModel <BuffCardModel>(gameObject); card = buffCardModel.transform.parent.gameObject; sequence = DOTween.Sequence(); draggable = GetComponent <Draggable>(); }
void Start() { model = GameObjectHelper.getScriptFromModel <BuffCardModel>(gameObject); buffOverlayManager = GetComponentInChildren <BuffOverlayManager>(); spriteRenderer = GetComponent <SpriteRenderer>(); seq = DOTween.Sequence(); }
private void OnTriggerExit2D(Collider2D collision) { buffCardModel = GameObjectHelper.getScriptFromModel <BuffCardModel>(collision.gameObject); if (buffCardModel && buffCardModel.State == BuffCardState.draggingOverDiscardApply) { discardToApply = null; buffCardModel.State = BuffCardState.dragging; } }
private void OnTriggerEnter2D(Collider2D collision) { buffCardModel = GameObjectHelper.getScriptFromModel <BuffCardModel>(collision.gameObject); if (buffCardModel && buffCardModel.State == BuffCardState.dragging && actionCardModel.canApplyBuff()) { discardToApply = collision.transform.parent.gameObject; buffCardModel.State = BuffCardState.draggingOverDiscardApply; } }
private void OnTriggerExit2D(Collider2D collision) { BuffCardModel buff = collision.transform.parent.GetComponentInChildren <BuffCardModel>(); if (buff && draggingBuff != null) { draggingBuff = null; actionCardModel.IsHovering = false; actionCardModel.IsHoveringApplied = false; } }
private void OnTriggerEnter2D(Collider2D collision) { BuffCardModel buff = collision.transform.parent.GetComponentInChildren <BuffCardModel>(); if (buff) { if (buff.isDragging()) { draggingBuff = buff; actionCardModel.IsHoveringApplied = true; } } }
private void OnTriggerExit2D(Collider2D collision) { if (!monsterCardModel.isApplied()) { buff = collision.transform.parent.GetComponentInChildren <BuffCardModel>(); if (buff && buff.isDraggingOverApplied()) { buff.State = BuffCardState.dragging; buff = null; monsterCardModel.IsHovering = false; monsterCardModel.IsHoveringApplied = false; } } }
private void Update() { if (handModel.getDraggingModel() != null) { Debug.Log(handModel.getDraggingModel().State); } int currentNumOfCards = handModel.Cards.Count; // find card that is currently being dragged // dragging is set in BuffModelController handModel.setDraggingCard(); // removed dragging card from hand int draggingCardIndex = handModel.getIndexOfDraggingCard(); if (draggingCardIndex != -1) { handModel.Cards.RemoveAt(draggingCardIndex); } if (handModel.DraggingCard) { BuffCardModel buff = handModel.getDraggingModel(); // return card back to hand if not dragging or applied if (buff.State == BuffCardState.movingToHand) { // insert dragging card back into hand list handModel.Cards.Insert(handModel.getGameObjectIndex(handModel.DraggingCard.gameObject), buff.transform.parent.gameObject); updateHandFanning(); handModel.DraggingCard = null; } // clear reference if card is applied else if (buff.State != BuffCardState.dragging && !buff.isDraggingOverApplied()) { updateHandFanning(); appliedCardsMap.Add(buff.GetInstanceID(), buff); handModel.DraggingCard = null; } } // update fanning when cards in hand number changes checkIfAppliedCardsMovingBackToHand(); if (previousNumOfCards != currentNumOfCards) { updateHandFanning(); previousNumOfCards = currentNumOfCards; } }
// moves all buffs, including buffs with state movingToHand, to hand, and adds fanning void updateHandFanning() { List <Vector3> positions = new List <Vector3>(); float diff = rightBounds.x - leftBounds.x; float spacing = diff / (handModel.Cards.Count + 1); float increments = spacing; handModel.Cards.ForEach(card => { BuffCardModel buff = card.transform.GetComponentInChildren <BuffCardModel>(); // dont set the dragged card's state if (buff.State != BuffCardState.movingToHand) { buff.State = BuffCardState.fanning; } Vector3 target = new Vector3(leftBounds.x + increments, leftBounds.y, leftBounds.z); card.transform.DOLocalMove(target, duration).OnComplete(() => backToHandCallback(buff)); increments += spacing; }); }
private void updateAppliedBuffs() { if (isAppliedChanged()) { List <Vector3> positions = new List <Vector3>(); float diff = rightBounds.x - leftBounds.x; float spacing = diff / (actionCardModel.getNumberOfApplied() + 1); float increments = spacing; List <GameObject> appliedCards = new List <GameObject>(actionCardModel.BuffsToApply); appliedCards.AddRange(actionCardModel.DiscardsToApply); appliedCards.ForEach(buff => { Vector3 target = new Vector3(leftBounds.x + increments, leftBounds.y, leftBounds.z); buff.transform.localPosition = target; increments += spacing; }); actionCardModel.IsBuff = false; draggingBuff = null; } }
private void OnTriggerEnter2D(Collider2D collision) { if (!monsterCardModel.isApplied()) { buff = collision.transform.parent.GetComponentInChildren <BuffCardModel>(); if (buff && buff.isDragging()) { //transform.parent.HoverPunch(); monsterCardModel.IsHoveringApplied = true; if (monsterCardModel.State == MonsterCardState.active) { buff.State = BuffCardState.draggingOverDrawThreeApply; } else if (monsterCardModel.State == MonsterCardState.left) { buff.State = BuffCardState.draggingOverSwitchLeftApply; } else if (monsterCardModel.State == MonsterCardState.right) { buff.State = BuffCardState.draggingOverSwitchRightApply; } } } }
// callback from tween void backToHandCallback(BuffCardModel buff) { buff.State = BuffCardState.inHand; }