Exemple #1
0
    public void PutACardOnTable(GameObject card, int UniqueID)
    {
        // Set a tag to reflect where this card is
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to tableVisual class
        AddCard(card);

        // Bring card to front while it travels from draw spot to hand
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();
        w.Slot        = 0;
        w.VisualState = VisualStates.Transition;


        // move card to the hand;
        Sequence s = DOTween.Sequence();

        // displace the card so that we can select it in the scene easier.
        s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));
        s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));

        s.OnComplete(() => ChangeLastCardStatusToOnTable(card, w));
    }
Exemple #2
0
    public void TakeCardBackIntoHand(GameObject card)
    {
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to HandVisual class
        AddCard(card);

        // Bring card to front while it travels from draw spot to hand
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();
        w.Slot        = 0;
        w.VisualState = VisualStates.Transition;

        // Confirm that card already has ID
        IDHolder id = card.GetComponent <IDHolder>();

        Debug.Log("Picking up card with ID: " + id.UniqueID);

        Sequence s = DOTween.Sequence();

        s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));
        if (TakeCardsOpenly)
        {
            s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
        }

        s.OnComplete(() => ChangeLastCardStatusToInHand(card, w));
    }
Exemple #3
0
    private void CalculateCardPositions()
    {
        var creaturesOnTable = CreaturesOnTable.Count();

        if (creaturesOnTable == 0)
        {
            return;
        }

        var creaturesGap = tableWidth / (creaturesOnTable + 1);

        creaturesGap = creaturesGap > maxCreaturesGap ? maxCreaturesGap : creaturesGap;

        var leftPadding = ((creaturesOnTable - 1) / 2f) * creaturesGap * -1;
        var i           = 0;

        foreach (var creature in CreaturesOnTable)
        {
            creature.transform.localPosition = new Vector3(leftPadding, 0, 0);

            WhereIsTheCardOrCreature whereIsCreature = creature.GetComponent <WhereIsTheCardOrCreature>();
            whereIsCreature.Slot        = i;
            whereIsCreature.VisualState = owner == AreaPosition.Low ? VisualStates.LowTable : VisualStates.TopTable;

            creature.transform.rotation = Quaternion.identity;
            leftPadding += creaturesGap;
            i++;
        }
    }
Exemple #4
0
    // PRZESUŃ WSZYSTKIE KARTY DO NOWYCH MIEJSC
    void PlaceCardsOnNewSlots()
    {
        //Sprawdza wszystkie elementy typu GameObject, które znajdują się w CardsInHand
        //Pierwszy argument to zmienna do której zostanie przypisana wartość listy
        // "in" standardowo wykorzystuje się w funkcji foreach
        // CardsInHand to lista po której będą sprawdzane obiekty
        foreach (GameObject g in CardsInHand)
        {
            // przenieś kartę do nowego slotu
            // Na aktualnym obiekcie "g" odczytuje jego pozycję (transform) i przenosi go do nowej pozycji po osi X (DOLocalMoveX)
            ///DOLocalMoveX to funkcja która pochodzi z dołączonej biblioteki DOTWEEN
            // Pierwszy parametr tej funkcji pobiera pozycję obiektu na osi x (slots.Children[CardsInHand.IndexOf(g)]) poprzez .transform.localPosition.x
            ///IndexOf(g) wyszukuje określony obiekt (g) i zwraca liczony od zera indeks pierwszego wystąpienia w obrębie całego CardsInHand
            /// transform.localPosition.x - to pozycja względem pozycji macierzystej po osi X
            /// W tym przypadku pozycją macierzystą jest pozycja slots.Children
            // Drugi parametr funkcji DOLocalMoveX odpowiada za czas w jakim ma nastąpić przesunięcie
            g.transform.DOLocalMoveX(slots.Children[CardsInHand.IndexOf(g)].transform.localPosition.x, 0.3f);

            // zastosuj prawidłową kolejność sortowania i wartość HandSlot na później
            //Inicjalizuje obiekt "w" typu WhereIsTheCardOrCreature
            ///Ogólnie jest to klasa odpowiedzialna za sprawdzanie gdzie znajduje się karta lub stworzenie w grze, więcej opisane w jego skrypcie
            // Przypisuje do "w" wszystkie komponenty, które znajdują się w obiekcie (GameObject) "g", tyle że przypisuje te komponenty
            // Które wymaga klasa WhereIsTheCardOrCreature; to tak jakby przerabiał GameObject na WhereIsTheCardOrCreature
            WhereIsTheCardOrCreature w = g.GetComponent <WhereIsTheCardOrCreature>();

            //WITCOC = WhereIsTheCardOrCreature
            //Pobiera zmienną slot z WITCOC i przypisuje do niego obiekt "g" z CardInHand, wcześniej wyszukany przez - IndexOf()
            w.Slot = CardsInHand.IndexOf(g);
            w.SetHandSortingOrder(); //wywołuje funkcję z WITCOC; funkcja ogólnie ustawia kolejność sortowania w ręce (więcej w jego skrypcie)
        }
    }
