Esempio n. 1
0
        public void DropCard(CardBehaviour droppingCard, Vector3 position)
        {
            // the position of the laying cardData will be position of the deck
            Vector3 pos = transform.parent.position;

            // destroy laying cardData (this)
            Destroy(transform.parent.gameObject);

            // destroy dropping cardData (parameter)
            Destroy(droppingCard.transform.parent.gameObject);

            // create a deck with this 2 cards on a position of laying cardData
            List <Card> cards = new List <Card>();

            if (Input.GetKey(KeyCode.LeftAlt))
            {
                cards.Add(cardBehaviour.ModelData);
                cards.Add(droppingCard.ModelData);
            }
            else
            {
                cards.Add(droppingCard.ModelData);
                cards.Add(cardBehaviour.ModelData);
            }

            cg.SpawnDeck(cards, pos, cardBehaviour.ModelData.IsFaceUp);
        }
Esempio n. 2
0
    /// <summary>
    /// Gets the first card. Where exist this card
    /// </summary>
    public CardBehaviour GetTheFirstCard(CardBehaviour card)
    {
        // TODO: Create the value will be returned.
        CardBehaviour paramReturn = null;

        // TODO: Create the list of cards.
        List <CardBehaviour> paramCheck;

        for (int i = 0; i < zoneCards.Length; i++)
        {
            // TODO: Check if it exists.
            if (cards.ContainsKey(Enums._IdTransformCard [(int)zoneCards[i].Id]))
            {
                // TODO: Try to get the value of cards.
                if (cards.TryGetValue(Enums._IdTransformCard [(int)zoneCards[i].Id], out paramCheck))
                {
                    // TODO: Check if it has any card.
                    if (paramCheck.Count > 0 && paramCheck.Contains(card))
                    {
                        // TODO: Set the value will be returned.
                        paramReturn = paramCheck [0];

                        // TODO: Break the function.
                        break;
                    }
                }
            }
        }

        // TODO: Return the value.
        return(paramReturn);
    }
Esempio n. 3
0
    /// <summary>
    /// Returns to pool.
    /// </summary>
    /// <param name="param">Parameter.</param>
    public void ReturnToPool(CardBehaviour param)
    {
        // TODO: Check if this is not null.
        if (param != null)
        {
            // TODO: Disable the gameobject.
            //param.gameObject.SetActive (false);

            // TODO: Check if this exists in the list. Just remove this param.
            if (ItemProperties.Contains(param))
            {
                LogGame.DebugLog(string.Format("[Pool System] Card Was Found {0}", param.name));

                // TODO: Remove this param.
                ItemProperties.Remove(param);
            }

            // TODO: Set default parent transform.
            param.transform.SetParent(transform);

            param.transform.localPosition = Contains.Vector3Null;

            // TODO: Add this param to the list of cards.
            ItemProperties.Add(param);
        }
    }
Esempio n. 4
0
 private void UnregisterCardEvents(CardBehaviour card)
 {
     card.CursorEnter -= Card_CursorEnter;
     card.CursorExit  -= Card_CursorExit;
     card.CursorDown  -= Card_CursorDown;
     card.CursorUp    -= Card_CursorUp;
 }
Esempio n. 5
0
 private void RegisterCardEvents(CardBehaviour card)
 {
     card.CursorEnter += Card_CursorEnter;
     card.CursorExit  += Card_CursorExit;
     card.CursorDown  += Card_CursorDown;
     card.CursorUp    += Card_CursorUp;
 }
Esempio n. 6
0
    private void Card_CursorUp(CardBehaviour sender)
    {
        _cards.Remove(sender);

        var index = GetCardIndexWithPosition(sender.RectTransform.position);

        if (index > 0)
        {
            _cards.Insert(index, sender);
        }
        else
        {
            // If we find no where to put card, put it back to the original place
            _cards.Insert(_lastSelectionIndex, sender);
        }

        _selected = null;

        if (_moveCardCoroutine != null)
        {
            StopCoroutine(_moveCardCoroutine);
            _moveCardCoroutine = null;
        }

        ReorderCards();
    }
