Beispiel #1
0
    private void RandomizeRooms()
    {
        // Shuffle all the rooms
        DeckShuffler.Shuffle(allRoomsExceptStartAndExit);

        // Divide the rooms into two stacks
        GameObject[] firstHalfOfRooms  = new GameObject[allRoomsExceptStartAndExit.Length / 2];
        GameObject[] secondHalfOfRooms = new GameObject[allRoomsExceptStartAndExit.Length / 2 + 1];

        for (int i = 0; i < firstHalfOfRooms.Length; i++)
        {
            firstHalfOfRooms[i]  = allRoomsExceptStartAndExit[i];
            secondHalfOfRooms[i] = allRoomsExceptStartAndExit[firstHalfOfRooms.Length + i];
        }

        // Add the Exit Room to the second stack
        secondHalfOfRooms[secondHalfOfRooms.Length - 1] = exitRoom;
        // Then shuffle the second stack
        DeckShuffler.Shuffle(secondHalfOfRooms);

        // Combine both stacks into a Room Deck
        GameObject[] allRooms = new GameObject[allRoomsExceptStartAndExit.Length + 1];

        firstHalfOfRooms.CopyTo(allRooms, 0);
        secondHalfOfRooms.CopyTo(allRooms, firstHalfOfRooms.Length);

        roomsDeck.SetCards(allRooms);
    }
    public void TriggerRoom(Transform player)
    {
        var enemy = Instantiate(enemyDeck.GetNextCard(), new Vector2(player.position.x - offset, player.position.y + offset), Quaternion.identity);

        if (enemy.TryGetComponent <Combatant>(out var combatant))
        {
            OnEnemySpawned?.Invoke(combatant);
        }

        // Move the player to the oposite corner of the room
        LeanTween.move(player.gameObject, new Vector2(player.position.x + offset, player.position.y - offset), timeToComplete)
        .setEaseOutSine()
        .setOnComplete(() =>
        {
            OnPlayerMoved?.Invoke();
        });

        // Shuffle and Reset the deck;
        playingCardsDeck.ResetIndex();
        DeckShuffler.Shuffle(playingCardsDeck.Cards);

        vcam.LookAt           = m_transform;
        vcam.Follow           = m_transform;
        spriteRenderer.sprite = null;
    }
    public void ShuffleDeck()
    {
        DeckShuffler shuffler = new DeckShuffler();

        shuffler.Shuffle(ref _deck);

        OrganizeQueue();
    }
Beispiel #4
0
    private void Awake()
    {
        RandomizeRooms();
        DeckShuffler.Shuffle(enemyDeck.Cards);
        enemyDeck.ResetIndex();

        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Combatant>();
        playerHealth = player.GetComponent <HealthBehaviour>();
    }
Beispiel #5
0
        public void Null()
        {
            var randomizer   = new Mock <IRandomizer>();
            var deckShuffler = new DeckShuffler(randomizer.Object);
            var results      = deckShuffler.Shuffle(null);

            Assert.IsNotNull(results);
            Assert.AreEqual(0, results.Count);
        }
Beispiel #6
0
        public void Shuffled()
        {
            var randomizer = new Mock <IRandomizer>();

            randomizer.Setup(x => x.Next(0, 2)).Returns(1);
            randomizer.Setup(x => x.Next(0, 1)).Returns(0);
            var deckShuffler = new DeckShuffler(randomizer.Object);
            var a            = new Card(null, null);
            var b            = new Card(null, null);
            var results      = deckShuffler.Shuffle(new[] { a, b });

            Assert.AreEqual(b, results[0]);
            Assert.AreEqual(a, results[1]);
        }
Beispiel #7
0
    // Start is called before the first frame update
    void Start()
    {
        CardLoader.loadCards();

        List <Card> shuffledCards = new List <Card>(CardLoader.deckBang);

        DeckShuffler.Shuffle(shuffledCards);

        float z = 0.0f;

        foreach (Card card in shuffledCards)
        {
            GameObject obj = Instantiate(cardPrefab);
            obj.transform.parent   = transform;
            obj.transform.position = new Vector3(0.0f, 0.0f, z);
            CardSprite cardSprite = obj.GetComponent <CardSprite>();
            cardSprite.card = card;
            z += 0.5f;
        }
    }
Beispiel #8
0
 private void StartNewRound()
 {
     DeckShuffler.Shuffle(playingCardDeck.Cards);
     playingCardDeck.ResetIndex();
     OnNewRoundStart?.Invoke();
 }