コード例 #1
0
    // executes when an object with this script is clicked
    public void OnPointerClick(PointerEventData eventData)
    {
        if (playerImage.sprite != emptySprite)                              // checks if player slot sprite is not empty
        {
            AudioManager.instance.PlaySFX(5);                               // plays UI beep
            tooltip.gameObject.SetActive(false);                            // hides tooltip

            if (selectedPlayer.sprite != emptySprite)                       // checks if select player sprite is not empty
            {
                PartyObject clone = new PartyObject(selectedPlayer.sprite); // clones selected player to store for image swap
                selectedPlayer.sprite = playerImage.sprite;                 // sets selected player sprite to player slot sprite
                playerImage.sprite    = clone.portrait;                     // sets player slot sprite to cloned sprite
                GameMenu.instance.UpdatePartyOrder();                       // calls function to update party order
            }
            else // executes if selected player sprite is empty
            {
                selectedPlayer.sprite = playerImage.sprite; // sets selected player sprite to player slot sprite
                playerImage.sprite    = emptySprite;        // sets player slot sprite to empty
            }
        }
        else if (selectedPlayer.sprite != emptySprite)     // executes if no player in slot and player selected
        {
            AudioManager.instance.PlaySFX(5);              // plays UI beep
            playerImage.sprite    = selectedPlayer.sprite; // sets player slot sprite to selected player sprite
            selectedPlayer.sprite = emptySprite;           //  sets selected player sprite to empty
            GameMenu.instance.UpdatePartyOrder();          // calls function to update party order
        }
    }
コード例 #2
0
 // creates constructor for PartyObject which copies another PartyObject
 public PartyObject(PartyObject partyObject)
 {
     // constructs PartyObject based on passed PartyObject
     portrait = partyObject.portrait;
 }