Esempio n. 7
0
        public override bool Drop(BaseObjectBehaviour droppingObj, Vector3 position)
        {
            CardBehaviour droppingCard = droppingObj as CardBehaviour;

            if (droppingCard != null)
            {
                if (!droppingCard.ModelData.allowStacking)
                {
                    return(false);
                }

                DropCard(droppingCard, position);
                return(true);
            }

            DeckBehaviour droppingDeck = droppingObj as DeckBehaviour;

            if (droppingDeck != null)
            {
                DropDeck(droppingDeck, position);
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
    private void TakeCard(BattleCard card, string guid)
    {
        Debug.Log("TC2");
        CardBehaviour cardBehaviour = AddCardToDeck(card, guid);

        CardsLayoutManager.Instance.MoveCardTo(cardBehaviour, CardsLayoutManager.SlotType.PlayerHand);
    }
Esempio n. 9
0
 private void Awake()
 {
     _camera        = Camera.main;
     _canvasGroup   = GetComponent <CanvasGroup>();
     _cardBehaviour = GetComponent <CardBehaviour>();
     shine.enabled  = false;
 }
Esempio n. 10
0
    /// <summary>
    /// Sort random position of all the cards in the array.
    /// </summary>
    public static List <CardBehaviour> SortRandom(List <CardBehaviour> paramIn)
    {
        // TODO: Create the list of cards.
        var paramOut = new List <CardBehaviour> (paramIn);

        // TODO: Create the list of cards will be returned.
        var paramReturn = new List <CardBehaviour> ();

        // TODO: Create the cache of card.
        CardBehaviour card = null;

        // TODO: Loop the cards to get random the values.
        while (paramOut.Count > 0)
        {
            // TODO: Get the value from random in the list of cards.
            card = paramOut [Random.Range(0, paramOut.Count)];

            // TODO: Remove the current card from the list.
            paramOut.Remove(card);

            // TODO: Add the card to the list will be returned.
            paramReturn.Add(card);
        }

        // TODO: Return the list of cards.
        return(paramReturn);
    }
    public void takeInHitSquares(CardBehaviour incCard, float widthOfall, float heightOfall, float widthOfHitSquaresT, float heightOfHitSquaresT)
    {
        //hitSquares = newHitSquares;
        card = incCard;
        heightOfAllHitSquares = heightOfall;
        widthOfAllHitSquares  = widthOfall;

        widthOfHitSquares  = widthOfHitSquaresT;
        heightOfHitSquares = heightOfHitSquaresT;

        startingV3 = card.transform.localPosition;
        gameObject.transform.localPosition = card.transform.localPosition;

//		GameObject GameControllerTemp = GameObject.FindWithTag("GameController");
//		if (GameControllerTemp != null) {
//			//PlayArea = playAreaTemp;
//			startingV3 = GameControllerTemp.transform.localPosition;}
//		if(GameControllerTemp == null){
//			Debug.Log ("Cannot find 'GameController'object");}

//		GameObject playAreaT = GameObject.FindWithTag("PlayArea");
//		if(playAreaT != null){
//			startingV3 = playAreaT.GetComponent<GridMaker>().firstBoxCord;}
//		if(playAreaT == null){
//			Debug.Log ("Cannot find 'PlayArea'object");}
    }
Esempio n. 12
0
 public void AddCard(CardBehaviour card)
 {
     Hand.AddCard(card.Card);
     card.transform.SetParent(transform);
     Cards.Add(card);
     StartCoroutine(AdjustCardPositions(card, IsPlayerHand));
 }
Esempio n. 13
0
    private void GetEventCard(int cardId, string guid)
    {
        EventCardWrapper wrapper       = new EventCardWrapper((EventCard)DefaultResources.GetCardById(cardId, DefaultResources.CardType.Event), guid);
        CardBehaviour    cardBehaviour = CardsLayoutManager.Instance.CreateCardIn(wrapper, CardsLayoutManager.SlotType.EventDeck);

        CardsLayoutManager.Instance.MoveCardTo(cardBehaviour, CardsLayoutManager.SlotType.EventDrop);
    }
Esempio n. 14
0
    private IEnumerator MoveCard(CardBehaviour card)
    {
        _lastSelectionIndex = _cards.FindIndex((x) => x == card);

        int prevIndex = _lastSelectionIndex;

        while (true)
        {
            var cursorPosition = InputHelper.GetCursorPosition();

            card.SetTarget(cursorPosition, Quaternion.identity);

            var index = GetCardIndexWithPosition(cursorPosition);
            if (index >= 0 && index != prevIndex)
            {
                _cards.Remove(card);
                _cards.Insert(index, card);
                ReorderCards();
                card.RectTransform.SetSiblingIndex(_cards.Count);
                prevIndex = index;
            }

            yield return(null);
        }
    }
Esempio n. 15
0
    private void CheckMouse()
    {
        Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        //float fx = worldPos.x + 7.5f;
        //int y = (int) Mathf.Floor(worldPos.y - 1.5f)*-1;

        //if (y%2 != 0) {
        //    fx += 0.5f;
        //}

        //int x = (int) Mathf.Floor(fx);

        MapPosition gridPosition = CombatManager.WorldToGrid(worldPos);

        int x = gridPosition.x;
        int y = gridPosition.y;


        // TODO: every second row
        if (0 <= x && x <= 15)
        {
            if (selectedCard != null && Input.GetMouseButtonDown(0))
            {
                if (CanUseSpell(selectedCard.GetBaseCard(), x, y))
                {
                    UseCard(selectedCard.GetBaseCard(), x, y);
                    Destroy(selectedCard.gameObject);
                }
                // Deselect card on failed attempt for now
                selectedCard = null;
            }
        }
    }
Esempio n. 16
0
    /// <summary>
    /// Gets the identifier the list of cards.
    /// </summary>
    public Enums.IdTransformCard GetIdTransform(CardBehaviour paramIn)
    {
        // TODO: Create the param will be returned.
        Enums.IdTransformCard paramReturn = Enums.IdTransformCard.None;

        // TODO: Get the number of zone.
        int count = zoneCards.Length;

        // TODO: Create the list of cards.
        List <CardBehaviour> paramOut;

        // TODO: Loop to get the id.
        for (int i = 0; i < count; i++)
        {
            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)zoneCards[i].Id], out paramOut))
            {
                // TODO: Check if the card exists.
                if (paramOut.Contains(paramIn))
                {
                    // TODO: Get the value will be returned.
                    paramReturn = zoneCards[i].Id;

                    // TODO: Break the functions.
                    break;
                }
            }
        }

        // TODO: Return the value.
        return(paramReturn);
    }
