Exemplo n.º 1
0
    public void RemoveAndReplaceSelected()
    {
        foreach (GameObject C in SelectedCards)
        {
            Sets.Add(C);
            if (Deck.Count > 0)
            {
                Play [Play.IndexOf(C)] = Deck [0];
                Deck.RemoveAt(0);
            }
            else
            {
                Play.Remove(C);
            }
            C.GetComponent <Card> ().TargetPos = new Vector3(10, 10, 0);
        }
        SelectedCards = new List <GameObject> ();

        //Play.AddRange(Deck.GetRange (0, 3));
        //Deck.RemoveRange (0, 3);

        ArrangePlay();

        if (Deck.Count == 0)
        {
            if (FindNumberOfSets() == 0)
            {
                GameHasStarted = false;
                Deck.AddRange(Sets);
                Sets = new List <GameObject> ();
                MainCanvas.GetComponentsInChildren <StartButton> () [0].GetComponentInChildren <Text> ().text = "Start Game";
                MainCanvas.GetComponentsInChildren <StartButton> () [1].GetComponentInChildren <Text> ().text = "Start Singleplayer";
                TemporaryMessage Message = Resources.Load <TemporaryMessage>("Prefabs/TempMessage");
                Message = Instantiate(Message, MainCanvas.transform);
                Message.SetText("All Sets Found!");
                Message.Delay = 1f;
                foreach (StartOptions SO in HelpButtons)
                {
                    SO.gameObject.SetActive(true);
                }
                if (CurrentTurn != 4)
                {
                    MultiplayerGameFinished();
                }
                else
                {
                    //Restore buttons etc.
                    StopTimers();
                }
            }
        }
    }
Exemplo n.º 2
0
    public void UpdateGrid()
    {
        string LongString = "";

        //PLAYERS
        foreach (Player P in Players)
        {
            LongString = "";
            foreach (string s in All)
            {
                if (P.DoesHave.Contains(s))
                {
                    LongString += " X \n";
                }
                else if (P.NotHave.Contains(s))
                {
                    LongString += "   \n";
                }
                else
                {
                    LongString += " ? \n";
                }
            }
            Players [P.Index].Visuals.SetText(LongString);
        }

        //SOLUTION
        LongString = "";
        foreach (string s in All)
        {
            if (Solution [0] == s || Solution [1] == s || Solution [2] == s)
            {
                LongString += " X \n";
            }
            else if (Known.Contains(s))
            {
                LongString += " <> \n";                 //Know where it is
            }
            else
            {
                LongString += "   \n";                 //DON'T know
            }
        }
        SolutionGrid.SetText(LongString);
    }
Exemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartGame();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            Clue();
        }

        if (Input.GetMouseButtonUp(0) && CurrentTurn != -1)
        {
            //Debug.Log(Camera.main.ScreenToWorldPoint(Input.mousePosition));
            bool ChoseCard = false;
            bool FoundSet  = false;
            foreach (GameObject C in Play)
            {
                Bounds B = new Bounds(C.transform.position, new Vector3(2, 1, 60));
                if (B.Contains(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    ChoseCard = true;
                    if (SelectedCards.Count < 3)
                    {
                        if (!SelectedCards.Contains(C))
                        {
                            SelectedCards.Add(C);
                            C.transform.localScale = new Vector3(1.05f, 1.05f, 1);
                        }
                        if (SelectedCards.Count >= 3)
                        {
                            if (CheckSet(SelectedCards [0].GetComponent <Card>(), SelectedCards [1].GetComponent <Card>(), SelectedCards [2].GetComponent <Card>()))
                            {
                                //Remove cards, replace them, and add a 'point'.
                                TemporaryMessage Message = Resources.Load <TemporaryMessage>("Prefabs/TempMessage");
                                Message = Instantiate(Message, MainCanvas.transform);
                                Message.SetText("Set!");
                                Message.Delay = 0.5f;
                                //Debug.Log("Set!");
                                FoundSet = true;
                                if (CurrentTurn < 4)
                                {
                                    PlayerScores [CurrentTurn] += 1;
                                    MainCanvas.GetComponentsInChildren <Text> () [CurrentTurn].text = "" + PlayerScores [CurrentTurn];
                                    TurnEnded(CurrentTurn + 1, false);
                                }
                            }
                            else
                            {
                                //Deselect all cards, give a warning ("Not a set") or lose a point.
                                foreach (GameObject aCard in SelectedCards)
                                {
                                    aCard.transform.localScale = new Vector3(1, 1, 1);
                                }
                                SelectedCards = new List <GameObject> ();
                            }
                        }
                    }
                }
            }
            if (FoundSet)
            {
                RemoveAndReplaceSelected();
                SetCounter.text = FindNumberOfSets() + " sets left.";
            }
            if (ChoseCard == false)
            {
                foreach (GameObject aCard in SelectedCards)
                {
                    aCard.transform.localScale = new Vector3(1, 1, 1);
                }
                SelectedCards = new List <GameObject> ();
            }
        }
    }