Exemple #5
0
    // gives player a new card from a given position
    public void GivePlayerACard(ScriptableObject c, int UniqueID, bool fast = false, bool fromDeck = true)
    {
        GameObject card;

        card = CreateACardAtPosition(c, DeckTransform.position, new Vector3(0f, -179f, 0f));

        // Set a tag to reflect where this card is
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to HandVisual class
        AddCard(card);

        // Bring card to front while it travels from draw spot to hand
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();
        w.Slot        = 0;
        w.VisualState = VisualStates.Transition;

        // pass a unique ID to this card.
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // move card to the hand;
        Sequence s = DOTween.Sequence();

        if (!fast)
        {
            // Debug.Log ("Not fast!!!");
            s.Append(card.transform.DOMove(DrawPreviewSpot.position, GlobalSettings.Instance.CardTransitionTime));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTime));
            }
            else
            {
                s.Insert(0f, card.transform.DORotate(new Vector3(0f, 179f, 0f), GlobalSettings.Instance.CardTransitionTime));
            }
            s.AppendInterval(GlobalSettings.Instance.CardPreviewTime);
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTime));
        }
        else
        {
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
            }
        }

        s.OnComplete(() => ChangeLastCardStatusToInHand(card, w));
    }
Exemple #6
0
    // method to create a new card and add it to the table
    public void AddSpellCardAtIndex(Cards ca, int UniqueID, int index, CardLogic cl, Player p, ICharacter target)
    {
        GameObject card;

        // create a new creature from prefab
        if (target == null)
        {
            card = GameObject.Instantiate(GlobalSettings.Instance.NoTargetSpellCardPrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;
            card.GetComponent <Draggable>().enabled = false;// just can't move when drag should somehow set "Candrag" in DraggingAction to false;
        }
        else
        {
            card = GameObject.Instantiate(GlobalSettings.Instance.TargetedSpellCardPrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;
            card.GetComponent <Draggable>().enabled = false;// just can't move when drag should somehow set "Candrag" in DraggingAction to false;
        }



        // apply the look from CardAsset
        OneCardManager manager = card.GetComponent <OneCardManager>();

        manager.cardAsset = ca;
        manager.ReadCardFromAsset();

        // add tag according to owner
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }

        // parent a new creature gameObject to table slots
        card.transform.SetParent(slots.transform);

        // add a new creature to the list
        CardsOnTable.Insert(index, card);

        // let this Card know about its position
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot        = index;
        w.VisualState = VisualStates.LowTable;

        // add our unique ID to this Card
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // after a new creature is added update placing of all the other creatures
        ShiftSlotsGameObjectAccordingToNumberOfCards();
        PlaceCardsOnNewSlots();

        p.commandsWaitinglist.Add(new TriggerEffectCommand(cl, target, p, p.table));

        // end command execution
        Command.CommandExecutionComplete();
    }
Exemple #7
0
    private void Awake()
    {
        lr = GetComponentInChildren <LineRenderer>();
        lr.sortingLayerName = "Above Everything";
        triangle            = transform.Find("Triangle");
        triangleSR          = triangle.GetComponent <SpriteRenderer>();

        whereIsCard = GetComponentInParent <WhereIsTheCardOrCreature>();
        manager     = GetComponentInParent <OneCardManager>();
    }
Exemple #8
0
    // METODA KTORA DODAJE NOWĄ POSTAC DO TABLE VISUAL SPRAWDZAJĄC PO JEGO INDEKSIE
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        // Tworzy nową postać z preefaba (było już tłumaczone w HandVisual)
        GameObject creature = GameObject.Instantiate(GlobalSettings.Instance.CreaturePrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;

        // Do stworzonej postaci przypisuje to co jest w CardAsset (było tłumaczone w HandVisual)
        OneCreatureManager manager = creature.GetComponent <OneCreatureManager>();

        manager.cardAsset = ca;
        manager.ReadCreatureFromAsset();

        // Ustawienie tagu, aby odzwierciedlić miejsce, w którym znajduje się ta karta
        // card.GetComponentsInChildren<Transform> - to zwrócony komponent typu Transform z obiektu card
        // Chodzi o przypisanie tagu do tego obiektu, a tag znajduje się w klasie Transform (jest to klasa systemowa)
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            // Odwołanie się do tagu z Transform i przypisanie do niego zwróconego łańcucha znaków [ToString()] z "Owner" i dodanie do niego "Card"
            t.tag = owner.ToString() + "Creature";
        }

        // umieszczamy stworzony obiekt "creature" na pozycji rodzica w slocie który jest na TableVisual
        creature.transform.SetParent(slots.transform);

        // Dodajemy stworzenie do listy stworzeń na Table
        CreaturesOnTable.Insert(index, creature);

        // niech to stworzenie zna swoją pozycję xD
        // Zainicjowanie zmiennej w typu WITCOC i przypisanie do niego creature z komponentem pobranym z WITCOC
        WhereIsTheCardOrCreature w = creature.GetComponent <WhereIsTheCardOrCreature>();

        // Odwołanie się do zmiennej Slot w WITCOC i przypisanie mu wartości ze zmiennej index
        w.Slot = index;
        // Sprawdzamy na co ustawiony jest owner, jeśli jest równy parametrowi "Low" z enum AreaPosition to:
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable; // do zmiennej VisualState z klasy WITCOC przypisujemy parametr LowTable z enum VisualStates
        }
        else
        {
            w.VisualState = VisualStates.TopTable; // jeśli nie to do zmiennej przypisujemy TopTable z enum VisualStates
        }
        // Dodaj ID do tego stworzenia
        // Zainicjowanie zmiennej id typu IDHolder i przypisanie do niego creature z dodanym komponentem IDHolder
        IDHolder id = creature.AddComponent <IDHolder>();

        // do UniqueID z klasy IDHolder przypisujemy UniqueID pobrane z funkcji, gdzieś to już tłumaczyłęm czemu tak (chyba w HandVisual)
        id.UniqueID = UniqueID;

        // po dodaniu nowego stwora zaktualizuj rozmieszczenie wszystkich innych stworzeń
        ShiftSlotsGameObjectAccordingToNumberOfCreatures(); // metoda opisana niżej
        PlaceCreaturesOnNewSlots();                         // metoda opisana niżej

        // Zakończ wykonywanie poleceń
        Command.CommandExecutionComplete(); //wywołanie metody z klasy Command
    }
    // method to create a new creature and add it to the table
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        // create a new creature from prefab
        GameObject creature = Instantiate(GlobalSettings.Instance.CreaturePrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;

        // apply the look from CardAsset
        OneCreatureManager manager = creature.GetComponent <OneCreatureManager>();

        manager.cardAsset = ca;
        manager.ReadCreatureFromAsset();

        // add tag according to owner
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Creature";
        }

        // parent a new creature gameObject to table slots
        creature.transform.SetParent(slots.transform);

        // add a new creature to the list
        CreaturesOnTable.Insert(index, creature);

        // let this creature know about its position
        WhereIsTheCardOrCreature w = creature.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot = index;
        if (owner == AreaPosition.Bottom)
        {
            w.VisualState = VisualStates.BottomTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // add our unique ID to this creature
        IDHolder id = creature.AddComponent <IDHolder>();

        id.uniqueID = UniqueID;

        // after a new creature is added update placing of all the other creatures
        ShiftSlotsGameObjectAccordingToNumberOfCreatures();
        PlaceCreaturesOnNewSlots();
        w.SetTableSortingOrder();

        // Angle monster appropriately
        creature.transform.rotation = creature.transform.parent.parent.rotation;

        // end command execution
        Command.CommandExecutionComplete();

        DebugManager.Instance.DebugMessage(string.Format("{0} player played {1} on their field!", owner, ca.name), DebugManager.MessageType.Game, creature);
    }
 void PlaceCardsOnNewSlots()
 {
     foreach (GameObject g in CardsInHand)
     {
         g.transform.DOLocalMoveX(slots.Children[CardsInHand.IndexOf(g)].transform.localPosition.x, 0.3f);
         // apply correct sorting order and HandSlot value for later
         WhereIsTheCardOrCreature w = g.GetComponent <WhereIsTheCardOrCreature>();
         w.Slot = CardsInHand.IndexOf(g);
         w.SetHandSortingOrder();
     }
 }
