// 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); }
// 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(); }
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(); }
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(); }
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); }