public void OnEnable() { swapAbility = GetComponent <ISpriteSwaperAbility>(); if (swapAbility != null) { hasSwapAbility = true; } cardFlipAbility = GetComponent <ICardFlipAbility>(); if (cardFlipAbility != null) { hasCardFlipAbility = true; } }
public IEnumerator Test_MoveAbility() { MoverAbilityInternal moverAbility = new MoverAbilityInternal(); GameObject startLocationObject = new GameObject(); startLocationObject.transform.position = new Vector2(0, 0); Locations startLocations = new Locations(startLocationObject.transform, startLocationObject.transform.position, false); GameObject endLocationObject = new GameObject(); endLocationObject.transform.position = new Vector2(0, 20); Locations endLocations = new Locations(endLocationObject.transform, endLocationObject.transform.position, false); IPokerOwner parent = Substitute.For <IPokerOwner>(); parent.speed = 2f; GameObject card = new GameObject("card"); Card po = card.AddComponent <Card>(); ISpriteSwaperAbility swaperAbility = Substitute.For <ISpriteSwaperAbility>(); ICardFlipAbility cardFlipAbility = Substitute.For <ICardFlipAbility>(); moverAbility.Move(new List <IPokerObject>() { po as IPokerObject }, new List <Locations>() { startLocations }, new List <Locations>() { endLocations }, parent, true, true, swaperAbility, cardFlipAbility); yield return(new WaitForSeconds(parent.speed + 0.5f)); Assert.AreEqual(endLocationObject.transform.position, po.transform.position); }
public void Move(List <IPokerObject> objectsToMove, List <Locations> startLocations, List <Locations> endLocations, IPokerOwner parent, bool hasSwapAbility, bool hasCardFlipAbility, ISpriteSwaperAbility swapAbility, ICardFlipAbility cardFlipAbility) { if (objectsToMove.Count <= endLocations.Count && objectsToMove.Count <= startLocations.Count) { for (int i = 0; i < objectsToMove.Count; i++) { if (!endLocations[i].isFilled) { var endObject = endLocations[i]; var ObjectToMove = objectsToMove[i].GetPokerObject; ObjectToMove.transform.localPosition = new Vector2(startLocations[i].location.x, startLocations[i].location.y); ObjectToMove.transform.DOLocalMove(endLocations[i].location, parent.speed).OnComplete(() => { endObject.isFilled = parent.fillUp; if (hasSwapAbility && !parent.dontSwap && parent.dontFlip) { swapAbility.SwapSprites(ObjectToMove, parent.isRealPlayer); } if (hasCardFlipAbility && parent.isRealPlayer && !parent.dontFlip) { cardFlipAbility.FlipCards(ObjectToMove); } //parent.action(); }).SetEase(Ease.Linear);//set ease type for movement } } } }