Exemple #11
0
    void Awake()
    {
        _sr = GetComponent <SpriteRenderer>();
        _lr = GetComponentInChildren <LineRenderer>();
        _lr.sortingLayerName = "AboveEverything";
        _triangle            = transform.Find("Triangle");
        _triangleSr          = _triangle.GetComponent <SpriteRenderer>();

        _manager             = GetComponentInParent <OneCreatureManager>();
        _whereIsThisCreature = GetComponentInParent <WhereIsTheCardOrCreature>();
    }
Exemple #12
0
    void PlaceCardsOnNewSlots()
    {
        foreach (GameObject g in CardsInHand)
        {
            g.transform.DOLocalMoveX(slots.Children[CardsInHand.IndexOf(g)].transform.localPosition.x, 0.3f);

            // корректный порядок сортировки (чтобы карты накладывались друг на друга)
            WhereIsTheCardOrCreature w = g.GetComponent <WhereIsTheCardOrCreature>();
            w.Slot = CardsInHand.IndexOf(g);
            w.SetHandSortingOrder();
        }
    }
Exemple #13
0
    void Awake()
    {
        // establish all the connections
        sr = GetComponent <SpriteRenderer>();
        lr = GetComponentInChildren <LineRenderer>();
        lr.sortingLayerName = "Above Everything";
        triangle            = transform.Find("Triangle");
        triangleSR          = triangle.GetComponent <SpriteRenderer>();

        manager             = GetComponentInParent <OneCreatureManager>();
        whereIsThisCreature = GetComponentInParent <WhereIsTheCardOrCreature>();
    }
