Inheritance: MonoBehaviour
Esempio n. 1
0
    public override void StartCommandExecution()
    {
        Debug.Log("In deal damage command!");

        GameObject target;

        foreach (DamageCommandInfo info in Targets)
        {
            target = IDHolder.GetGameObjectWithID(info.targetID);
            if (GlobalSettings.Instance.IsPlayer(info.targetID))
            {
                // target is a hero
                target.GetComponent <PlayerPortraitVisual>().TakeDamage(info.amount, info.healthAfter);
            }
            else
            {
                // target is a creature
                target.GetComponent <OneCreatureManager>().TakeDamage(info.amount, info.healthAfter);
            }
        }
        Sequence s = DOTween.Sequence();

        s.PrependInterval(1f);
        s.OnComplete(Command.CommandExecutionComplete);
    }
Esempio n. 2
0
    public override void StartCommandExecution()
    {
        GameObject Attacker = IDHolder.GetGameObjectWithID(AttackerUniqueID);

        //Debug.Log(TargetUniqueID);
        Attacker.GetComponent <CreatureAttackVisual>().AttackTarget(TargetUniqueID, DamageTakenByTarget, DamageTakenByAttacker, AttackerHealthAfter, TargetHealthAfter);
    }
Esempio n. 3
0
    // METHODS TO SHOW GLOW HIGHLIGHTS
    public void HighlightPlayableCards(bool removeAllHighlights = false)
    {
        //Debug.Log("HighlightPlayable remove: "+ removeAllHighlights);
        foreach (CardLogic cl in hand.CardsInHand)
        {
            GameObject g = IDHolder.GetGameObjectWithID(cl.UniqueCardID);
            if (g != null)
            {
                g.GetComponent <OneCardManager>().CanBePlayedNow = (cl.CurrentManaCost <= ManaLeft) && !removeAllHighlights;
            }
        }

        foreach (CreatureLogic crl in table.CreaturesOnTable)
        {
            GameObject g = IDHolder.GetGameObjectWithID(crl.UniqueCreatureID);
            if (g != null)
            {
                g.GetComponent <OneCreatureManager>().CanAttackNow = (crl.AttacksLeftThisTurn > 0) && !removeAllHighlights;
                //Debug.Log("creature attack possible" + g.GetComponent<OneCreatureManager>().CanAttackNow);
            }
        }

        // highlight hero power
        PArea.HeroPower.Highlighted = (!usedHeroPowerThisTurn) && (ManaLeft > 2) && !removeAllHighlights;
    }
Esempio n. 4
0
 public void ReloadScene()
 {
     IDFactory.ResetIDs();
     IDHolder.ClearIDHoldersList();
     Command.OnSceneReload();
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
Esempio n. 5
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));
    }
Esempio n. 6
0
    public void GivePlayerACard(CardAsset cardAsset, int UniqueID)
    {
        GameObject card = CreateACardAtPosition(cardAsset, slots.Children[0].transform.localPosition);

        foreach (Transform transform in card.GetComponentsInChildren <Transform>())
        {
            transform.tag = owner.ToString() + "Card";
        }
        AddCard(card);

        WhereIsCard whereIsCard = card.GetComponent <WhereIsCard>();

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

        id.UniqueID = UniqueID;

        Sequence sequence = DOTween.Sequence();

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

        sequence.OnComplete(() => ChangeLastCardStatusToInHand(card, whereIsCard));
    }
