Ejemplo n.º 1
0
    // method to create a new creature and add it to the table
    public void AddCreatureAtIndex(CardAsset ca, int UniqueID, int index)
    {
        GameObject creature = GameObject.Instantiate(GlobalSettings.Instance.CreaturePrefab, this.transform.position, Quaternion.identity) as GameObject;

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

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

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

        creature.transform.SetParent(this.transform);

        CreaturesOnTable.Insert(index, creature);

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

        id.UniqueID = UniqueID;

        CalculateCardPositions();

        // end command execution
        Command.CommandExecutionComplete();
    }
Ejemplo n.º 2
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
    }
Ejemplo n.º 3
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 = 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);
    }
Ejemplo n.º 4
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>();
    }
Ejemplo n.º 5
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>();
    }
Ejemplo n.º 6
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>();
    }
Ejemplo n.º 7
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();
    }
Ejemplo n.º 8
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();
    }
Ejemplo n.º 9
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();
    }
Ejemplo n.º 10
0
    public void PlaceCreatureOnTile(Team owner, CardAsset cardAsset, int uniqueCreatureID, Tile tile)
    {
        // GameObject creature = Instantiate(GlobalSettings.instance.tableCreaturePrefab, tile.transform.position, Quaternion.identity) as GameObject;
        GameObject         creature           = Instantiate(cardAsset.creaturePrefab, tile.transform.position, Quaternion.identity) as GameObject;
        OneCreatureManager oneCreatureManager = creature.GetComponent <OneCreatureManager>();

        creature.AddComponent <IDHolder>().uniqueID = uniqueCreatureID;

        // Add the visual Creature GameObject to a list of Creature GameObjects
        creatureGameObjectsByID.Add(uniqueCreatureID, creature);

        // Visually Construct this Creature
        oneCreatureManager.ReadCreatureFromAsset(cardAsset);

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

        creature.transform.SetParent(creaturesParent.transform);
    }
Ejemplo n.º 11
0
 void Awake()
 {
     manager = GetComponent <OneCreatureManager>();
     w       = GetComponent <WhereIsTheCardOrCreature>();
 }
Ejemplo n.º 12
0
 void Awake()
 {
     manager = GetComponentInParent <OneCreatureManager>();
     dondeEstaCartaOCriatura = GetComponentInParent <WhereIsTheCardOrEntity>();
 }
Ejemplo n.º 13
0
 protected void Awake()
 {
     manager = GetComponent <OneCreatureManager>();
     w       = GetComponent <WhereIsTheCardOrEntity>();
 }
Ejemplo n.º 14
0
    private WhereIsTheCardOrCreature w;  //określa gdzie znajduje się karta

    void Awake()
    {
        manager = GetComponent <OneCreatureManager>();       //pobiera wygląd karty jeszcze przed rozpoczęciem gry
        w       = GetComponent <WhereIsTheCardOrCreature>(); //pobiera właściwość kart określająca gdzie znajduje się karta
    }