Exemple #14
0
    void Awake()
    {
        // ustal wszystkie połączenia
        sr = GetComponent <SpriteRenderer>();
        lr = GetComponentInChildren <LineRenderer>();
        lr.sortingLayerName = "AboveEverything";
        triangle            = transform.Find("Triangle");
        triangleSR          = triangle.GetComponent <SpriteRenderer>();

        manager             = GetComponentInParent <OneCreatureManager>();
        whereIsThisCreature = GetComponentInParent <WhereIsTheCardOrCreature>();
    }
Exemple #15
0
    void Awake()
    {
        sr = GetComponent <SpriteRenderer>();
        lr = GetComponentInChildren <LineRenderer>();
        lr.sortingLayerName = "AboveEverything";
        triangle            = transform.Find("PointerTriangle");
        triangleSR          = triangle.GetComponent <SpriteRenderer>();

        whereIsThisCard = GetComponentInParent <WhereIsTheCardOrCreature>();

        targets          = GetComponentInParent <CardAsset>().Targets;
        originalPosition = this.transform.parent.localPosition;
    }
Exemple #16
0
 /// <summary>
 /// After a new creature is added or an old creature dies, this method
 /// shifts all the creatures and places the creatures on new slots.
 /// </summary>
 void PlaceCardsOnNewSlots()
 {
     foreach (GameObject g in CardsOnTable)
     {
         g.transform.DOLocalMoveX(slots.Children[CardsOnTable.IndexOf(g)].transform.localPosition.x, 0.3f);
         // apply correct sorting order and HandSlot value for later
         // TODO: figure out if I need to do something here:
         // g.GetComponent<WhereIsTheCardOrCreature>().SetTableSortingOrder() = CreaturesOnTable.IndexOf(g);
         WhereIsTheCardOrCreature w = g.GetComponent <WhereIsTheCardOrCreature>();
         w.Slot = CardsOnTable.IndexOf(g);
         w.SetHandSortingOrder();
     }
 }
Exemple #17
0
    private void ChangeLastCardStatusToInSlot(GameObject card, WhereIsTheCardOrCreature w)
    {
        // TODO: Make this a slot-related status.
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowHand;
        }
        else
        {
            w.VisualState = VisualStates.TopHand;
        }

        // end command execution for DrawACArdCommand or TakeCardBackCommand
        Command.CommandExecutionComplete();
    }
    void ChangeLastCardStatusToInHand(GameObject card, WhereIsTheCardOrCreature w)
    {
        //Debug.Log("Changing state to Hand for card: " + card.gameObject.name);
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowHand;
        }
        else
        {
            w.VisualState = VisualStates.TopHand;
        }

        w.SetHandSortingOrder();
        Command.CommandExecutionComplete();
    }
Exemple #19
0
    // method to create a new creature and add it to the table
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        // create a new creature from prefab
        GameObject creature = GameObject.Instantiate(GlobalSettings.Instance.CreaturePrefab, slots.children[index].transform.position, Quaternion.identity) as GameObject;

        // apply the look from CardAsset
        OneCreatureManager manager = creature.GetComponent <OneCreatureManager>();

        manager.cardAsset = ca;
        manager.ReadCreatureFromAsset();

        // add tag according to owner
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Creature";
        }

        // parent a new creature gameObject to table slots
        creature.transform.SetParent(slots.transform);

        // add a new creature to the list
        CreaturesOnTable.Insert(index, creature);

        // let this creature know about its position
        WhereIsTheCardOrCreature w = creature.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot = index;
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // add our unique ID to this creature
        IDHolder id = creature.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // after a new creature is added update placing of all the other creatures
        ShiftSlotsGameObjectAccordingToNumberOfCreatures();
        PlaceCreaturesOnNewSlots();

        // end command execution
        Command.CommandExecutionComplete();
    }