Esempio n. 7
0
    /// <summary>
    /// Función que permite jugar una carta al jugador.
    /// </summary>
    public override void EmpezarEjecucionComanda()
    {
        //Eliminar la carta de la mano del jugador y elimina el gameobject
        HandVisual PlayerHand = Controlador.Instance.AreaJugador(p).manoVisual;
        //TODO se podria hacer que el id de la carta pase a ser el id de la criatura
        GameObject card = IDHolder.GetGameObjectWithID(cl.ID);

        PlayerHand.EliminarCarta(card);
        IDHolder.EliminarElemento(card.GetComponent <IDHolder>());
        GameObject.Destroy(card);
        //Permite la previsualizacion de cartas
        //HoverPreview.PrevisualizacionesPermitidas = true;
        OpcionesObjeto.PrevisualizacionesPermitidas = true;
        // Añade la carta en el tablero
        PlayerArea areaJugador = Controlador.Instance.AreaJugador(p);

        if (ente.GetType() == typeof(Magica))
        {
            areaJugador.tableVisual.AñadirMagica(cl.AssetCarta, ente.ID, tablePos);
        }
        else
        {
            if (((Criatura)ente).PosicionCriatura.Equals(PosicionCriatura.ATAQUE))
            {
                areaJugador.tableVisual.AñadirCriaturaAtaque(cl.AssetCarta, ente.ID, tablePos);
            }
            else
            {
                areaJugador.tableVisual.AñadirCriaturaDefensa(cl.AssetCarta, ente.ID, tablePos);
            }
        }
    }
Esempio n. 8
0
    /// <summary>
    /// Función que cambia la posición de la criatura (defensa o ataque)
    /// </summary>
    public override void EmpezarEjecucionComanda()
    {
        GameObject Attacker = IDHolder.GetGameObjectWithID(AttackerUniqueID);

        //Debug.Log(TargetUniqueID);
        Attacker.GetComponent <CreatureAttackVisual>().ChangePosition(pos);
    }
Esempio n. 9
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();
    }
Esempio n. 10
0
    public override void ExecuteCommand()
    {
        GameObject            target     = IDHolder.GetGameObjectWithID(TargetID);
        CardOnBoardController targetCard = CardOnBoardController.CardsPlayedThisGame[TargetID];

        int currentTargetedCardHealth = targetCard.CardHealth;

        if (currentTargetedCardHealth > DamageDealt)
        {
            targetCard.CardHealth             -= DamageDealt;
            targetCard.cardOwner.PlayerHealth -= DamageDealt;
        }
        else
        {
            int healthToSubtract = targetCard.CardHealth;
            targetCard.CardHealth             -= healthToSubtract;
            targetCard.cardOwner.PlayerHealth -= healthToSubtract;
        }

        if (targetCard.CardHealth <= 0)
        {
            new DestroyObjectCommand(target).AddToQueue();
        }

        if (GameManager.IsHeadlessMode == false)
        {
            if (GameManager.IsHeadlessMode == false)
            {
                target.GetComponent <CardOnBoardView>().healthText.text        = targetCard.CardHealth.ToString();
                targetCard.cardOwner.playerView.playerHealth.playerHealth.text = targetCard.cardOwner.PlayerHealth.ToString();
            }
        }

        CommandExecutionComplete();
    }
