private void Battle(CardViewer plCardView, CardViewer enCardView)
        {
            Card plCard = plCardView.Card;
            Card enCard = enCardView.Card;

            int newPlHP = plCard.Health - enCard.Attack;
            int newEnHP = enCard.Health - plCard.Attack;

            // Update the values of the model
            plCard.Health = newPlHP;
            enCard.Health = newEnHP;

            // Repaint both controls since their model changed.
            plCardView.Invalidate();
            enCardView.Invalidate();

            /* Remove card view and its model if the cards are below than zero.*/
            if (newPlHP <= 0)
            {
                battleF.GetControlsOfPlayerPanel().Remove(plCardView);
                battleF.Tr.Player.Hand.Remove(plCard);
            }

            if (newEnHP <= 0)
            {
                battleF.GetControlsOfEnemyPanel().Remove(enCardView);
                battleF.CurrEnemy.Hand.Remove(enCard);
            }

            IsOver();
        }
示例#2
0
    private CardViewer AddNewCardViewer()
    {
        CardViewer cv = Instantiate(cardViewerPrefab, cardContainer);

        cv.transform.localScale = cv.transform.localScale * viewerScaleRatio;
        loadedViewers.Add(cv);
        return(cv);
    }
示例#3
0
 public void ToggleCardPicked(CardViewer viewer)
 {
     if (selectedCards.Contains(viewer.CurrentlyDisplayed))
     {
         DeselectViewer(viewer);
     }
     else
     {
         SelectViewer(viewer);
     }
 }
 public void HideFullSizeCard(CardViewer card)
 {
     if (isShowed)
     {
         Destroy(fullSizeCard);
         isShowed = false;
     }
     else
     {
     }
 }
示例#5
0
    private void DeselectViewer(CardViewer viewer)
    {
        selectedCards.Remove(viewer.CurrentlyDisplayed);
        if (selectedCards.Count < minCards)
        {
            confirmButton.gameObject.SetActive(false);
        }

        GameObject cardVis = viewer.GetComponentInChildren <StatChangePropogator>().gameObject;

        Destroy(cardVis.GetComponent <Outline>());
        Destroy(cardVis.GetComponent <Image>());
    }
    private void OnMouseOver()
    {
        CardViewer viewer = DeckBuilderDeck.instance.hoveredCardViewer;
        //viewer.SetCard(cardId); needs to be redone
        Vector3 newPosition = transform.position;

        newPosition.x = X_OFFSET;
        if (newPosition.y < MIN_Y)
        {
            newPosition.y = MIN_Y;
        }
        viewer.transform.position = newPosition;
    }
示例#7
0
    public void Init()
    {
        DeckViewer mv   = Mission.GetComponent <DeckViewer>();
        DeckViewer drwv = Draw.GetComponent <DeckViewer>();
        DeckViewer hv   = Hand.GetComponent <DeckViewer>();

        Review = GameObject.Find("CardViewer");
        cv     = Review.GetComponent <CardViewer>();
        Deck d = Player.Decks.GetDeck(DeckEnum.Draw);

        drwv.GUID = d.GUID;
        d.Shuffle();
        Deck hand = new Deck();

        Player.Decks.AddDeck(hand);
        hand.DeckType = DeckEnum.PlayerHand;
        //hv.AddDeck(hand);

        if (hand != null)
        {
            hv.Clear();
            hv.GUID        = hand.GUID;
            hv.start       = new Vector3(0f, 0f);
            hv.Scale       = 0.25f;
            hv.cardXOffset = 1f;
        }

        Deck m = Player.Decks.GetDeck(DeckEnum.Mission);

        if (m != null)
        {
            mv.Clear();
            mv.GUID        = m.GUID;
            mv.start       = new Vector3(-1.65f, -0.025f);
            mv.Scale       = 0.25f;
            mv.cardXOffset = 1.4f;
            mv.ShowCards(0, mv.DeckCount());
        }

        if (d != null)
        {
            drwv.Clear();
            drwv.start       = new Vector3(-3.3f, -1.0f);
            drwv.Scale       = 0.25f;
            drwv.cardXOffset = 0f;
            drwv.ShowCards(0, drwv.DeckCount(), true, true);
        }

        cv.start = new Vector3(-6.35f, 1.75f);
        cv.Scale = 1.2F;
    }
        private void StartEnemyTurn()
        {
            battleF.ChangeToEnemyTurn(); // Moves the turn label and sets the according text.

            Thread.Sleep(2000);          // Give a little delay before choosing random cards.

            CardViewer enemyRandCard = GetRandomEnemyCard();

            currPlayerCard = GetRandomPlayerCard();

            Battle(currPlayerCard, enemyRandCard);

            Thread.Sleep(2000);

            ResetAndNotifyDelegate();
        }
        public void OnClickPlayerCard(CardViewerBattle cV)
        {
            if (!IsPlayerTurn)
            {
                return;
            }

            // If the player wants to unselect the selected card.
            if (SelectedPlayerCard && currPlayerCard.Equals(cV))
            {
                Reset();
            }
            else if (!SelectedPlayerCard)
            {
                currPlayerCard     = cV;
                SelectedPlayerCard = true;
            }
        }