Exemple #20
0
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        // создаем новый gameobject
        GameObject creature = GameObject.Instantiate(GlobalSettings.Instance.CreaturePrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;

        // настраиваем внешний вид карты из ассета
        OneCreatureManager manager = creature.GetComponent <OneCreatureManager>();

        manager.cardAsset = ca;
        manager.ReadCreatureFromAsset();

        // добавляем тэг в соответствии с владельцем карты
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Creature";
        }

        // привязываем созданный объект к слотам на столе
        creature.transform.SetParent(slots.transform);

        // добавляем в список (на определенное место)
        CreaturesOnTable.Insert(index, creature);

        // позволяем созданному объекту знать свое местоположение
        WhereIsTheCardOrCreature w = creature.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot = index;
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // добавляем уникальный ID
        IDHolder id = creature.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // обновляем местоположение остальных существ на столе
        ShiftSlotsGameObjectAccordingToNumberOfCreatures();
        PlaceCreaturesOnNewSlots();

        // заканчиваем выполнение комманды
        Command.CommandExecutionComplete();
    }
Exemple #21
0
    // this method will be called when the card arrived to hand
    void ChangeLastCardStatusToInHand(GameObject card, WhereIsTheCardOrCreature w)
    {
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowHand;
        }
        else
        {
            w.VisualState = VisualStates.TopHand;
        }

        // set correct sorting order
        w.BringToHandCards();
        // end command execution for DrawACArdCommand
        Command.CommandExecutionComplete();
    }
Exemple #22
0
    // this method will be called when the card arrived to table
    void ChangeLastCardStatusToOnTable(GameObject card, WhereIsTheCardOrCreature w)
    {
        //Debug.Log("Changing state to Hand for card: " + card.gameObject.name);
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        // set correct sorting order
        w.SetHandSortingOrder();
        // end command execution for DrawACArdCommand
        Command.CommandExecutionComplete();
    }
Exemple #23
0
    public void GetCardFromDeck(CardAsset ca, int cardID, bool fast)
    {
        GameObject card;
        Transform  DeckTransform = table.deckPosition;

        card = CreateACardAtPosition(ca, DeckTransform.position, new Vector3(0f, -179f, 0f));

        // Set a tag to reflect where this card is
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to HandVisual class
        AddCard(card);

        // Bring card to front while it travels from draw spot to hand
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();
        w.Slot        = 0;
        w.VisualState = VisualStates.Transition;

        // pass a unique ID to this card.
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = cardID;

        // move card to the hand;
        Sequence s = DOTween.Sequence();

        if (!fast)
        {
            // Debug.Log ("Not fast!!!");
            s.Append(card.transform.DOLocalMove(gameObject.transform.localPosition, GlobalSettings.Instance.CardTransitionTime));
            s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTime));
        }
        else
        {
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(gameObject.transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));
            s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
        }

        s.OnComplete(() => ChangeLastCardStatusToInSlot(card, w));
    }
Exemple #24
0
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        GameObject creature = GameObject.Instantiate(GlobalSettings.Instance.CreaturePrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;

        OneCreatureManager manager = creature.GetComponent <OneCreatureManager>();

        manager.cardAsset = ca;
        manager.ReadCreatureFromAsset();

        // add tag according to owner
        foreach (Transform t in creature.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Creature";
        }

        creature.transform.SetParent(slots.transform);
        CreaturesOnTable.Insert(index, creature);

        WhereIsTheCardOrCreature w = creature.GetComponent <WhereIsTheCardOrCreature>();

        w.Slot = index;
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowTable;
        }
        else
        {
            w.VisualState = VisualStates.TopTable;
        }

        IDHolder id = creature.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        ShiftSlotsGameObjectAccordingToNumberOfCreatures();
        PlaceCreaturesOnNewSlots();

        Command.CommandExecutionComplete();
    }