Esempio n. 11
0
    public void LoadScene()
    {
        IDCreator.ResetIDs();
        IDHolder.ClearIDHoldersList();
        Command.CommandQueue.Clear();
        Command.CommandExecutionComplete();
        string buttonClicked = EventSystem.current.currentSelectedGameObject.name;

        switch (buttonClicked)
        {
        case "PlayerVsAI":
            GameManager.IsHeadlessMode = false;
            SceneManager.LoadScene("Scene_PlayervsAI");
            break;

        case "AIvsAI":
            GameManager.IsHeadlessMode = true;
            SceneManager.LoadScene("Scene_AIvsAI");
            break;

        case "Quit":
            Application.Quit();
            break;

        case "Menu":
            SceneManager.LoadScene("Scene_Menu");
            break;

        default:
            SceneManager.LoadScene("Scene_Menu");
            break;
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Función que básicamente voltea la carta mágica
    /// </summary>
    public override void EmpezarEjecucionComanda()
    {
        GameObject Attacker = IDHolder.GetGameObjectWithID(AttackerUniqueID);

        Attacker.GetComponent <MagicEffectVisual>().ColocarMagicaBocaArriba();
        Comandas.Instance.CompletarEjecucionComanda();
    }
Esempio n. 13
0
    public void AddCardAtIndex(CardAsset cardAsset, int UniqueID, int index)
    {
        GameObject card = Instantiate(ViewManager.Instance.cardOnBoardPrefab, slots.Children[index].transform.position, Quaternion.identity) as GameObject;

        CardOnBoardView cardView = card.GetComponent <CardOnBoardView>();

        cardView.cardAsset = cardAsset;
        cardView.displayCardOnBoardVisual();

        foreach (Transform transform in card.GetComponentsInChildren <Transform>())
        {
            transform.tag = owner.ToString() + "CardOnFrontRow";
        }

        card.transform.SetParent(slots.transform);

        cardsInRow.Insert(index, card);

        WhereIsCard whereIsCard = card.GetComponent <WhereIsCard>();

        whereIsCard.Slot        = index;
        whereIsCard.VisualState = VisualStates.LowBoardFrontRow;

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

        id.UniqueID = UniqueID;

        ShiftSlotsGameObjectAccordingToNumberOfCardsOnBoard();
        PlaceCardsOnNewSlots();

        Command.CommandExecutionComplete();
    }
Esempio n. 14
0
    // gives player a new card from a given position
    public void GivePlayerACard(CardAsset cardAsset, int UniqueID, bool fast = false, bool fromDeck = true)
    {
        var lastCardPosition = GetLastCardPosition();
        var originPosition   = fromDeck ? DeckTransform.position : OtherCardDrawSourceTransform.position;

        var card = CreateACardAtPosition(cardAsset, originPosition, new Vector3(0f, -180f, 0f));

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

        AddCard(card);

        var whereIs = card.GetComponent <WhereIsTheCardOrCreature>();

        if (whereIs == null)
        {
            whereIs = card.GetComponentInChildren <WhereIsTheCardOrCreature>();
        }

        whereIs.BringToFront();
        whereIs.Slot        = 0;
        whereIs.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)
        {
            s.Append(card.transform.DOMove(DrawPreviewSpot.position, GlobalSettings.Instance.CardTransitionTime));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTime));
            }

            s.AppendInterval(GlobalSettings.Instance.CardPreviewTime);

            s.Append(card.transform.DOLocalMove(lastCardPosition, GlobalSettings.Instance.CardTransitionTime));
        }
        else
        {
            s.Append(card.transform.DOLocalMove(lastCardPosition, GlobalSettings.Instance.CardTransitionTimeFast));
            if (TakeCardsOpenly)
            {
                s.Insert(0f, card.transform.DORotate(Vector3.zero, GlobalSettings.Instance.CardTransitionTimeFast));
            }
        }

        s.OnComplete(() => {
            ChangeLastCardStatusToInHand(card, whereIs);
            AdjustCardsInHand();
        });
    }
Esempio n. 15
0
 private void VaciarElementos()
 {
     for (int i = 0; i < gridLayoutGroup.transform.childCount; i++)
     {
         IDHolder.EliminarElemento(gridLayoutGroup.transform.GetChild(i).gameObject.GetComponent <IDHolder>());
         Destroy(gridLayoutGroup.transform.GetChild(i).gameObject);
     }
 }
Esempio n. 16
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));
    }
Esempio n. 17
0
    public void StartGame()
    {
        //reset all card IDs

        IDFactory.ResetIDs();
        IDHolder.ClearIDHoldersList();
        Command.OnSceneReload();
        SceneManager.LoadScene("InGame");
    }
Esempio n. 18
0
    // Destroy a creature
    public void RemoveCreatureWithID(int IDToRemove)
    {
        GameObject creatureToRemove = IDHolder.GetGameObjectWithID(IDToRemove);

        CreaturesOnTable.Remove(creatureToRemove);
        Destroy(creatureToRemove);
        CalculateCardPositions();
        Command.CommandExecutionComplete();
    }
Esempio n. 19
0
 public void ReloadScene()
 {
     Debug.Log("Scene reloaded");
     IDFactory.ResetIDs();
     IDHolder.ClearIDHoldersList();
     Command.CommandQueue.Clear();
     Command.CommandExecutionComplete();
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
Esempio n. 20
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();
    }
