Exemple #1
0
 public void SaveMove()
 {
     if (!AvailableMoves.ContainsName(move.GetName()) && !move.GetName().Equals(string.Empty))
     {
         AvailableMoves.AddMove((Move)move.Clone());
         SaveLoad.Save(AvailableMoves.GetMoves());             //Save every time save button is clicked in case game crashes while still in scene.
         ResetMoveEditor();
     }
     else
     {
         saveButton.interactable = false;
     }
 }
Exemple #2
0
 /// <summary>
 /// If the scene stack is non empty, pops the stack and loads the top scene.
 /// If the current scene is the MoveEditor, a "Are you sure"-dialog is opened to not discard the move.
 /// </summary>
 public static void GoBack()
 {
     if (sceneStack.Count > 0)
     {
         float fadeTime = GameObject.Find("Canvas").GetComponent <SceneFade>().BeginFade(1);
         Wait(fadeTime);
         if (SceneManager.GetActiveScene().name == "MoveEditorScene")
         {
             SaveLoad.Save(AvailableMoves.GetMoves());
         }
         string previousSceneName = (string)sceneStack.Pop();
         if (scenePathsList.Contains(previousSceneName))
         {
             SceneManager.LoadScene(previousSceneName);
         }
     }
 }
Exemple #3
0
    public void Init()
    {
        deleteMovePrompt.SetActive(false);
        scrollDelay = 0;
        //Hide the play button untill each character has a move assigned to each of its used buttons.
        playText.SetActive(false);
        //Create a list item for each available move.
        moves = AvailableMoves.GetMoves();

        //Make list items as high as the MeasuingPanel which is 1/7 of the viewport.
        RectTransform measuringPanel = GameObject.Find("MeasuringPanel").GetComponent <RectTransform> ();

        listItemHeight     = measuringPanel.rect.height;
        nbrOfVisiblePanels = 7;

        //Update viewport content size to make room for all moves.
        GameObject    listViewContent     = gameObject;
        RectTransform listViewContentRect = listViewContent.GetComponent <RectTransform> ();
        Vector2       viewContentSize     = listViewContentRect.sizeDelta;
        Vector2       viewContentNewSize  = new Vector2(viewContentSize.x, (moves.Count + 1) * listItemHeight);   // +1 for margin

        listViewContentRect.sizeDelta = viewContentNewSize;

        int nbrOfRightMoveType = 0;

        for (int i = 0; i < moves.Count; i++)
        {
            Move move = moves [i];
            if (move.IsBlockMove() == containsBlockMoves)
            {
                nbrOfRightMoveType++;
            }
        }
        listItems = new MovePanelBehaviour[nbrOfRightMoveType];
        int j = 0;

        for (int i = 0; i < moves.Count; i++)
        {
            Move move = moves [i];
            if (move.IsBlockMove() == containsBlockMoves)
            {
                GameObject previewPanel = CreateMovePanel(move, transform);
                listItems[j] = previewPanel.GetComponent <MovePanelBehaviour> ();                //Get the interaction script from the created list item.
                j++;
            }
        }

        //Get a reference to the interaction script of each panel viewing the currently selected moves of each character and place them in a list.
        selectedMovesPanels = new SelectionPanelBahviour[2];
        for (int i = 0; i < selectedMovesPanels.Length; i++)
        {
            // (Panel(i+1) is used becuase the panels are named Panel1 and Panel2, not Panel0 and Panel1)
            selectedMovesPanels[i] = GameObject.Find("SelectedMovesPanel" + (i + 1)).GetComponent <SelectionPanelBahviour> ();
            Character character = StaticCharacterHolder.characters [i];
            //Make sure there is actually a characters present for each selected moves panel.
            if (character == null)
            {
                continue;
            }
            selectedMovesPanels [i].SetOwner(character);
        }

        if (listItems.Length > 0)
        {
            listItems [selectedListIndex].Select();
            if (selectedListIndex > nbrOfVisiblePanels / 2 && hasDeleted && listItems.Length >= nbrOfVisiblePanels)
            {
                ScrollList(-1);
                hasDeleted = false;
            }

            ReselectMoves();
        }

        if (selected)
        {
            PlayAnimation(1);
        }
    }