Exemplo n.º 1
0
 private void Awake()
 {
     if (instance != null)
     {
         Debug.Log("Multiple PlayerPanelController. Something went wrong");
     }
     instance = this;
 }
Exemplo n.º 2
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
 private void UpdatePlayerPanelHealthBar(float h)
 {
     PlayerPanelController.SetPlayerHealth(h / SimulationSettings.PlayerMaxHealth);
 }
Exemplo n.º 4
0
    public void DisplayVersusModeSubMenu1()
    {
        ApplicationUtils.ClearDifficultyAffectation();

        if (versusModeSubMenuElements.Count > 0)
        {
            versusModeSubMenuElements.Clear();
        }

        ApplicationUtils.playerNumber = 2;

        this.ManageCurrentDisplay();

        GameObject graphicInterface = GameUtils.FetchGraphicInterface();

        RectTransform graphicInterfaceRectTransform = graphicInterface.GetComponent <RectTransform>();

        GameObject instantiatedVersusModePanel = Instantiate(versusModeOptionsPanel);

        instantiatedVersusModePanel.transform.SetParent(graphicInterface.transform, false);

        Button instantiatedVersusModePanelButton = instantiatedVersusModePanel.GetComponentsInChildren <Transform>()
                                                   .Where(child => child.gameObject.CompareTag(TagConstants.TAG_NAME_MAIN_MENU_BUTTON))
                                                   .Select(child => child.GetComponent <Button>())
                                                   .First();

        instantiatedVersusModePanelButton.onClick.AddListener(this.LaunchTwoPlayerMode);

        RectTransform instantiatedVersusModePanelRectTransform = instantiatedVersusModePanel.GetComponent <RectTransform>();

        instantiatedVersusModePanelRectTransform.anchoredPosition3D = Vector3.zero;

        for (int i = 0; i < ApplicationUtils.playerNumber; i++)
        {
            GameObject    instantiatedPlayerSideSelectionPanel = Instantiate(playerSideSelectionPanel);
            RectTransform instantiatedPlayerPanelRectTransform = instantiatedPlayerSideSelectionPanel.GetComponent <RectTransform>();

            instantiatedPlayerSideSelectionPanel.transform.SetParent(graphicInterface.transform, false);

            PlayerPanelController playerPanelControllerScript = instantiatedPlayerSideSelectionPanel.GetComponent <PlayerPanelController>();
            playerPanelControllerScript.OwnerId = i;
            instantiatedPlayerPanelRectTransform.anchoredPosition3D = new Vector3(0, playerPanelControllerScript.CalculateTargetYposition(graphicInterfaceRectTransform), 0);

            Image instantiatedPlayerSideSelectionPanelImage = instantiatedPlayerSideSelectionPanel.GetComponent <Image>();
            instantiatedPlayerSideSelectionPanelImage.color = ApplicationUtils.GetPlayerColor(i);

            Text instantiatedPlayerSideSelectionPanelText = instantiatedPlayerSideSelectionPanel.GetComponentInChildren <Text>();

            string playerNumberId = "";

            if ((int)PlayerEnum.PlayerId.PLAYER_1 == i)
            {
                playerNumberId = "1";
            }
            else if ((int)PlayerEnum.PlayerId.PLAYER_2 == i)
            {
                playerNumberId = "2";
            }

            instantiatedPlayerSideSelectionPanelText.text = instantiatedPlayerSideSelectionPanelText.text.Replace("{0}", playerNumberId);

            versusModeSubMenuElements.Add(instantiatedPlayerSideSelectionPanel);
        }

        versusModeSubMenuElements.Add(instantiatedVersusModePanel);

        this.CurrentMenuId = (int)MenuEnum.MenuId.VERSUS_MODE;
    }
 public void AssignControlPanel(PlayerPanelController panel)
 {
     ControlPanel = panel;
     ControlPanel.OnButtonClicked += ControlPanel_OnButtonClicked;
 }
 public void AssignPanel(PlayerPanelController panel)
 {
     controller.AssignControlPanel(panel);
 }