示例#10
0
    //float Scale = 1f;
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start Game");
        Players = new List <string>();
        Players.Add("Player One");
        Board.LoadBoard(Players);
        hv                   = HandViewer.GetComponent <DeckViewer>();
        cv                   = CardViewer.GetComponent <CardViewer>();
        files                = GetComponent <GetFiles>();
        Global.Version       = "startrek2e";
        Global.ImageHeader   = "ImageFile";
        Global.NameHeader    = "Name";
        Global.CurrentPlayer = 0;
        string update = Global.Root + @"\plugins\" + Global.Version + @"\playable\updatelist.txt";

        Global.ImageDir = Global.Root + @"\plugins\" + Global.Version + @"\sets\setimages\general\";
        HandViewer.GetComponent <SpriteRenderer>().enabled = false;
        if (File.Exists(update))
        {
            files.Populate();
            StreamReader sr   = File.OpenText(update);
            string       line = "";
            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
            }
            Global.CardGeneralURLs = line;
            Global.ImageDir        = Global.Root + @"\plugins\" + Global.Version + @"\sets\setimages\general";
        }
        else
        {
            files.InitializeFiles(
                Global.Url,
                @"plugins/" + Global.Version + @"/" + Global.UpdateDir + @"/updatelist.txt");
        }
        var        extensionList = new[] { new ExtensionFilter("Text", "txt"), };
        var        paths         = StandaloneFileBrowser.OpenFilePanel("Open File", "", extensionList, false);
        GameObject PlayField     = GameObject.Find("PlayField");
        PlayEngine pe            = PlayField.GetComponent <PlayEngine>();

        pe.Player = Board.GetPlayer(Players[0]);
        pe.LoadDecks(paths[0]);
        pe.Init();
    }
示例#11
0
    private void SelectViewer(CardViewer viewer)
    {
        selectedCards.Add(viewer.CurrentlyDisplayed);
        if (selectedCards.Count == maxCards)
        {
            ConfirmPicks();
        }
        else if (selectedCards.Count >= minCards)
        {
            confirmButton.gameObject.SetActive(true);
        }
        GameObject cardVis = viewer.GetComponentInChildren <StatChangePropogator>().gameObject;

        cardVis.gameObject.AddComponent <Image>();
        Outline outline = cardVis.gameObject.AddComponent <Outline>();

        outline.effectDistance = outlineSize;
        outline.effectColor    = outlineColor;
    }
示例#12
0
 // Start is called before the first frame update
 void Start()
 {
     hv = Hand.GetComponent <DeckViewer>();
     cv = Review.GetComponent <CardViewer>();
 }
 private void Reset()
 {
     currPlayerCard     = null;
     SelectedPlayerCard = false;
 }