Ejemplo n.º 1
0
    // gives player a new card from a given position
    public void GivePlayerACard(CardAsset c, int index, bool canSee)
    {
        GameObject card;

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

        // pass this card to HandVisual class
        AddCard(card, index);

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

        w.BringToFront();
        w.Slot = index;

        // 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, GameStateSync.Instance.CardTransitionTime));

        if (canSee)
        {
            //s.Append(card.transform.DOMove(DrawPreviewSpot.position, GameStateSync.Instance.CardTransitionTime));
            s.Insert(0f, card.transform.DORotate(Vector3.zero, GameStateSync.Instance.CardTransitionTime));
            //s.AppendInterval(GameStateSync.Instance.CardPreviewTime);
        }
        else
        {
            HoverPreview preview = card.GetComponent <HoverPreview>();
            Destroy(preview);
        }

        s.OnComplete(() => ChangeLastCardStatusToInHand(card, w));
    }
Ejemplo n.º 2
0
    // flips a player's monster card
    public void PlayMonster(MonsterAsset monsterAsset, int index)
    {
        GameObject monster;

        monster = CreateAMonsterAtPosition(monsterAsset, slots.Children[index].position, new Vector3(0f, -179f, 0f));
        MonsterManager monsterManager = monster.GetComponent <MonsterManager>();

        monsterManager.index = index;
        monsterManager.CardFaceGlowImage.enabled = false;
        monsterManagers.Insert(index, monsterManager);

        // pass this monster to HandVisual class
        AddMonster(monster, index);

        // bring monster to front
        WhereIsTheCardOrMonster w = monster.GetComponent <WhereIsTheCardOrMonster>();

        w.BringToFront();
        w.Slot = index;

        // flip monster
        Sequence s = DOTween.Sequence();

        s.Insert(0f, monster.transform.DORotate(Vector3.zero, GameStateSync.Instance.MonsterFlipTime));

        // displace the monster so that we can select it in the scene easier.
        s.Append(monster.transform.DOLocalMove(slots.Children[0].transform.localPosition, GameStateSync.Instance.MonsterFlipTime));

        s.OnComplete(() => ChangeLastCardStatusToInHand(monster, w));
    }
Ejemplo n.º 3
0
    // method to add a card to the table
    public void AddCard(CardAsset cardAsset, Vector3 handPosition, int monsterIndex)
    {
        // create a new card from prefab
        GameObject card;

        card = GameObject.Instantiate(GameStateSync.Instance.SkillCardPrefab, handPosition, Quaternion.Euler(new Vector3(0f, -179f, 0f))) as GameObject;

        // apply the look of the card based on the info from CardAsset
        SkillCardManager manager = card.GetComponent <SkillCardManager>();

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

        // parent this card to our open slot
        Transform openSlot = FindOpenSlot(monsterIndex);

        card.transform.SetParent(openSlot);

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

        w.SendToBack();
        w.Slot = monsterIndex;

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

        s.Insert(0f, card.transform.DORotate(Vector3.zero, GameStateSync.Instance.CardTransitionTime));
        s.Append(card.transform.DOMove(openSlot.position, GameStateSync.Instance.CardTransitionTime));

        s.OnComplete(() => Command.CommandExecutionComplete());
    }
Ejemplo n.º 4
0
    // this method will be called when the monster is played
    void ChangeLastCardStatusToInHand(GameObject monster, WhereIsTheCardOrMonster w)
    {
        if (owner == AreaPosition.Low)
        {
            w.VisualState = VisualStates.LowHand;
        }
        else
        {
            w.VisualState = VisualStates.TopHand;
        }

        // set correct sorting order
        w.SetHandSortingOrder();
        // end command execution
        Command.CommandExecutionComplete();
    }
Ejemplo n.º 5
0
    // this method will be called when the card arrived to hand
    void ChangeLastCardStatusToInHand(GameObject card, WhereIsTheCardOrMonster 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;
        }

        // set correct sorting order
        w.SetHandSortingOrder();
        // end command execution for DrawACArdCommand
        Command.CommandExecutionComplete();
    }
Ejemplo n.º 6
0
 void Awake()
 {
     whereIsCard = GetComponent <WhereIsTheCardOrMonster>();
 }