Esempio n. 17
0
    /// <summary>
    /// Gets the first card. From the id of card.
    /// </summary>
    public CardBehaviour GetTheFirstCard(Enums.IdTransformCard id)
    {
        // TODO: Create the value will be returned.
        CardBehaviour paramReturn = null;

        // TODO: Check if it exists.
        if (cards.ContainsKey(Enums._IdTransformCard [(int)id]))
        {
            // TODO: Create the list of cards.
            List <CardBehaviour> paramCheck;

            // TODO: Try to get the value of cards.
            if (cards.TryGetValue(Enums._IdTransformCard [(int)id], out paramCheck))
            {
                // TODO: Check if it has any card.
                if (paramCheck.Count > 0)
                {
                    // TODO: Set the value will be returned.
                    paramReturn = paramCheck [0];
                }
            }
        }

        // TODO: Return the value.
        return(paramReturn);
    }
Esempio n. 18
0
 // Use this for initialization
 void Start()
 {
     anim        = this.GetComponent <Animator> ();
     cardBhav    = this.GetComponent <CardBehaviour> ();
     audioSource = GameObject.FindWithTag("GameController").GetComponent <AudioSource>();
     changeVarSE = Resources.Load("fm004") as AudioClip;
 }
Esempio n. 19
0
		/// <summary>
		/// Unlocks the last card from all the arrays.
		/// </summary>
		public void UnlockLastCard()
		{
			// TODO: Create the value will be unlocked.
			CardBehaviour paramCheck = null;

			// TODO: Loop to check all the arrays.
			for (int i = 0; i < PlayingZone.Instance.zoneCards.Length; i++)
			{

				// TODO: Get the default of value.
				paramCheck = PlayingZone.Instance.GetTheLastCard(PlayingZone.Instance.zoneCards[i].Id);

				// TODO: Check it don't equal null.
				if (paramCheck != null)
				{

					// TODO: Records Unlock
					UndoSystem.Instance.Record(Enums.Zone.Play, Enums.IdTransformCard.None, paramCheck ,paramCheck.IsUnlocked(), true);


					// TODO: Unlock this cards.
					paramCheck.Unlock(true);
				}
			}
		}
Esempio n. 20
0
 // On drag event we want to move the image of the
 // card around in  order to give the player visual
 // feedback.
 public static void OnDrag(PointerEventData eventData, CardBehaviour handled)
 {
     if (handled == handling)
     {
         OnDrag(eventData);
     }
 }
Esempio n. 21
0
    void SelectCard()
    {
        if (gamepad.GetButtonDown(attack))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Attack)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Attack];
                selectedCard.Select();
            }
        }

        if (gamepad.GetButtonDown(shield))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Shield)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Shield];
                selectedCard.Select();
            }
        }

        if (gamepad.GetButtonDown(backstep))
        {
            if (selectedCard != null)
            {
                selectedCard.Deselect();
            }

            if (selectedCard != null && selectedCard.cardNature == Cards.Backstep)
            {
                selectedCard = null;
            }

            else
            {
                selectedCard = cardDico[Cards.Backstep];
                selectedCard.Select();
            }
        }
    }
Esempio n. 22
0
    private CardBehaviour AddCardToDeck(BattleCard card, string guid)
    {
        BattleCardWrapper wrapper       = new BattleCardWrapper(card, guid);
        CardBehaviour     cardBehaviour = CardsLayoutManager.Instance.CreateCardIn(wrapper, CardsLayoutManager.SlotType.Nowhere);

        CardsLayoutManager.Instance.MoveCardTo(cardBehaviour, CardsLayoutManager.SlotType.PlayerDeck, null, true);
        return(cardBehaviour);
    }