Exemple #25
0
    // ZMIANA OSTATNIEJ KARTY NA: InHand
    void ChangeLastCardStatusToInHand(GameObject card, WhereIsTheCardOrCreature w)
    {
        //Debug.Log("Zmiana stanu na kartę w ręce: " + card.gameObject.name);

        // Tutaj sprawdzamy do której dłoni ma trafić karta, czy do przeciwnika czy do naszej
        // Jeśli owner jest równy pozycji Low (jest to pozycja gracza na dole ekranu) to jedzie z kodem ->
        if (owner == AreaPosition.Low)
        {
            // odwołanie się do VisualState w WITCOC i nadanie jej argumentu "LowHand" z enum VisualStates
            w.VisualState = VisualStates.LowHand;
        }

        // Jeśli owner nie jest Low to jest Top (czyli jest na pozycji gracza na górze ekranu) i jedzie z tym kodem ->
        else
        {
            // odwołanie się do VisualState w WITCOC i nadanie jej argumentu "TopHand" z enum VisualStates
            w.VisualState = VisualStates.TopHand;
        }

        // ustawienie prawidłowej kolejności sortowania
        w.SetHandSortingOrder();            // odwołanie się do metody w WITCOC i wykonanie tej metody
        Command.CommandExecutionComplete(); // odwołanie się do metody w klasie Command i jej wywołanie
    }
 void Awake()
 {
     whereIsCard = GetComponent <WhereIsTheCardOrCreature>();
     manager     = GetComponent <OneCardManager>();
 }
 void Awake()
 {
     manager = GetComponent <OneCreatureManager>();
     w       = GetComponent <WhereIsTheCardOrCreature>();
 }
