public void setRandomArrows()
    {
        int range = 4;

        int rand = Random.Range(0, range);

        switch (rand)
        {
        case 0:
            arrows = arrows.Up | arrows.Left;
            break;

        case 1:
            arrows = arrows.Up | arrows.Right;
            break;

        case 2:
            arrows = arrows.Down | arrows.Left;
            break;

        case 3:
            arrows = arrows.Down | arrows.Right;
            break;
        }
    }
Example #2
0
    public bool IsEndzoneValid(Point p)
    {
        arrows check = p.Y == 0 ? arrows.Up : arrows.Down;

        OneCardManager c;

        if (FindFieldCardAtPoint(p) != null)
        {
            c = FindFieldCardAtPoint(p);
        }
        else
        {
            c = FindPlayerCardAtPoint(p);
        }

        if ((c.arrows & check) != 0)
        {
            return(true);
        }
        return(false);

        /*for(int x=0; x<3;x++)
         * {
         *  OneCardManager card = FindCardAtPoint(new Point(x, y));
         *  if (card == null) continue;
         *  if ((card.arrows & check) != 0) return true;
         * }*/
    }
 public void updateArrowsGlow(arrows arrowz)
 {
     if ((arrowz & arrows.Left) != 0)
     {
         CardArrowLeft.GetComponent <MeshRenderer>().material = arrowActiveMat;
     }
     else
     {
         CardArrowLeft.GetComponent <MeshRenderer>().material = arrowInactiveMat;
     }
     if ((arrowz & arrows.Right) != 0)
     {
         CardArrowRight.GetComponent <MeshRenderer>().material = arrowActiveMat;
     }
     else
     {
         CardArrowRight.GetComponent <MeshRenderer>().material = arrowInactiveMat;
     }
     if ((arrowz & arrows.Up) != 0)
     {
         CardArrowUp.GetComponent <MeshRenderer>().material = arrowActiveMat;
     }
     else
     {
         CardArrowUp.GetComponent <MeshRenderer>().material = arrowInactiveMat;
     }
     if ((arrowz & arrows.Down) != 0)
     {
         CardArrowDown.GetComponent <MeshRenderer>().material = arrowActiveMat;
     }
     else
     {
         CardArrowDown.GetComponent <MeshRenderer>().material = arrowInactiveMat;
     }
 }
    public void setPlayerArrows(arrows arrowz)
    {
        playerManager.arrows = arrowz;

        if (playerManager.myCardManager != null)
        {
            playerManager.myCardManager.updateArrows(playerManager.arrows);
        }
    }
    public void updateArrows(arrows arrowz)
    {
        CardArrowLeft.SetActive((arrowz & arrows.Left) != 0);
        CardArrowRight.SetActive((arrowz & arrows.Right) != 0);
        CardArrowDown.SetActive((arrowz & arrows.Down) != 0);
        CardArrowUp.SetActive((arrowz & arrows.Up) != 0);

        this.arrows = arrowz;
    }
Example #6
0
    public void RotateArrows(Point p)
    {
        OneCardManager myCard = FindCardAtPoint(p);

        // if (myCard.gameObject.tag == "Arrows")
        //    Arrow.gameObject.SetActive(false);
        //arrowss = GameObject.FindGameObjectsWithTag("Arrows");
        //foreach (GameObject r in arrowss)
        //   r.transform.Translate(Direction * movespeed * Time.deltaTime);



        arrows t = arrows.None;

        if ((myCard.arrows & arrows.Up) == arrows.Up)
        {
            t |= arrows.Down;
        }

        if ((myCard.arrows & arrows.Down) == arrows.Down)
        {
            t |= arrows.Up;
        }

        if ((myCard.arrows & arrows.Right) == arrows.Right)
        {
            t |= arrows.Left;
        }

        if ((myCard.arrows & arrows.Left) == arrows.Left)
        {
            t |= arrows.Right;
        }



        if (myCard.cardAsset.Type == CardType.Player)
        {
            foreach (PlayerManager pl in GameManager.Instance.players)
            {
                if (pl.myCardManager == myCard)
                {
                    Debug.Log("rotateplayerArrows");
                    pl.arrows = t;
                    pl.point  = myCard.point;
                }
            }
        }

        myCard.updateArrows(t);
    }
Example #7
0
    public void HighlightArrows() // highlight arrows and save all player moves found
    {
        foreach (OneCardManager card in AllCards)
        {
            if (card.cardAsset.Type != CardType.Spell)
            {
                arrows t = arrows.None;
                if (FindFieldCardAtPoint(new Point(card.point.X, card.point.Y - 1)) != null)
                {
                    t |= arrows.Up;
                }
                if (FindFieldCardAtPoint(new Point(card.point.X - 1, card.point.Y)) != null)
                {
                    t |= arrows.Left;
                }
                if (FindFieldCardAtPoint(new Point(card.point.X, card.point.Y + 1)) != null)
                {
                    t |= arrows.Down;
                }
                if (FindFieldCardAtPoint(new Point(card.point.X + 1, card.point.Y)) != null)
                {
                    t |= arrows.Right;
                }

                if (card.point.Y == 0)
                {
                    t |= arrows.Up;
                }
                if (card.point.Y == 1)
                {
                    t |= arrows.Down;
                }

                card.updateArrowsGlow(t);
            }
        }
    }
