public IEnumerator Test_SpriteFlipAbility() { CardFlipAbilityInternal cardFlipAbility = new CardFlipAbilityInternal(); ISpriteSwaperAbility spriteSwaperAbility = Substitute.For <ISpriteSwaperAbility>(); GameObject card = new GameObject("card"); Card po = card.AddComponent <Card>(); Image img = card.AddComponent <Image>(); Texture2D tex = new Texture2D(10, 10); Sprite sprf = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f); sprf.name = "front Sprite"; Sprite sprb = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f); sprb.name = "back Sprite"; po.front = sprf; po.back = sprb; po.View = img; Sprite sprDefault = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f); sprDefault.name = "default Sprite"; img.sprite = sprDefault; float speed = 1f; cardFlipAbility.FlipCards(card, false, spriteSwaperAbility, speed); yield return(new WaitForSeconds(speed)); Assert.AreEqual(card.transform.localScale.x, 0); yield return(new WaitForSeconds(speed)); Assert.AreEqual(card.transform.localScale.x, 1); }
private void Start() { swapAbility = GetComponent <ISpriteSwaperAbility>(); if (swapAbility != null) { hasSwapAbility = true; } }
public void OnEnable() { swapAbility = GetComponent <ISpriteSwaperAbility>(); if (swapAbility != null) { hasSwapAbility = true; } cardFlipAbility = GetComponent <ICardFlipAbility>(); if (cardFlipAbility != null) { hasCardFlipAbility = true; } }
public void FlipCards(GameObject real, bool hasSwapAbility, ISpriteSwaperAbility swapAbility, float moveSpeed) { real.transform.DOScaleX(0, moveSpeed).OnComplete(() => { if (hasSwapAbility) { swapAbility.SwapSprites(real, true); } real.transform.DOScaleX(1, moveSpeed).OnComplete(() => { }); }); }
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 } } } }