Exemple #28
0
    // DAJE GRACZOWI NOWĄ KARTĘ Z POZYCJI
    public void GivePlayerACard(CardAsset c, int UniqueID, bool fast = false, bool fromDeck = true)
    {
        // Zainicjowanie obiektu card typu GameObject
        GameObject card;

        // Sprawdzenie dla pewności czy karta pochodzi z talii; fromDeck musi być true
        if (fromDeck)
        {
            // Przypisanie do obiektu card obiektu stworzonego za pomocą funkcji - CreateACardAtPosition() -> funkcja opisana wyżej
            // W nawiasach znajdują się argumenty na których ma operować funkcja
            card = CreateACardAtPosition(c, DeckTransform.position, new Vector3(0f, -179f, 0f));
        }
        else
        {
            // Jeżeli fromDeck to false to karta nie jest z talii więc tworzy tą kartę, ale umieszcza ją w innym miejscu w grze
            card = CreateACardAtPosition(c, OtherCardDrawSourceTransform.position, new Vector3(0f, -179f, 0f));
        }

        // Ustawienie tagu, aby odzwierciedlić miejsce, w którym znajduje się ta karta
        // card.GetComponentsInChildren<Transform> - to zwrócony komponent typu Transform z obiektu card
        // Chodzi o przypisanie tagu do tego obiektu, a tag znajduje się w klasie Transform (jest to klasa systemowa)
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            // Odwołanie się do tagu z Transform i przypisanie do niego zwróconego łańcucha znaków [ToString()] z "Owner" i dodanie do niego "Card"
            t.tag = owner.ToString() + "Card";
        }

        AddCard(card); //wywołanie funkcji (jest opisana wyżej)

        // Zainicjowanie zmiennej w typu WITCOC przypisanie do niego komponentu z obiektu card typu WITCOC
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();                        //odwołanie się do funkcji w klasie WITCOC i wywołanie jej (działanie funkcji opisane w danym skrypcie)
        w.Slot        = 0;                       // Odwołanie się do zmiennej slot w klasie WITCOC i przypisanie jej wartości 0
        w.VisualState = VisualStates.Transition; //Odwołanie się do zmiennej VisualState w klasie WITCOC (jest to zmienna typu enum)
        // I nadanie jej argumentu "Transition", który znajduje się w zbiorze enum VisualStates
        /// Ogólnie tutaj chodzi o to aby podczas gdy karta będzie podróżować z miejsca do ręki miała priorytet i była ponad wszystkimi
        /// Innymi obiektami (była najbardziej widoczna)

        // NADAJ TEJ KARCIE - ID
        // Zainicjowanie zmiennej id typu IDHolder i przypisanie do niej stworzonego komponentu z obiektu card, typu IDHolder
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = UniqueID; // Odwołanie się do zmiennej w klasie IDHolder i przypisanie do niej - jej (tzn jej ale będącej argumentem tej funkcji) xD
        /// Wiem to może być dziwne, ale to co przetwarza tamta klasa zapisuje się właśnie w UniqueID; chcemy to co ona wykona przekazać tą funkcją dalej
        /// Więc musimy to przekazać do jej argumentu - tym właśnie jest to drugie UniqueID po znaku równa się


        //  PRZENIESIENIE KARTY DO RĘKI
        // Zainicjowanie zmiennej s typu Sequence
        /// Na przyszłość: jeśli chodzi o tym Sequence to jest to typ udostępniany przez bibliotekę DOTWEEN
        /// Tworzy ona zasób w której będzie można przetrzymywać stworzoną sekwencję animacji jaka ma być wykonywana
        /// Nie będę tutaj za dużo o niej pisać, ale polecam zapoznać się z dokumentacją DOTWEEN jest tam wszystko dokładnie wytłumaczone
        // Do "s" przypisujemy funkcję która będzie generować tą sekwencję (chodzi po prostu o dbanie o zdrowie swoich palcy i nie pisania za dużo) xD
        Sequence s = DOTween.Sequence();

        // Na początku tej funkcji zainicjowaliśmy tą zmienną jako false, chodzi tutaj o wywołanie jej jako true, bez zmieniania jej na true
        if (!fast)
        {
            // Debug.Log ("Not fast!!!");
            // s.Append() - Wywołanie funkcji Append zawartej w Sequence()
            /// Append() - dodaje animację do końca sekwencji
            // DrawPreviewSpot.position - przekazuje referencje pozycji jakie znajdują się w polu DrawPreviewSpot
            // GlobalSettings.Instance.CardTransitionTime - przekazuje referencje czasu jakie znajdują się w polu CardTransitionTime
            /// Jeśli chodzi o to ostatnie to jest to wytłumaczone w skrypcie GlobalSetting
            s.Append(card.transform.DOMove(DrawPreviewSpot.position, GlobalSettings.Instance.CardTransitionTime));

            // Sprawdzanie czy można wyłożyć kartę, jeśli tak to jedzie z kodem ->
            if (TakeCardsOpenly)
            {
                // s.Insert() - Wywołanie funkcji Insert zawartej w Sequence()
                /// Insert() - umożliwia dodanie animacji do konkretnej pozycji czasowej
                // 0f - oznacza czas w którym ma zostać animacja umieszczona
                /// ogólnie w tej funkcji pierwszy argument zawsze oznacza czas
                // ard.transform.DORotate - wywołanie funkcji DORotate, która będzie działąć na Transform w obrębie card
                /// DORotate() - obraca cel do podanej wartości
                // Vector3.zero - pierwszy argument DORotate, jest końcowym stanem do jakiego ma zostać zmodyfikowany obiekt
                /// Na przyszłość: Vector3.zero - jest skrótem od Vector3 (0,0,0); ustawia obiekt na 0
                // lobalSettings.Instance.CardTransitionTime - TO CO BYŁO OPISANE WYŻEJ ^
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTime));
            }

            //else
            //s.Insert(0f, card.transform.DORotate(new Vector3(0f, -179f, 0f), GlobalSettings.Instance.CardTransitionTime));

            // s.AppendInterval() - Wywołanie funkcji AppendInterval zawartej w Sequence()
            // AppendInterval() - dodaje podany interwał do końca sekwencji
            // W nawiasie to co było wytłumaczane wyżej ^
            s.AppendInterval(GlobalSettings.Instance.CardPreviewTime);
            // Dodajemy animację do końca sekwencji; w nawiasie podajemy jaka animacja ma się stworzyć
            // card.transform.DOLocalMove - odwołujemy się do tramsformacji w obrębie "card" i wywołujemy funkcję DOLocalMove
            /// DOLocalMove() - funkcja która przenosi obiekt do podanej wartości w nawiasie
            // slots.Children[0].transform.localPosition - odwołujemy się do lokalnej pozycji jaka jest zawarta w Children[0], który jest w "slots"
            /// Jest to pierwszy argument funkcji DOLocalMove(), zawsze oznacza pozycję do której ma się udać obiekt
            // Drugi argument to czas w jakim ma się przenieść obiekt, tutaj bez zmian to co powyżej było wyjaśniane ^
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTime));
        }
        // Jeśli zmienna fast jest false to wykonuje poniższy kod ->
        else
        {
            // To samo co parę linikej wyżej z tą różnicą, że tym razem czas w jakim ma się wykonać animacja pochodzi od zmiennej CardTransitionTimeFast
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));

            // Sprawdzenie czy można wyłożyć kartę z talii do ręki, TakeCardsOplenly musi być true aby ruszył się dalej kod ->
            if (TakeCardsOpenly)
            {
                // To samo co było wajaśniane wyżej w tej funkcji, dodajemy animację do konkretnej pozycji czasowej
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
            }
        }

        // Ustawienie wywołania zwrotnego (OnComplete), które zostanie wywołanie po zakończeniu animacji; w nawiasie podajemy co ma być wywołane
        /// => - to wyrażenie lambda, służy do wywoływania funkcji/metod. Przydatne przy delegatach.
        /// Nie wiem jak to wytłumaczyć na zrozumiały język. .może przykład:
        /// mamy delegację del Delegate -> przypisujemy do niego np x -> del Delegate = x / i teraz możemy użyć wyrażenia lambda aby określić argumenty
        /// del Delegate = x => x + x;
        /// Potem możemy wywołać Delegate(np. 5) i dostaniemy wynik 10, ponieważ podaną 5 lambda przypisuje do argumentów x+x
        /// I tak samo lambdę moża wykorzystać w funkcjach tak jak poniżej, mamy funkcję ChangeLastCardStatusToInHand i podane argumenty
        /// Lambda przekazuje te parametry do funkcji, potem ta funkcja się wykonuje i zwraca wynik do niej
        /// Wynik wędruje do OnComplete aby wykonać swoją robotę na podstawie swojego argumentu, który składa się z argumentów ChangeLastCardStatusToInHand
        /// W ten sposób stworzyliśmy tzw. Drzewo wyrażeń - coś się składa z czegoś, a to coś jeszcze z czegoś i tak do najniższej pozycji drzewa
        // A dlaczego tak? Bo funkcja ChangeLastCardStatusToInHand zmienia status karty; chcemy aby ten status wykonał się po tym jak karta trafi do ręki
        // Dlatego umieszczamy ją w OnComplete, która oznacza koniec animacji która przenosi kartę do ręki i w ten sposób mamy pewność że ta funkcja
        // Wykona się dopiero wtedy gdy karta będzie w ręce
        s.OnComplete(() => ChangeLastCardStatusToInHand(card, w));
    }
 void Awake()
 {
     whereIsCard = GetComponent <WhereIsTheCardOrCreature>();
 }
    // CARD DRAW METHODS
    public void GivePlayerACard(CardAsset c, int UniqueID, bool fast = false, bool fromDeck = true)
    {
        GameObject card;

        if (fromDeck)
        {
            card = CreateACardAtPosition(c, DeckTransform.position, new Vector3(0f, -179f, 0f));
        }
        else
        {
            card = CreateACardAtPosition(c, OtherCardDrawSourceTransform.position, new Vector3(0f, -179f, 0f));
        }
        // save this as visual representation in CardLogic
        // Player ownerPlayer = GlobalSettings.Instance.Players[owner];
        //Debug.Log(ownerPlayer);
        //Debug.Log(ownerPlayer.hand);
        //Debug.Log("CArdsInHand.Count: "+ ownerPlayer.hand.CardsInHand.Count);
        //Debug.Log("Attempted placeInHand: " +placeInHand);
        // ownerPlayer.hand.CardsInHand[0].VisualRepresentation = card;
        //Debug.Log(ownerPlayer.hand);
        // Set a tag to reflect where this card is
        foreach (Transform t in card.GetComponentsInChildren <Transform>())
        {
            t.tag = owner.ToString() + "Card";
        }
        // pass this card to HandVisual class
        AddCard(card);
        // let the card know about its place in hand.
        WhereIsTheCardOrCreature w = card.GetComponent <WhereIsTheCardOrCreature>();

        w.BringToFront();

        w.Slot = 0;
        // pass a unique ID to this card.
        IDHolder id = card.AddComponent <IDHolder>();

        id.UniqueID = UniqueID;

        // save this card to change its state to "Hand" when it arrives to the hand.
        LastDealtCard = card;

        // move card to the hand;
        Sequence s = DOTween.Sequence();

        if (!fast)
        {
            Debug.Log("Not fast!!!");
            s.Append(card.transform.DOMove(DrawPreviewSpot.position, GlobalSettings.Instance.CardTransitionTime));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTime));
            }
            else
            {
                s.Insert(0f, card.transform.DORotate(new Vector3(0f, 179f, 0f), GlobalSettings.Instance.CardTransitionTime));
            }
            s.AppendInterval(GlobalSettings.Instance.CardPreviewTime);
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTime));
        }
        else
        {
            // displace the card so that we can select it in the scene easier.
            s.Append(card.transform.DOLocalMove(slots.Children[0].transform.localPosition, GlobalSettings.Instance.CardTransitionTimeFast));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
            }
        }

        s.OnComplete(() => ChangeLastCardStatusToInHand(card, w));
    }