Exemplo n.º 1
0
    /// <summary>
    /// Adds the move to the list of selected moves in the slot with the correct button.
    /// </summary>
    /// <param name="button">Button.</param>
    /// <param name="move">Move.</param>
    public void AddMove(string button, Move move)
    {
        foreach (Transform child in transform)
        {
            MovePanelBehaviour panelBehaviour = child.GetComponent <MovePanelBehaviour> ();

            //Panel has to be a move panel.
            if (panelBehaviour == null)
            {
                continue;
            }
            if (panelBehaviour.GetAssignedButton() == null)
            {
                continue;
            }

            //Add move to correct panel and remove it from any other panel.
            if (panelBehaviour.GetAssignedButton().Equals(button))
            {
                RemovePanelWithMove(move.GetName());                   //Remove the move from any panel currently holding the move.
                panelBehaviour.transform.Find("NameText").GetComponent <Text>().color = new Color(0, 0, 0, 1);
                panelBehaviour.setMove(move);
            }
        }
    }
Exemplo n.º 2
0
 void Awake()
 {
     this.attackList       = GameObject.Find("AttackContent").GetComponent <MovePanelListBehaviour> ();
     this.blockList        = GameObject.Find("BlockContent").GetComponent <MovePanelListBehaviour> ();
     this.attackViewport   = GameObject.Find("AttackViewport");
     this.blockViewport    = GameObject.Find("BlockViewport");
     this.blockMovesArrow  = GameObject.Find("BlockMovesArrow");
     this.attackMovesArrow = GameObject.Find("AttackMovesArrow");
     this.moveListHeader   = GameObject.Find("MoveListHeader").GetComponent <MovePanelBehaviour> ();
     this.deleteMovePrompt = GameObject.Find("DeleteMovePrompt");
 }
Exemplo n.º 3
0
    /// <summary>
    /// Creates a move panel.
    /// </summary>
    /// <returns>The move panel.</returns>
    /// <param name="move">Move.</param>
    /// <param name="parent">Parent.</param>
    public GameObject CreateMovePanel(Move move, Transform parent)
    {
        string     previewPath        = "Prefabs" + Path.DirectorySeparatorChar + "MovePanel";
        GameObject previewPanelObject = (GameObject)Resources.Load(previewPath);
        GameObject previewPanel       = Instantiate(previewPanelObject, previewPanelObject.transform.position, previewPanelObject.transform.rotation, parent);

        previewPanel.GetComponent <LayoutElement> ().preferredHeight = listItemHeight;        //Set the preferred height to 1/7 the height of the viewport.
        MovePanelBehaviour panelBehaviour = previewPanel.GetComponent <MovePanelBehaviour> ();

        panelBehaviour.setMove(move);
        return(previewPanel);
    }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a panel to the selected moves of a character.
 /// </summary>
 /// <param name="character">Character.</param>
 /// <param name="button">Button.</param>
 private void AddPanelToCharacterMoves(Character character, string button, int index)
 {
     //Find the panel of the character.
     foreach (SelectionPanelBahviour selectionPanel in selectedMovesPanels)
     {
         if (selectionPanel.GetOwner().Equals(character))
         {
             MovePanelBehaviour movePanel = listItems [index];
             selectionPanel.AddMove(button, movePanel.getMove());
             break;
         }
     }
 }
