OnPlayerIsMarried

From Intrigues Wiki
Revision as of 15:47, 24 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>onPlayerIsMarried</code> Event in Actor Class == === Overview === The <code>onPlayerIsMarried</code> event within the <code>Actor</code> class is triggered when the player-character gets married. This event is significant in games where marriage between characters impacts narrative progression, character development, or gameplay mechanics. === Description === * Event Type: <code>Action<Actor, Actor></code> * Functionality: This event is activated upon the mar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

onPlayerIsMarried Event in Actor Class

Overview

The onPlayerIsMarried event within the Actor class is triggered when the player-character gets married. This event is significant in games where marriage between characters impacts narrative progression, character development, or gameplay mechanics.

Description

  • Event Type: Action<Actor, Actor>
  • Functionality: This event is activated upon the marriage of the player-character to another actor. It receives two Actor parameters representing the couple who are getting married. This allows the game to execute specific actions or logic in response to this significant character event.

Usage

The event can be used to trigger updates or custom actions within the game when the player-character marries, such as updating character status, unlocking new gameplay features, or advancing storylines based on the new marital relationship.

Subscribing to the Event

To effectively respond to the onPlayerIsMarried event, subscribe a method with the signature Action<Actor, Actor> within a MonoBehaviour script. It's important to unsubscribe from the event to maintain optimal game performance and prevent unintended behavior.

Example of Usage

public class MarriageEventHandler : MonoBehaviour {
    public Actor playerCharacter;

    void Start() {
        if (playerCharacter != null) {
            playerCharacter.onPlayerIsMarried += OnPlayerMarried;
        }
    }

    private void OnPlayerMarried(Actor spouse1, Actor spouse2) {
        Debug.Log($"{spouse1.FullName} and {spouse2.FullName} are now married.");
        // Logic to handle the marriage event of the player-character
    }

    void OnDestroy() {
        if (playerCharacter != null) {
            playerCharacter.onPlayerIsMarried -= OnPlayerMarried;
        }
    }
}

In this Unity script, MarriageEventHandler is attached to a GameObject and subscribes to the onPlayerIsMarried event of a player-character Actor. When the player-character gets married, the OnPlayerMarried method is called, providing an opportunity to react to the marriage, such as updating the characters' statuses or triggering related narrative events.

Remarks

  • The onPlayerIsMarried event adds a layer of depth to gameplay, reflecting significant life events and their impact on the player-character's journey.
  • Properly managing this event can contribute to a richer narrative experience, offering a more immersive and responsive environment.
  • This event is especially relevant in role-playing games, simulation games, and other genres where character relationships and life events play a central role in the game's progression.