Esempio n. 23
0
 public void AddToFlipedList(CardBehaviour card)
 {
     CardDealerController.FlipedCards.Add(card);
     if (CardDealerController.FlipedCards.Count == _dataCountFlipCardATime)
     {
         HandleFlipedCards();
     }
 }
Esempio n. 24
0
    void Start()
    {
        currentCard = carouselCardBehaviours[currentCardID];

        ActivateFirstCard();
        ShowCurrentCardTextInfo();
        SetNewCardProfilePanelUI();
    }
Esempio n. 25
0
    public void AddCard(CardBehaviour card)
    {
        _cards.Add(card);
        card.RectTransform.SetParent(_cardsParent, true);
        ReorderCards();

        RegisterCardEvents(card);
    }
Esempio n. 26
0
 public RectTransform GetDisposeHolder(CardBehaviour Behaviour)
 {
     if (typeof(ObstacleBehaviour).IsAssignableFrom(Behaviour.GetType()))
     {
         return(ObstacleDisposeHolder);
     }
     return(GraveyardPlaceHolder);
 }
Esempio n. 27
0
    private void Card_CursorDown(CardBehaviour sender)
    {
        sender.ToggleHighlight(false);
        _highlighted = null;
        _selected    = sender;

        _moveCardCoroutine = StartCoroutine(MoveCard(sender));
    }
Esempio n. 28
0
 public void RemoveCard(CardBehaviour card)
 {
     if (_cards.Remove(card))
     {
         card.RectTransform.SetParent(null, true);
         UnregisterCardEvents(card);
         ReorderCards();
     }
 }
Esempio n. 29
0
 /// <summary>
 /// Removes the card follow.
 /// </summary>
 /// <param name="paramIn">Parameter in.</param>
 public void RemoveCardFollow(CardBehaviour paramIn)
 {
     // TODO: Check if this card exists in the list.
     if (cardFollows.Contains(paramIn))
     {
         // TODO: Remove the card.
         cardFollows.Remove(paramIn);
     }
 }
Esempio n. 30
0
        private void SpawnCard(ICard card)
        {
            CardBehaviour cardInstance = Instantiate(cardPrefab, spawnPosition,
                                                     Quaternion.Euler(0.0f, -180.0f, 0.0f));

            cardInstance.Card           = card;
            cardInstance.snapPosition.y = spawnPosition.y;
            cardInstance.Controller     = this;
        }
Esempio n. 31
0
    public void update(object message)
    {
        //DEL CLICK EN LA CARTA

        if(this.card1 == null){
            this.card1 = ((CardBehaviour)message);
        }
        else{
            this.card2 = ((CardBehaviour)message);
            this.block = true;
            //this.checkMatch(); //Verifico si coinciden las 2 cartas

            StartCoroutine(this.checkMatch());
        }
    }
Esempio n. 32
0
    private IEnumerator checkMatch()
    {
        yield return new WaitForSeconds(0.7f);

        if(card1.id == card2.id){	//HUBO MATCH
            //this.tick.Play();
            this.tick.Play();
            this.winCard.Play();	//Sonido del match
            this.remainingCards-=2;
            this.score+= Level.pointsPerPair;
            this.correct+=1;
            this.updateText(GameCore.REMAINING_TEXT, this.remainingCards);
            this.updateText(GameCore.SCORE_TEXT, this.score);
            this.updateText(GameCore.CORRECT_TEXT, this.correct);
            GameObject.Destroy(this.card1.getSprite());
            GameObject.Destroy(this.card2.getSprite());
        }
        else{	//NO HUBO MATCH
            this.cross.Play();
            this.errors+=1;
            this.updateText(GameCore.WRONG_TEXT, this.errors);
            this.card1.unFlip();
            this.card2.unFlip();
        }
        this.card1=null;
        this.card2=null;

        this.block = false;
    }
Esempio n. 33
0
    private void initValues()
    {
        this.currentLevel=1;
        this.timeLeft = true;
        this.card1 = null;
        this.card2 = null;
        this.remainingCards = 0;
        this.score = 0;
        this.errors = 0;
        this.correct = 0;
        this.currentLevel = 1;
        this.tableSize = 0;
        this.levelCards = new ArrayList();
        this.winCard = new OTSound("winCard");
        this.winCard.Idle();
        this.left = false;
        this.globalTime = 0;

        ExitGame eg = (ExitGame)this.exitCross.GetComponent(typeof(ExitGame));
        eg.setCore(this);
    }