Exemplo n.º 5
0
    /// <summary>
    /// Clears move from any panel that has a specific move.
    /// </summary>
    /// <param name="moveName">Move name.</param>
    public void RemovePanelWithMove(string moveName)
    {
        //Cannot remove items from list while itterating.
        //Only one panel at a time can hold the same move. This fins it if it exists.
        Transform panelWithMove = null;

        foreach (Transform panel in transform)
        {
            MovePanelBehaviour panelBehaviour = panel.GetComponent <MovePanelBehaviour> ();
            Move panelMove = panelBehaviour.getMove();
            if (panelMove == null)
            {
                continue;                 // Skip panel if it does not have a move.
            }
            string panelMoveName = panelMove.GetName();
            if (panelMoveName.Equals(moveName))
            {
                panelWithMove = panel;
                break;                 //Quit loop when the correct panel is found.
            }
        }
        if (panelWithMove != null)
        {
            //Clear the panel.
            panelWithMove.GetComponent <MovePanelBehaviour>().setMove(null);
            panelWithMove.GetComponent <MovePanelBehaviour> ().RemoveSpeedText();
            panelWithMove.GetComponent <MovePanelBehaviour> ().RemoveStrengthText();
            panelWithMove.GetComponent <MovePanelBehaviour> ().RemoveNameText();
            ResetText(panelWithMove.gameObject);

            GameObject previewCharacter = panelWithMove.GetComponent <MovePanelBehaviour>().getPreviewCharacter();
            if (previewCharacter != null)
            {
                previewCharacter.SetActive(false);
                previewCharacter.GetComponent <MovePlayer>().ShowActiveBodypart(false);
                previewCharacter.GetComponent <MovePlayer>().setMoveToPlay(null);
            }
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Goes through all previously selected moves from InputSettings and selects them in the GUI.
    /// </summary>
    public void ReselectMoves()
    {
        List <string> usedButtons = InputSettings.allUsedButtons;

        //For every used button, if the move asigned to it matches that of a panel list item. Mark that list item in GUI.
        foreach (string button in usedButtons)
        {
            string buttonMoveName = InputSettings.GetMoveName(button);
            for (int i = 0; i < listItems.Length; i++)
            {
                MovePanelBehaviour listItem = listItems [i];
                Move panelMove = listItem.getMove();
                if (panelMove == null)
                {
                    continue;
                }
                if (panelMove.GetName().Equals(buttonMoveName))
                {
                    RegisterPlayerMoveToButton(button, i);
                }
            }
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Init this instance. Adds slots for the buttons of the current owner to the list of moves.
    /// This is init and not start because the owner is not set form the start.
    /// </summary>
    void Init()
    {
        //TODO: In case we ever set owner twice, we would have to delete all children of the panel.
        this.inited = true;
        panels      = new List <GameObject> ();
        List <string> character1Buttons = InputSettings.GetCharacterButtons(owner.GetNbr());

        foreach (string characterButton in character1Buttons)
        {
            string previewPath          = "Prefabs" + Path.DirectorySeparatorChar + "MovePanel";
            string previewCharacterPath = "Prefabs" + Path.DirectorySeparatorChar + "Character";

            GameObject previewPanelObject     = (GameObject)Resources.Load(previewPath);
            GameObject previewCharacterObject = (GameObject)Resources.Load(previewCharacterPath);
            previewCharacterObject.GetComponent <CharacterCollisionDetector>().enabled = false;
            GameObject previewPanel = Instantiate(previewPanelObject, previewPanelObject.transform.position, previewPanelObject.transform.rotation, transform);

            if (owner.GetNbr() == 1)
            {
                foreach (Transform child in previewPanel.transform)
                {
                    //Flip all text fields.
                    //The transform of player 1 is flipped. So if all children are not flipped as well, the text is reversed.
                    child.GetComponent <RectTransform> ().localScale = new Vector3(-1, 1, 1);
                }
            }

            //Make selection panel list entries have the default button sprite to make them look less like an interactable list.
            //string defaultButtonPath = "UI/Skin/Background.psd";
            string defaultButtonPath = "Art/Main Menu/button_up_test";
            if (System.IO.File.Exists(defaultButtonPath))
            {
                Debug.Log("foooound! file ");
            }
            //Sprite defaultButtonSprite = AssetDatabase.GetBuiltinExtraResource<Sprite> (defaultButtonPath);
            Sprite defaultButtonSprite = Resources.Load <Sprite>(defaultButtonPath);
            previewPanel.GetComponent <Image> ().sprite = defaultButtonSprite;

            ResetText(previewPanel);

            foreach (Transform child in previewPanel.transform)
            {
                Text text = child.GetComponent <Text> ();
                if (text != null)
                {
                    text.fontSize = 24;
                }
            }

            GameObject previewCharacter = Instantiate(previewCharacterObject, previewCharacterObject.transform.position, previewCharacterObject.transform.rotation, previewPanel.transform);

            previewPanel.GetComponent <MovePanelBehaviour>().addPreviewCharacter(previewCharacter);

            float characterPosition;

            if (owner.GetNbr() == 1)
            {
                characterPosition = 2.4f;
            }
            else
            {
                characterPosition = -2.4f;
            }

            previewCharacter.transform.position   = new Vector2(characterPosition * previewPanel.transform.localScale.x, 0);
            previewCharacter.transform.localScale = new Vector3(3 * -previewPanel.transform.localScale.x, 3, 3);

            previewCharacter.SetActive(false);

            MovePanelBehaviour panelBehaviour = previewPanel.GetComponent <MovePanelBehaviour> ();
            if (owner != null)
            {
                string characterButtonDisplayName = characterButton;
                if (characterButtonDisplayName.Length > 1)
                {
                    characterButtonDisplayName = UnityUtils.ControllerButtonToDisplayName(characterButtonDisplayName);
                }
                panelBehaviour.AssignButton(characterButtonDisplayName, owner.GetColor(), 2);
            }
        }
    }