Beispiel #1
0
 void SwitchUIText()
 {
     CurrentUIState = (UI_STATE)(((((int)CurrentUIState) + 1)) % ((int)UI_STATE.STATE_COUNT));
     if (CurrentUIState == UI_STATE.INVISIBLE)
     {
         // display all UI elements
         foreach (ButtonData element in UsedButtonList)
         {
             element.ButtonComponent.gameObject.SetActive(false);
         }
         if (DescriptionBox.activeInHierarchy == true)
         {
             DescriptionBox.SetActive(false);
         }
         ToggleCamMovementButton.gameObject.SetActive(false);
         BackToSceneIndexButton.gameObject.SetActive(false);
         ToggleUIText.text = "UI: Off";
     }
     else
     {
         // turn off all UI elements
         foreach (ButtonData element in UsedButtonList)
         {
             element.ButtonComponent.gameObject.SetActive(true);
         }
         ToggleCamMovementButton.gameObject.SetActive(true);
         BackToSceneIndexButton.gameObject.SetActive(true);
         ToggleUIText.text = "UI: On";
     }
 }
Beispiel #2
0
        void Update()
        {
            switch (m_state)
            {
            case UI_STATE.Still:
                break;

            case UI_STATE.Grow:

                m_changing_height += UI_Manager.Current.m_Speed * Time.deltaTime;

                float y = m_center_y + (m_changing_height - m_height) / 2;

                m_size.y = m_changing_height;



                if (m_changing_height >= UI_Manager.Current.m_Height)
                {
                    m_rectTransform.sizeDelta = new Vector2(m_size.x, UI_Manager.Current.m_Height);

                    m_rectTransform.anchoredPosition3D = new Vector3(m_center_x, y, 0);

                    m_state = UI_STATE.Still;
                }
                m_rectTransform.sizeDelta = m_size;

                m_rectTransform.anchoredPosition3D = new Vector3(m_center_x, y, 0);


                break;

            case UI_STATE.Shrink:

                m_changing_height -= UI_Manager.Current.m_Speed * Time.deltaTime;

                float y2 = m_center_y + (m_changing_height - m_height) / 2;

                m_size.y = m_changing_height;


                m_rectTransform.sizeDelta = m_size;

                m_rectTransform.anchoredPosition3D = new Vector3(m_center_x, y2, 0);

                if (m_changing_height <= m_height)
                {
                    m_state = UI_STATE.Still;

                    m_rectTransform.sizeDelta = new Vector2(m_width, m_height);

                    m_rectTransform.anchoredPosition3D = new Vector3(m_center_x, m_center_y, 0);
                }


                break;
            }
        }
Beispiel #3
0
        // Start is called before the first frame update
        void Start()
        {
            m_state         = UI_STATE.Still;
            m_rectTransform = this.GetComponent <RectTransform>();

            m_width    = m_rectTransform.sizeDelta.x;
            m_height   = m_rectTransform.sizeDelta.y;
            m_center_x = m_rectTransform.anchoredPosition3D.x;
            m_center_y = m_rectTransform.anchoredPosition3D.y;

            m_changing_height = m_height;

            m_changing_center_y = m_center_y;

            m_size = new Vector2(m_width, 0);
        }
Beispiel #4
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     m_state = UI_STATE.Grow;
 }
Beispiel #5
0
 public void OnPointerExit(PointerEventData eventData)
 {
     m_state = UI_STATE.Shrink;
 }
Beispiel #6
0
    public void setNetPlayer(NetPlayer pNP)
    {
        _NetPlayer = pNP;

        cdtimer.SetActive (false);
        HUD.GetComponent<Image>().sprite = Huds [_NetPlayer.iShipChoice];
        HUD.GetComponent<Image> ().enabled = true;
        HUD.transform.FindChild("MiniMapBack").GetComponent<Image>().sprite = MapBorders[_NetPlayer.iShipChoice];
        UIState = UI_STATE.Waiting;
    }
