public void Start() { var entDB = GameObject.FindGameObjectWithTag("LevelController"); playerManager = entDB.GetComponent <PlayerManager>(); gameController = entDB.GetComponent <GameController>(); playerActivatorMenu.setPlayer(playerData); _Camera.verticalAxisName = "L_YAxis_" + playerData.controllerNumber; _Camera.horizontalAxisName = "L_XAxis_" + playerData.controllerNumber; //set side UIAnchor.Side[] Sides = new UIAnchor.Side[] { UIAnchor.Side.TopLeft, UIAnchor.Side.TopRight, UIAnchor.Side.BottomLeft, UIAnchor.Side.BottomRight }; anchor.side = Sides[playerData.controllerNumber - 1]; AbilityBarGrid.UpdateGrid(); AbilityPanelGrid.UpdateGrid(); UpgradeGrid.UpdateGrid(); if (playerData.state == PlayerState.ready) { state = AbilityMenuState.Bar; } changeState(state); }
public void Start() { var entDB=GameObject.FindGameObjectWithTag("LevelController"); playerManager=entDB.GetComponent<PlayerManager>(); gameController=entDB.GetComponent<GameController>(); playerActivatorMenu.setPlayer (playerData); _Camera.verticalAxisName="L_YAxis_"+playerData.controllerNumber; _Camera.horizontalAxisName="L_XAxis_"+playerData.controllerNumber; //set side UIAnchor.Side[] Sides=new UIAnchor.Side[]{UIAnchor.Side.TopLeft,UIAnchor.Side.TopRight,UIAnchor.Side.BottomLeft,UIAnchor.Side.BottomRight}; anchor.side=Sides[playerData.controllerNumber-1]; AbilityBarGrid.UpdateGrid (); AbilityPanelGrid.UpdateGrid (); UpgradeGrid.UpdateGrid (); if (playerData.state==PlayerState.ready) state=AbilityMenuState.Bar; changeState (state); }
void changeState(AbilityMenuState state) { disableSwap(); var old_state=this.state; this.state = state; _Camera.setAnalogStickDelaysDefault (); GameMenu.gameObject.SetActive (true); playerActivatorMenu.gameObject.SetActive (false); ShopPanel.SetActive (false); UpgradePanel.gameObject.SetActive (false); hp_slider.gameObject.SetActive (false); mp_slider.gameObject.SetActive (false); if (state == AbilityMenuState.Off) { playerActivatorMenu.gameObject.SetActive (true); GameMenu.gameObject.SetActive (false); playerActivatorMenu.setState (PlayerState.notConnected); gameController.startCounter (true); } if (state == AbilityMenuState.Bar) { menu_BG_panel.enableButtonHelper(true); menu_BG_panel.setPlayer(playerData); _Camera.selectedObjectInput = AbilityBarGrid.gameObject; AbilityBarGrid.HighlightCurrent (); gameController.startCounter (false); }else if (old_state == AbilityMenuState.Bar) { menu_BG_panel.enableButtonHelper(false); } if (state == AbilityMenuState.Shop) { ShopPanel.SetActive (true); _Camera.selectedObjectInput = AbilityPanelGrid.gameObject; AbilityPanelGrid.HighlightCurrent (); } if (state == AbilityMenuState.Upgrade) { if (GetSelectedBar ().Ability.Ability.GetComponent<UpgradeStats> ().AvailableUpgrades.Length > 0) { _Camera.AnalogHorizontalDelay = 0.1f; UpgradePanel.gameObject.SetActive (true); UpgradePanel.setAbility (GetSelectedBar ().Ability); _Camera.selectedObjectInput = UpgradeGrid.gameObject; UpgradeGrid.HighlightCurrent(); } else return; } if (old_state == AbilityMenuState.Upgrade) {//Coming from upgrade UpgradePanel.clearGrid(); } if (old_state == AbilityMenuState.Ready) {//Coming from ready menu_BG_panel.gameObject.SetActive (true); playerManager.DestroyPlayer (playerData); } if (state == AbilityMenuState.Ready) {//Going to ready menu_BG_panel.gameObject.SetActive (false); _Camera.selectedObjectInput = null; _Camera.selectedObjectHighlight = null; hp_slider.gameObject.SetActive (true); mp_slider.gameObject.SetActive (true); //set player data //save selected abilities. int i=0; foreach (var item in AbilityBarGrid.Grid) { var a = item.GetComponent<ItemContainerMain>().Ability; playerData.Abilities[i]=a; i++; } //create player object playerManager.CreatePlayer (playerData); gameController.startCounter (true); } }
void changeState(AbilityMenuState state) { disableSwap(); var old_state = this.state; this.state = state; _Camera.setAnalogStickDelaysDefault(); GameMenu.gameObject.SetActive(true); playerActivatorMenu.gameObject.SetActive(false); ShopPanel.SetActive(false); UpgradePanel.gameObject.SetActive(false); hp_slider.gameObject.SetActive(false); mp_slider.gameObject.SetActive(false); if (state == AbilityMenuState.Off) { playerActivatorMenu.gameObject.SetActive(true); GameMenu.gameObject.SetActive(false); playerActivatorMenu.setState(PlayerState.notConnected); gameController.startCounter(true); } if (state == AbilityMenuState.Bar) { menu_BG_panel.enableButtonHelper(true); menu_BG_panel.setPlayer(playerData); _Camera.selectedObjectInput = AbilityBarGrid.gameObject; AbilityBarGrid.HighlightCurrent(); gameController.startCounter(false); } else if (old_state == AbilityMenuState.Bar) { menu_BG_panel.enableButtonHelper(false); } if (state == AbilityMenuState.Shop) { ShopPanel.SetActive(true); _Camera.selectedObjectInput = AbilityPanelGrid.gameObject; AbilityPanelGrid.HighlightCurrent(); } if (state == AbilityMenuState.Upgrade) { if (GetSelectedBar().Ability.Ability.GetComponent <UpgradeStats> ().AvailableUpgrades.Length > 0) { _Camera.AnalogHorizontalDelay = 0.1f; UpgradePanel.gameObject.SetActive(true); UpgradePanel.setAbility(GetSelectedBar().Ability); _Camera.selectedObjectInput = UpgradeGrid.gameObject; UpgradeGrid.HighlightCurrent(); } else { return; } } if (old_state == AbilityMenuState.Upgrade) //Coming from upgrade { UpgradePanel.clearGrid(); } if (old_state == AbilityMenuState.Ready) //Coming from ready { menu_BG_panel.gameObject.SetActive(true); playerManager.DestroyPlayer(playerData); } if (state == AbilityMenuState.Ready) //Going to ready { menu_BG_panel.gameObject.SetActive(false); _Camera.selectedObjectInput = null; _Camera.selectedObjectHighlight = null; hp_slider.gameObject.SetActive(true); mp_slider.gameObject.SetActive(true); //set player data //save selected abilities. int i = 0; foreach (var item in AbilityBarGrid.Grid) { var a = item.GetComponent <ItemContainerMain>().Ability; playerData.Abilities[i] = a; i++; } //create player object playerManager.CreatePlayer(playerData); gameController.startCounter(true); } }