Example #8
0
    public List <OneCardManager> GetValidMovesDist(Point pos, arrows arr, int dist)
    {
        if (dist == 0)
        {
            return(new List <OneCardManager>());
        }

        List <OneCardManager> nList  = GetValidMoves(pos, arr);
        List <OneCardManager> nList2 = new List <OneCardManager>();

        foreach (OneCardManager card in nList)
        {
            List <OneCardManager> nSub = GetValidMovesDist(card.point, card.arrows, dist - 1);
            foreach (OneCardManager card2 in nSub)
            {
                if (!nList.Contains(card2))
                {
                    nList2.Add(card2);                         //TODO fix bug here
                }
            }
        }
        nList.AddRange(nList2);
        return(nList);
    }
    /*public void TakeDamage(int amount, int healthAfter)
     * {
     *  if (amount > 0)
     *  {
     *      Hp -= amount;
     *      //DamageEffect.CreateDamageEffect(transform.position, amount);
     *
     *      if (Hp <= 0) Die();
     *  }
     * }*/

    protected override void Awake()
    {
        base.Awake();

        if (PlayerDeck != null)
        {
            //  PlayerDeck.Get

            Deck.AddRange(PlayerDeck.GetComponent <PlayerDeck>().playerDeck);
        }

        boardManager = BoardManager.Instance;

        kvis.AvailableKidneys = 1;
        ActionPoints          = 1;
        apvis.TotalAp         = ActionPoints;
        ActionPoints          = 1;

        Hp = 10;

        // for testing // this spawns a player card
        // instantiate kidney object and assign add it to the list

        patientKidneys.Add(Instantiate(GameManager.Instance.KidneyPrefab));

        //patientKidneys[0].transform.position = KidneyLocation.transform.position;
        patientKidneys[0].transform.rotation = Quaternion.Euler(90f, 0f, 0f);//set kidney to proper place and //parent kidney
        patientKidneys[0].SetActive(false);

        if (mySide == location.top)
        {
            Doctor.transform.position = BoardManager.Instance.Top.transform.position;
        }
        else
        {
            Doctor.transform.position = BoardManager.Instance.Bottom.transform.position;
        }

        Doctor.SetActive(true);

        if (mySide == location.bottom)
        {
            myLocation = location.bottom;
            point.X    = 1;
            point.Y    = 2;
            arrows     = arrows.Up | arrows.Left | arrows.Right;
        }
        else   // top player
        {
            myLocation = location.top;
            point.X    = 1;
            point.Y    = -1;
            arrows     = arrows.Down | arrows.Left | arrows.Right;
        }


        //for testing

        /*playerKidneys.Add(Instantiate(KidneyPrefab));
         * playerKidneys[0].transform.SetParent(Doctor.transform, false);*/

        // hide doctor for testing TODO

        boardManager = BoardManager.Instance;
        //playerInput.InputEnabled = true;
        playerMover = GetComponent <PlayerMover>();
        playerInput = GetComponent <PlayerInput>();
        readFromCharAsset();
    }
Example #10
0
    public List <OneCardManager> GetValidMoves(Point pos, arrows arr)
    {
        List <OneCardManager> nList = new List <OneCardManager>();

        Point p;

        if ((arr & arrows.Up) != 0)
        {
            p = new Point(pos.X, pos.Y - 1);
            if (FindFieldCardAtPoint(p) != null)
            {
                nList.Add(FindFieldCardAtPoint(p));
            }
        }

        if ((arr & arrows.Down) == arrows.Down)
        {
            p = new Point(pos.X, pos.Y + 1);
            if (FindFieldCardAtPoint(p) != null) // can always move into endzone extra arrows here
            {
                nList.Add(FindFieldCardAtPoint(p));
            }
        }

        if ((arr & arrows.Right) == arrows.Right)
        {
            p = new Point(pos.X + 1, pos.Y);
            if (FindFieldCardAtPoint(p) != null)
            {
                nList.Add(FindFieldCardAtPoint(p));
            }
        }

        if ((arr & arrows.Left) == arrows.Left)
        {
            p = new Point(pos.X - 1, pos.Y);
            if (FindFieldCardAtPoint(p) != null)
            {
                nList.Add(FindFieldCardAtPoint(p));
            }
        }

        if (pos.Y == 2)
        {
            foreach (OneCardManager card in AllCards)
            {
                if (card.point.Y == 1)
                {
                    nList.Add(card);
                }
            }
        }
        else if (pos.Y == -1)
        {
            foreach (OneCardManager card in AllCards)
            {
                if (card.point.Y == 0)
                {
                    nList.Add(card);
                }
            }
        }
        return(nList);
    }