Beispiel #7
0
 public void startCountdown()
 {
     UIState = UI_STATE.Countdown;
     fTimer = 3.0f;
     gameObject.GetComponent<AudioSource>().Play();
     cdtimer.SetActive (true);
 }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        //Hide/Shows the menu button
        if (Input.GetKeyDown (KeyCode.Escape)) {
            IsPaused = !IsPaused;
            _NetPlayer.ship.GetComponent<PlayerController> ().bPaused = IsPaused;
            Menu.SetActive(IsPaused);
        }

        if (_NetPlayer == null)
          return;

        if(Input.GetKeyDown(KeyCode.Tab)){
          if(miniMapZoom < 3){
        miniMapZoom++;
          }
          else{
        miniMapZoom = 0;
          }
        }
        if (_NetPlayer.getPlayerState() == NetPlayer.PLAYER_STATE.Racing || _NetPlayer.getPlayerState() == NetPlayer.PLAYER_STATE.RaceReady)
        {
          switch (miniMapZoom)
          {
        case 0:
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().enabled = true;
          HUD.transform.FindChild("MiniMapBack").gameObject.SetActive(true);
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().orthographicSize = 50;
          break;
        case 1:
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().enabled = true;
          HUD.transform.FindChild("MiniMapBack").gameObject.SetActive(true);
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().orthographicSize = 85;
          break;
        case 2:
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().enabled = true;
          HUD.transform.FindChild("MiniMapBack").gameObject.SetActive(true);
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().orthographicSize = 150;
          break;
        case 3:
          GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().enabled = false;
          HUD.transform.FindChild("MiniMapBack").gameObject.SetActive(false);
          break;
          }
        }

        //------------------------------------
        //---------Update HUD-----------------
        //------------------------------------
        if (UIState == UI_STATE.HUD || UIState == UI_STATE.Waiting)
          UpdateHUD ();

        //------------------------------------
        //------Update countdown timer--------
        //------------------------------------
        else if(UIState == UI_STATE.Countdown){
          UpdateHUD ();
          fTimer -= Time.deltaTime;
          if(fTimer > 0)
        cdtimer.GetComponent<Image>().sprite = cDown[Mathf.CeilToInt(fTimer)];
          else if (fTimer <= 0 && fTimer > -1){
        if (_NetPlayer.PlayerState == NetPlayer.PLAYER_STATE.RaceReady)
          _NetPlayer.setPlayerState (NetPlayer.PLAYER_STATE.Racing);
        //countdownText.text = "GO!!!";
        cdtimer.GetComponent<Image>().sprite = cDown[0];
        //countdownText.color = Color.green;
          } // End if (fStartTimer < 0)
          if (fTimer <= -1){
        //transform.FindChild ("Canvas").FindChild ("CountdownText").gameObject.SetActive (false);
        UIState = UI_STATE.HUD;
        cdtimer.SetActive(false);
          } //End if (fStartTimer <= -500)
        } //End if(UIState == UI_STATE.Countdown)

        //------------------------------------
        //-------Update Scoreboard------------
        //------------------------------------
        else{
          if (UIState == UI_STATE.None)
        return;

          GameObject[] players = GameObject.FindGameObjectsWithTag ("NetPlayer");
          int[] iPlayerNums = {0,1,2,3,4,5,6,7};

          //Sort player nums by place
          for(int i=0; i<8; i++){
        for(int j=i+1; j<8; j++){
          int iPoints = players [iPlayerNums[i]].GetComponent<NetPlayer> ().getPoints ();
          int jPoints = players [iPlayerNums[j]].GetComponent<NetPlayer> ().getPoints ();
          if (jPoints > iPoints){
            int temp = iPlayerNums [i];
            iPlayerNums [i] = iPlayerNums [j];
            iPlayerNums [j] = temp;
          }
        }
          }

          fTimer -= Time.deltaTime;
          switch(UIState){
          case UI_STATE.SBWait:
        changeState (1, UI_STATE.SBPoints);
        HUD.SetActive(false);
        GameObject.FindGameObjectWithTag("minimap").GetComponent<Camera>().enabled = false;
        break;

          case UI_STATE.SBPoints:
        changeState (2, UI_STATE.SBPointTransfer);
        float lfTime = 0.0f;
        int liMin = 0;
        int liSec = 0;
        int liRem = 0;
        Scorboard.SetActive(true);
        foreach(GameObject p in players){
          if(p == null)
            continue;
          NetPlayer _NP = p.GetComponent<NetPlayer>();
          Transform slot = Scorboard.transform.FindChild ("Slots").GetChild (_NP.getPlace () - 1);

          //Slot background color
          if (_NP.getPlayerNum () == _NetPlayer.getPlayerNum ())
            slot.FindChild ("Background").GetComponent<Image> ().color = new Color (255.0f, 215.0f, 0.0f, 175.0f);
          //Ship Icon
          slot.FindChild ("Ship").GetComponent<Image> ().sprite = ShipIcons [_NP.iShipChoice];
          //Player# (text)
          slot.FindChild ("Name").GetComponent<Text> ().text = "Player " + (_NP.getPlayerNum() + 1).ToString();
          //Points
          slot.FindChild ("Points").GetComponent<Text> ().text =
            _NP.getPoints () - GameManager.POINTS [_NP.getPlace () - 1] - (_NP.hasFlag() ? 4 : 0) + "+" +
            (GameManager.POINTS [_NP.getPlace () - 1] + (_NP.hasFlag() ? 4 : 0));
          //Flag caps
          slot.FindChild ("Flags").GetComponent<Text> ().text = _NP.getFlags ().ToString ();
          //Time
          lfTime = _NP.getRaceTime ();
          liMin = Mathf.FloorToInt (lfTime / 60.0f);
          liSec = Mathf.FloorToInt(lfTime - liMin * 60.0f);
          liRem = Mathf.FloorToInt (1000.0f * (lfTime - Mathf.FloorToInt(lfTime)));
          slot.FindChild ("Time").GetComponent<Text> ().text = liMin + ":" + liSec + ":" + liRem;
        } //End foreach(GameObject p in GameObject.Find("GameManager").GetComponent<GameManager>().players)
        break;

          case UI_STATE.SBPointTransfer:
        changeState (3, UI_STATE.SBTransferWait);
        float fdt = 4 * (fSBTimes [2] - fTimer); //This isn't perfect but it works for now
        foreach (GameObject p in players){
          NetPlayer _NP = p.GetComponent<NetPlayer> ();
          Transform slot = Scorboard.transform.FindChild ("Slots").GetChild (_NP.getPlace () - 1);
          int liPoints = Mathf.FloorToInt (GameManager.POINTS [_NP.getPlace()-1] - fdt + (_NP.hasFlag() ? 4 : 0));
          if (liPoints <= 0.0f)
            slot.FindChild ("Points").GetComponent<Text> ().text = _NP.getPoints ().ToString();
          else
            slot.FindChild ("Points").GetComponent<Text> ().text =
              _NP.getPoints () - liPoints + " + " + liPoints;
        }
        break;

          case UI_STATE.SBTransferWait:
        changeState (4, UI_STATE.SBRearrange);
        break;

          case UI_STATE.SBRearrange:
        changeState (5, UI_STATE.SBFinal);
        for(int i = 0; i<8; i++){
          //Relavent script and placing slot
          NetPlayer _NP = players[iPlayerNums[i]].GetComponent<NetPlayer> ();
          Transform slot = Scorboard.transform.FindChild ("Slots").GetChild (_NP.getPlace () - 1);
          RectTransform rect = slot.gameObject.GetComponent<RectTransform> ();
          rect.offsetMin = new Vector2 (0, -75 * (i));
          rect.offsetMax = new Vector2 (1, -75 - 75 * (i));
        }
        break;

          case UI_STATE.SBFinal:
        changeState (6, UI_STATE.SBDone);
        break;

          case UI_STATE.SBDone:
        _NetPlayer.setPlayerState (NetPlayer.PLAYER_STATE.SceneOutro);
        break;

          default:
        Debug.LogError ("Error: SpHUD.cs 107: UIState not detected.");
        break;
          } //End switch(UIState)
        } //End else
    }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     cdtimer = GameObject.FindGameObjectWithTag("countdown");
     cdtimer.GetComponent<Image>().sprite = cDown[3];
     //Initialize all variables to their starting positions\
     UIState = UI_STATE.None;
     PlayerPrefs.SetFloat ("start", 0);
       IsPaused = false;
 }
Beispiel #10
0
 private bool changeState(int iTimer, UI_STATE state)
 {
     bool lbResult = false;
     if (fTimer <= fSBTimes [iTimer]){
       UIState = state;
       lbResult = true;
     }
     return lbResult;
 }
Beispiel #11
0
 public void startScoreboard()
 {
     UIState = UI_STATE.SBWait;
     fTimer = fSBTimes[0];
 }
Beispiel #12
0
 public void startCountdown()
 {
     UIState = UI_STATE.Countdown;
     fTimer = 3.0f;
     cdtimer.SetActive (true);
 }