Exemplo n.º 1
0
        public void UpdateDisplay()
        {
            this.PlayerGrid.Background  = (this.textBlockMessage.Text.Contains("Winner")) ? new SolidColorBrush(Colors.LightGreen) : new SolidColorBrush(Colors.White);
            this.textBlockScore.Text    = "Score: " + aPlayer.p1.score.ToString();
            this.textBlockRight.Text    = "Right: " + aPlayer.p1.correct.ToString();
            this.textBlockWrong.Text    = "Wrong: " + aPlayer.p1.incorrect.ToString();
            this.textBlockTimer.Text    = "This Time: " + aPlayer.p1.timer.ToString();
            this.textBlockBestTime.Text = "Best Time:" + ((aPlayer.p1.besttime == 99999) ? "" : aPlayer.p1.besttime.ToString());
            this.textBlockMessage.Text  = aPlayer.p1.message;

            this.textBlockQuestion.Text = aPlayer.p1.x.ToString() + " x " + aPlayer.p1.y.ToString();

            this.buttonA.Content = aPlayer.p1.suggestion1.ToString();
            this.buttonB.Content = aPlayer.p1.suggestion2.ToString();
            this.buttonX.Content = aPlayer.p1.suggestion3.ToString();
            this.buttonY.Content = aPlayer.p1.suggestion4.ToString();

            this.buttonA.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonB.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonX.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.buttonY.IsEnabled    = aPlayer.dispatcherTimer.IsEnabled;
            this.textBlockPlayer.Text = PlayerNum.ToString();

            this.ProgBar.Value = ((aPlayer.p1.score <= 0) ? 0 : aPlayer.p1.score) * 100 / 7;
            //this.ProgBar.MaxWidth = aPlayer.AnswersToWin;
            //this.ProgBar.MinWidth = 0;


            double dscore = (((aPlayer.p1.correct * 100.0) / (aPlayer.p1.incorrect + aPlayer.p1.correct)));

            dscore = (dscore > 0) ? dscore: 0;
            this.textBlockPercent.Text     = "Score: " + (dscore).ToString("N2") + " %";
            this.textBlockScore.Foreground = aPlayer.AnswerColor;

            if ((aPlayer.WrongAnswers.Count() > 0) && (this.listBox.Items.Count != aPlayer.WrongAnswers.Count))
            {
                this.listBox.Items.Add(aPlayer.WrongAnswers[aPlayer.WrongAnswers.Count - 1]);
            }

            if (aPlayer.WrongAnswers.Count() == 0)
            {
                this.listBox.Items.Clear();
            }

            if ((aPlayer.p1.showresults) && (this.myWebView.Visibility == Visibility.Collapsed))
            {
                this.myWebView.Visibility = Visibility.Visible;
                this.myWebView.NavigateToString(aPlayer.MakeResultsPage());
            }
            else if (!(aPlayer.p1.showresults) && (this.myWebView.Visibility == Visibility.Visible))
            {
                this.myWebView.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 2
0
 public bool Search(string str)
 {
     if (ID.ToString().Contains(str) || IDType.ToString().Contains(str) ||
         Range.ToString().Contains(str) || PlayerNum.ToString().Contains(str))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
    // Start is called before the first frame update
    private void Start()
    {
        _playerConfig = PlayerConfig.GetConfig(_playerNum);

        _titleText.text = _playerNum.ToString();
        SetColors(_playerConfig.PlayerColor);

        _deathOverlay.SetActive(false);
        var health = _playerConfig.PlayerHealth;

        // Subscribe
        health.OnHpChanged += OnHpChanged;
        health.OnDeath     += OnDeath;
        PlayersManager.OnPlayerEnteredGame += OnPlayerEneteredGame;

        _playerHudRoot.SetActive(false);
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxis("Horizontal" + PlayerNumber.ToString());
        float y = Input.GetAxis("Vertical" + PlayerNumber.ToString());

        //Debug.Log("X:" + x + " Y:" + y);
        if (state != PlayerState.moving)
        {
            if (damn)
            {
                damn = false;
            }
            else
            {
                float Xoffset = (this.transform.position.x + 0.4f) % 0.8f;
                if (Xoffset >= 0.4f)
                {
                    Xoffset -= 0.8f;
                }
                ;
                float Yoffset = (this.transform.position.y + 0.4f) % 0.8f;
                if (Yoffset >= 0.4f)
                {
                    Yoffset -= 0.8f;
                }
                ;
                float newx = this.transform.position.x - Xoffset;
                float newy = this.transform.position.y - Yoffset;
                //newx = Mathf.Round(this.transform.position.x - 0.4f) + 0.4f;
                //newy = Mathf.Round(this.transform.position.y - 0.4f) + 0.4f;
                this.transform.position = new Vector3(newx, newy, this.transform.position.z);
            }
        }
        if (state == PlayerState.idle)
        {
            float           zone = 0.5f;
            int             tx = 0, ty = 0;
            PlayerDirection?temp = null;
            if (Mathf.Abs(x) > Mathf.Abs(y))
            {
                if (x > zone)
                {
                    tx = 1; temp = PlayerDirection.right;
                }
                else if (x < -zone)
                {
                    tx = -1; temp = PlayerDirection.left;
                }
            }
            else
            {
                if (y > zone)
                {
                    ty = -1; temp = PlayerDirection.up;
                }
                else if (y < -zone)
                {
                    ty = 1; temp = PlayerDirection.down;
                }
            }
            //Debug.Log("x:" + x + "  y: "+ y + "playernum:"+PlayerNumber);
            if (temp != null)
            {
                int currentX = FindCellPositionX(transform.position.x);
                int currentY = FindCellPositionY(transform.position.y);
                //Debug.Log("CurrentX:" + currentX + " CurrentY:" + currentY);

                int nextX = currentX + tx;
                int nextY = currentY + ty;

                if (!(nextX >= gridSpawner.numberOfCellsX ||
                      nextX < 0 ||
                      nextY >= gridSpawner.numberOfCellsY ||
                      nextY < 0))
                {
                    //Debug.Log("Movement detected");
                    if (RoomManager.get().checkEmpty(nextX, nextY))
                    {
                        state     = PlayerState.moving;
                        direction = (PlayerDirection)temp;
                        //destX = currentX + tx;
                        //destY = currentY + ty;
                        prevPos   = transform.position;
                        targetPos = new Vector3(prevPos.x + (tx * gridSpawner.cellWidth),
                                                prevPos.y + (ty * gridSpawner.cellHeight), 0);
                        damn         = true;
                        walkProgress = 0f;
                        RoomManager.get().register(this, nextX, nextY);
                        RoomManager.get().unregister(this, currentX, currentY);
                    }
                }
            }
        }
        else if (state == PlayerState.moving)
        {
            walkProgress += speed / 100f;
            if (walkProgress >= 1f)
            {
                walkProgress       = 0f;
                transform.position = targetPos;
                state = PlayerState.idle;
            }
            else
            {
                transform.position = Vector3.Lerp(prevPos, targetPos, walkProgress);
            }
        }
    }
Exemplo n.º 5
0
 public override string ToString()
 {
     return(PlayerNum.ToString());
 }
Exemplo n.º 6
0
    //Coroutine deals with the movement of a player when they are oiled up


    //void oiledMovement()
    //{
    //    if (oilCount % 2 == 0)
    //    {
    //        GetComponent<Rigidbody2D>().AddForce(new Vector2(0, moveSpeed * oilForce *(hitPoints / 100f)));
    //    }
    //    else
    //    {
    //        GetComponent<Rigidbody2D>().AddForce(new Vector2(0, -moveSpeed *oilForce* (hitPoints / 100f)));
    //    }
    //    oilCount++;
    //    oilForce += 0.1f;
    //}

    float getOwnAxis(string axis)
    {
        return(Input.GetAxis(playerNum.ToString() + axis));
    }