void HandleCharacterPreview(PlayerInterfaces pl) { //если у нас есть отображаемый портрет бойца, который не совпадает с активным (выбираемым нами) //это значит мы изменили персонажей if (pl.previewPotrait != pl.activePotrait) { if (pl.createdCharacter != null)//удаляем выбор персонажа, если игрок осуществил таковой { Destroy(pl.createdCharacter); } //и мы создаем нового GameObject go = Instantiate( CharacterManager.GetInstance().returnCharacterWithID(pl.activePotrait.characterId).prefab, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPotrait = pl.activePotrait; if (!string.Equals(pl.playerBase.playerId, charManager.players[0].playerId)) { pl.createdCharacter.GetComponent <StateManager>().lookRight = false; } } }
void HandleCharacterPreview(PlayerInterfaces pl) { //if the previews potrait we had, is not the same as the active one we have //that means we changed characters if (pl.previewPotrait != pl.activePotrait) { if (pl.createdCharacter != null)//delete the one we have now if we do have one { Destroy(pl.createdCharacter); } //and create another one GameObject go = Instantiate( CharacterManager.GetInstance().returnCharacterWithID(pl.activePotrait.characterId).prefab, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPotrait = pl.activePotrait; if (!string.Equals(pl.playerBase.playerId, charManager.players[0].playerId)) { pl.createdCharacter.GetComponent <StateManager>().lookRight = false; } } }
void HandleCharacterPreview(PlayerInterfaces pl) { //Se o previews potrait tivemos, nao eh o mesmo que esta ativa uma que temos //Entao significa que precisa trocar de personagem if (pl.previewPotrait != pl.activePotrait) { if (pl.createdCharacter != null)// Deleta o anterior { Destroy(pl.createdCharacter); } //E cria outro GameObject go = Instantiate( CharacterManager.GetInstance().returnCharacterWithID(pl.activePotrait.characterId).prefab, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPotrait = pl.activePotrait; if (!string.Equals(pl.playerBase.playerId, charManager.players[0].playerId)) { pl.createdCharacter.GetComponent <StateManager>().lookRight = false; } } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxY - 1; } else { pl.activeY = (pl.activeY < maxY - 1) ? pl.activeY + 1 : 0; } pl.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxX - 1; } else { pl.activeX = (pl.activeX < maxX - 1) ? pl.activeX + 1 : 0; } pl.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } // Actual Character Selection if (Input.GetButtonDown("Submit" + playerId)) { Debug.Log("player" + playerId + " has selected a character"); //Passes to Character Manager pl.playerBase.playerprefab = charManager.returnCharacterWithID(pl.activePortrait.CharacterId).prefab; pl.playerBase.hasCharacter = true; } }
void HandleSelectorPosition(PlayerInterfaces p1) { p1.selector.SetActive(true); //find the active portrait p1.activePortrait = charGrid[p1.activeX, p1.activeY]; //place the selector over the position Vector2 selectorPosition = p1.activePortrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(portraitCanvas.transform.localPosition.x, portraitCanvas.transform.localPosition.y); p1.selector.transform.localPosition = selectorPosition; }
void HandleSelectorPosition(PlayerInterfaces pl) { // activate character selector pl.selector.SetActive(true); //find active portrait pl.activePotrait = charGrid[pl.activeX, pl.activeY]; // place selector over position Vector2 selectorPosition = pl.activePotrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(potraitCanvas.transform.transform.localPosition.x, potraitCanvas.transform.localPosition.y); pl.selector.transform.localPosition = selectorPosition; }
void HandleSelectorPosition(PlayerInterfaces pl) { pl.selector.SetActive(true); pl.activePortrait = charGrid[pl.activeX, pl.activeY]; Vector2 selectorPosition = pl.activePortrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(portraitCanvas.transform.localPosition.x , portraitCanvas.transform.localPosition.y); pl.selector.transform.localPosition = selectorPosition; }
void HandleSelectorPosition(PlayerInterfaces pl) { pl.selector.SetActive(true); //Habilitado o selector pl.activePotrait = charGrid[pl.activeX, pl.activeY]; //Encontra o potrait ativado //E coloca o seletor em cima de uma posicao Vector2 selectorPosition = pl.activePotrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(potraitCanvas.transform.localPosition.x , potraitCanvas.transform.localPosition.y); pl.selector.transform.localPosition = selectorPosition; }
//mouse over character stuff - find out how to get smooth animations instead of character prefab so that menus can move better void HandleCharacterPreview(PlayerInterfaces pl) { if (pl.previewPortrait != pl.activePortrait) { if (pl.createdCharacter != null) { Destroy(pl.createdCharacter); } GameObject go = Instantiate(CharacterManager.GetInstance().returnCharacterWithID(pl.activePortrait.characterId).prefab, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPortrait = pl.activePortrait; if (string.Equals(pl.playerBase.playerId, charManager.players[0].playerId)) { pl.createdCharacter.GetComponent <StateManager>().lookRight = false; } } }
void HandleSelectorPosition(PlayerInterfaces pl) //обновляет положение рамки выбора бойца { pl.selector.SetActive(true); //включить рамку выбора бойца PotraitInfo pi = ReturnPotrait(pl.activeX, pl.activeY); if (pi != null) { pl.activePotrait = pi;//находим активный портрет бойца //помещаем рамку на выбранную позицию Vector2 selectorPosition = pl.activePotrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(potraitCanvas.transform.localPosition.x , potraitCanvas.transform.localPosition.y); pl.selector.transform.localPosition = selectorPosition; } }
void HandleSelectorPosition(PlayerInterfaces pl) { pl.selector.SetActive(true); //enable the selector PotraitInfo pi = ReturnPotrait(pl.activeX, pl.activeY); // if (pi != null) { pl.activePotrait = pi; //find the active potrait //and place the selector over it's position Vector2 selectorPosition = pl.activePotrait.transform.localPosition; selectorPosition = selectorPosition + new Vector2(potraitCanvas.transform.localPosition.x , potraitCanvas.transform.localPosition.y); pl.selector.transform.localPosition = selectorPosition; } }
void HandleCharacterPreview(PlayerInterfaces pl) { if (pl.previewPortrait != pl.activePortrait) { //shes broken here shes not accessing this if statement ^ if (pl.createdCharacter != null) { Destroy(pl.createdCharacter); } GameObject go = Instantiate( CharacterManager.getInstance().returnCharacterWithID(pl.activePortrait.CharacterId).displayIcon, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPortrait = pl.activePortrait; } }
void HandleCharacterPreview(PlayerInterfaces pl) { if (pl.previewPortrait != pl.activePortrait) // if previous port isnt the same of active = we changed chars, so { if (pl.createdCharacter != null) // if we have one char { Destroy(pl.createdCharacter); //destroy it } //and create another one GameObject go = Instantiate( CharacterManager.GetInstance().GetCharByID(pl.activePortrait.characterId).prefab, pl.charVisPos.position, Quaternion.identity) as GameObject; pl.createdCharacter = go; pl.previewPortrait = pl.activePortrait; if (!string.Equals(pl.playerBase.playerId, charManager.players[0].playerId)) { // pl.createdCharacter.GetComponent<StateManager> ().lookRight = false; } } }
void HandleCharacterPreview(PlayerInterfaces p1) { //if the preview portrait and the active portrait is not the same we need to change the portrait if (p1.previewPortrait != p1.activePortrait) { if (p1.createdCharacter != null) { Destroy(p1.createdCharacter); } //create another portrait GameObject go = Instantiate (CharacterManager.GetInstance().ReturnCharacterWithID(p1.activePortrait.characterID).prefab, p1.charVisPos.position, Quaternion.identity) as GameObject; p1.createdCharacter = go; p1.previewPortrait = p1.activePortrait; if (!string.Equals(p1.playerBase.playerID, charManager.players[0].playerID)) { //p1.createdCharacter.GetComponent<StateManager>().lookRight = false; } } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation /*To navigate in the grid * we simply change the active x and y to select what entry is active * we also smooth out the input so if the user keeps pressing the button * it won't switch more than once over half a second */ float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxCollumn; } else { pl.activeY = (pl.activeY < maxCollumn) ? pl.activeY + 1 : 0; } pl.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxRow - 1; } else { pl.activeX = (pl.activeX < maxRow - 1) ? pl.activeX + 1 : 0; } pl.timerToReset = 0; pl.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } if (pl.hitInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > 0.8f) { pl.hitInputOnce = false; pl.timerToReset = 0; } } #endregion //если игрок нажал "пробел", то он определился в выборе бойца if (Input.GetButtonUp("Fire1" + playerId)) { //проиграем анимацию удара (можно любую другую), //чтобы показать реакцию персонажа, потому что почему бы и нет pl.createdCharacter.GetComponentInChildren <Animator>().Play("Kick"); //пропустить персонажа в контроллер персонажей, чтобы он понял, какой префаб выбран игроком pl.playerBase.playerPrefab = charManager.returnCharacterWithID(pl.activePotrait.characterId).prefab; pl.playerBase.hasCharacter = true; } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation /* To navigate grid, change active X and Y to select which entry is active * smooth input to reduce speed of selection if button held down */ float verticle = Input.GetAxis("Vertical" + playerId); if (verticle != 0) { if (!pl.hasInputOnce) { if (verticle > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxY - 1; } else { pl.activeY = (pl.activeY < maxY - 1) ? pl.activeY + 1 : 0; } pl.hasInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hasInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxX - 1; } else { pl.activeX = (pl.activeX < maxX - 1) ? pl.activeX + 1 : 0; } pl.timerToReset = 0; pl.hasInputOnce = true; } } if (verticle == 0 && horizontal == 0) { pl.hasInputOnce = false; } if (pl.hasInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > 0.8f) { pl.hasInputOnce = false; pl.timerToReset = 0; } } #endregion // space bar to select character if (Input.GetButtonUp("Fire1" + playerId)) { audioManager.soundPlay("Effect_Hit"); // characterReact pl.createdCharacter.GetComponentInChildren <Animator>().Play("Kick"); // pass character to character manager pl.playerBase.playerPrefab = charManager.returnCharacterWithId(pl.activePotrait.characterId).prefab; pl.playerBase.hasCharacter = true; } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation /*Para navegar no grid * Simplesmente mudamos o active x e y para selectionar o que ativar * E tambem suaviza o input se voce continuar pressionando o botao * Nao vai mudar mais que um por meio segundo */ float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxY - 1; } else { pl.activeY = (pl.activeY < maxY - 1) ? pl.activeY + 1 : 0; } pl.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxX - 1; } else { pl.activeX = (pl.activeX < maxX - 1) ? pl.activeX + 1 : 0; } pl.timerToReset = 0; pl.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } if (pl.hitInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > 0.8f) { pl.hitInputOnce = false; pl.timerToReset = 0; } } #endregion if (Input.GetButtonUp("Fire1" + playerId)) { pl.createdCharacter.GetComponentInChildren <Animator>().Play("Kick"); pl.playerBase.playerPrefab = charManager.returnCharacterWithID(pl.activePotrait.characterId).prefab; pl.playerBase.hasCharacter = true; } //Se meu jogador 1 selecionar o seu personagem, entao o segundo jogador ira ser selecionado if (charManager.players[0].hasCharacter == true) { if (charManager.players[1].hasCharacter == false) { pl.playerBase.playerPrefab = charManager.returnCharacterWithID(pl.activePotrait.characterId).prefab; pl.playerBase.hasCharacter = true; pl.createdCharacter.GetComponentInChildren <Animator>().Play("Kick"); } } }
void HandleSelectScreenInput(PlayerInterfaces p1, string playerID) { #region /*To navigate the grid * the active x and y need to change to whichever character is selected * */ float vertical = Input.GetAxis("Vertical" + playerID); if (vertical != 0) { if (!p1.hitInputOnce) { if (vertical > 0) { p1.activeY = (p1.activeY > 0) ? p1.activeY - 1 : maxY - 1; } else { p1.activeY = (p1.activeY - 1 < maxY - 1) ? p1.activeY : 0; } p1.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerID); if (horizontal != 0) { if (!p1.hitInputOnce) { if (horizontal > 0) { p1.activeX = (p1.activeX > 0) ? p1.activeX - 1 : maxX - 1; } else { p1.activeX = (p1.activeX - 1 < maxX - 1) ? p1.activeX : 0; } p1.timerToReset = 0; p1.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { p1.hitInputOnce = false; } if (p1.hitInputOnce) { p1.timerToReset += Time.deltaTime; if (p1.timerToReset > 0.8f) { p1.hitInputOnce = false; p1.timerToReset = 0; } } #endregion //if the player presses A or X a character has been selected if (Input.GetKeyUp(KeyCode.JoystickButton1 + playerID)) { //play an animation when a character is selected //p1.createdCharacter.GetComponentInChildren<Animator>().Play("Something"); p1.playerBase.playerPrefab = charManager.ReturnCharacterWithID(p1.activePortrait.characterID).prefab; p1.playerBase.hasCharacter = true; } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation /*To navigate in the grid * we simply change the active x and y to select what entry is active * we also smooth out the input so if the user keeps pressing the button * it won't switch more than once over half a second */ float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxCollumn; } else { pl.activeY = (pl.activeY < maxCollumn) ? pl.activeY + 1 : 0; } pl.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxRow - 1; } else { pl.activeX = (pl.activeX < maxRow - 1) ? pl.activeX + 1 : 0; } pl.timerToReset = 0; pl.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } if (pl.hitInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > 0.8f) { pl.hitInputOnce = false; pl.timerToReset = 0; } } #endregion //if the user presses space, he has selected a character if (Input.GetButtonUp("Fire1" + playerId)) { //make a reaction on the character, because why not pl.createdCharacter.GetComponentInChildren <Animator>().Play("Kick"); //pass the character to the character manager so that we know what prefab to create in the level pl.playerBase.playerPrefab = charManager.returnCharacterWithID(pl.activePotrait.characterId).prefab; pl.playerBase.hasCharacter = true; } }
void HandleSelectScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.activeY = (pl.activeY > 0) ? pl.activeY - 1 : maxY - 1; } else { pl.activeY = (pl.activeY < maxY - 1) ? pl.activeY + 1 : 0; } pl.hitInputOnce = true; } } float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.activeX = (pl.activeX > 0) ? pl.activeX - 1 : maxX - 1; } else { pl.activeX = (pl.activeX < maxX - 1) ? pl.activeX + 1 : 0; } pl.timerToReset = 0; pl.hitInputOnce = true; } } if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } if (pl.hitInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > 0.8f) { pl.hitInputOnce = false; pl.timerToReset = 0; } } #endregion // if user has pressed space, he has selected a char if (Input.GetButtonUp("Fire1" + playerId)) { // make a reaction on char // pl.createdCharacter.GetComponentInChildren<Animator> ().Play ("Kick"); // pass character to character manager pl.playerBase.playerPrefab = charManager.GetCharByID(pl.activePortrait.characterId).prefab; pl.playerBase.hasCharacter = true; } }
void HandleScreenInput(PlayerInterfaces pl, string playerId) { #region Grid Navigation #region vertical float vertical = Input.GetAxis("Vertical" + playerId); if (vertical != 0) { if (!pl.hitInputOnce) { if (vertical > 0) { pl.ActiveY = (pl.ActiveY > 0) ? pl.ActiveY - 1 : maxY - 1; } else { pl.ActiveY = (pl.ActiveY < maxY - 1) ? pl.ActiveY + 1 : 0; } pl.hitInputOnce = true; } } #endregion #region Horizontal float horizontal = Input.GetAxis("Horizontal" + playerId); if (horizontal != 0) { if (!pl.hitInputOnce) { if (horizontal > 0) { pl.ActiveX = (pl.ActiveX > 0) ? pl.ActiveX - 1 : MaxX - 1; } else { pl.ActiveX = (pl.ActiveX < MaxX - 1) ? pl.ActiveX + 1 : 0; } pl.timerToReset = 0; pl.hitInputOnce = true; } } #endregion if (vertical == 0 && horizontal == 0) { pl.hitInputOnce = false; } if (pl.hitInputOnce) { pl.timerToReset += Time.deltaTime; if (pl.timerToReset > SelectMoveDelay) { pl.hitInputOnce = false; pl.timerToReset = 0; } } #endregion //character has been selected if (Input.GetButtonUp("Block" + playerId)) { //reaction goes here //tell the character manager what preafb to instantiate pl.playerBase.playerPrefab = charManager.returnCharacterWithID(pl.activePortrait.characterId).prefab; confirmClip = charManager.returnCharacterWithID(pl.activePortrait.characterId).selectionClip; confirmSource.clip = confirmClip; confirmSource.Play(); pl.playerBase.hasCharacter = true; } }