Esempio n. 21
0
    public override void StartCommandExecution()
    {
        DebugManager.Instance.DebugMessage("Executing stat divide command.", DebugManager.MessageType.Commands);

        GameObject target = IDHolder.GetGameObjectWithID(targetID);
        target.GetComponent<OneCreatureManager>().ChangeStat("health", healthAfter);
        target.GetComponent<OneCreatureManager>().ChangeStat("attack", healthAfter);

        CommandExecutionComplete();
    }
Esempio n. 22
0
 public void ReloadScene()
 {
     // Command has some static members, so let`s make sure that there are no commands in the Queue
     Debug.Log("Scene reloaded");
     // reset all card and creature IDs
     IDFactory.ResetIDs();
     IDHolder.ClearIDHoldersList();
     Command.OnSceneReload();
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
    public override void StartCommandExecution()
    {
        HandVisual PlayerHand = _p.PArea.handVisual;
        GameObject card       = IDHolder.GetGameObjectWithID(_cl.UniqueCardID);

        PlayerHand.RemoveCard(card);
        GameObject.Destroy(card);
        HoverPreview.PreviewsAllowed = true;
        _p.PArea.tableVisual.AddCreatureAtIndex(_cl.ca, _creatureId, _tablePos);
    }
Esempio n. 24
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
    }
Esempio n. 25
0
    public override void StartCommandExecution()
    {
        Debug.Log("In change stats command!");

        GameObject target = IDHolder.GetGameObjectWithID(targetID);

        // target is a creature
        target.GetComponent <OneCreatureManager>().ChangeStats(attackAmount, healthAmount, attackAfter, healthAfter);

        CommandExecutionComplete();
    }
Esempio n. 26
0
    public void RemoveCardOnBoardWithID(int IDToRemove)
    {
        GameObject cardToRemove = IDHolder.GetGameObjectWithID(IDToRemove);

        cardsInRow.Remove(cardToRemove);
        Destroy(cardToRemove);

        ShiftSlotsGameObjectAccordingToNumberOfCardsOnBoard();
        PlaceCardsOnNewSlots();
        Command.CommandExecutionComplete();
    }
 // METHODS TO SHOW GLOW HIGHLIGHTS
 public void HighlightPlayableCards(bool removeAllHighlights = false)
 {
     foreach (CardLogic cl in GlobalSettings.instance.players[owner].hand.cardsInHand)
     {
         GameObject g = IDHolder.GetGameObjectWithID(cl.uniqueCardID);
         if (g != null)
         {
             g.GetComponent <OneCreatureButtonManager>().canBePlayedNow = cl.canBePlayed && !removeAllHighlights;
         }
     }
 }
Esempio n. 28
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);
    }
Esempio n. 29
0
    /// <summary>
    /// Función que añade el item al script  progreso visual incoporado al gameobject de la carta.
    /// </summary>
    public override void EmpezarEjecucionComanda()
    {
        GameObject cartaG   = IDHolder.GetGameObjectWithID(carta.ID);
        GameObject itemG    = IDHolder.GetGameObjectWithID(item.ID);
        int        tipoItem = item.GetType() == typeof(Piedra) ? 1 : 0;

        cartaG.GetComponent <ProgresoVisual> ().AñadirItem(tipoItem, item.Cantidad);
        IDHolder.EliminarElemento(itemG.GetComponent <IDHolder> ());
        GameObject.Destroy(itemG);
        Comandas.Instance.CompletarEjecucionComanda();
    }
Esempio n. 30
0
 public void ReturnToMenu()
 {
     Debug.Log("Returning to Main Menu");
     // reset all card and creature IDs
     IDFactory.ResetIDs();
     IDHolder.ClearIDHoldersList();
     Command.CommandQueue.Clear();
     Command.CommandExecutionComplete();
     // probably find a better way to do this later
     SceneManager.LoadScene(mainMenu);
 }