Corgi Engine  v9.1
MoreMountains.CorgiEngine.CharacterSwitchManager Class Reference

Add this component to an empty object in your scene, and when you'll press the SwitchCharacter button (P by default, change that in Unity's InputManager settings), your main character will be replaced by one of the prefabs in the list set on this component. You can decide the order (sequential or random), and have as many as you want. Note that this will change the whole prefab, not just the visuals. If you're just after a visual change, look at the CharacterSwitchModel ability. If you want to swap characters between a bunch of characters within a scene, look at the CharacterSwap ability and CharacterSwapManager More...

Inheritance diagram for MoreMountains.CorgiEngine.CharacterSwitchManager:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

enum  NextCharacterChoices { NextCharacterChoices.Sequential, NextCharacterChoices.Random }
 the possible orders the next character can be selected from More...
 

Public Member Functions

virtual void ForceCharacterSwitch ()
 A public method you can use to switch to the next character in the rotation More...
 
virtual void ForceCharacterSwitchTo (int newIndex)
 A public method you can use to switch to a specific character in the array More...
 

Public Attributes

string PlayerID = "Player1"
 the ID of the Player we want this CharacterSwitchManager to control More...
 
int PlayerIndex = 0
 the index of the Player in the LevelManager we want to target More...
 
Character[] CharacterPrefabs
 the list of possible characters prefabs to switch to More...
 
NextCharacterChoices NextCharacterChoice = NextCharacterChoices.Sequential
 the order in which to pick the next character More...
 
int CurrentIndex = 0
 the initial (and at runtime, current) index of the character prefab More...
 
bool CommonHealth
 if this is true, current health value will be passed from character to character More...
 
bool MaintainPreviousCharacterFacingDirection = false
 if this is true, newly switched to characters will flip (if needed) to face the direction the previous character was facing More...
 
ParticleSystem CharacterSwitchVFX
 a particle system to play when a character gets changed More...
 
bool ForceCharacterSwitchButton
 a test button that forces a character switch More...
 
int DebugTargetIndex = 1
 the index that will be used when pressing the DebugCharacterSwitchToTargetIndex button below More...
 
bool DebugCharacterSwitchToTargetIndexButton
 a test button that forces a character switch to the specified index in DebugTargetIndex More...
 
InputManager LinkedInputManager
 the input manager we'll read input on More...
 

Protected Member Functions

virtual void Start ()
 On Awake we grab our input manager and instantiate our characters and VFX More...
 
virtual void GetInputManager ()
 We grab the corresponding input manager More...
 
virtual void InstantiateCharacters ()
 Instantiates and disables all characters in our list More...
 
virtual void InstantiateVFX ()
 Instantiates and disables the particle system if needed More...
 
virtual void Update ()
 On Update we watch for our input More...
 
virtual void DebugCharacterSwitchToTargetIndex ()
 A test method that switches to the specified debug index More...
 
virtual void DetermineNextIndex ()
 Determines the next index to go to based on the choice mode settings More...
 
virtual IEnumerator SwitchCharacter ()
 Switches to the next character in the list More...
 
virtual IEnumerator SwitchCharacter (int newIndex)
 A coroutine to switch to a specific index More...
 
virtual IEnumerator OperateSwitch ()
 A coroutine that changes the character, triggers an event, and sets its Health More...
 

Protected Attributes

Character[] _instantiatedCharacters
 
ParticleSystem _instantiatedVFX
 
CorgiEngineEvent _switchEvent = new CorgiEngineEvent(CorgiEngineEventTypes.CharacterSwitch, null)
 

Detailed Description

Add this component to an empty object in your scene, and when you'll press the SwitchCharacter button (P by default, change that in Unity's InputManager settings), your main character will be replaced by one of the prefabs in the list set on this component. You can decide the order (sequential or random), and have as many as you want. Note that this will change the whole prefab, not just the visuals. If you're just after a visual change, look at the CharacterSwitchModel ability. If you want to swap characters between a bunch of characters within a scene, look at the CharacterSwap ability and CharacterSwapManager

Member Enumeration Documentation

◆ NextCharacterChoices

the possible orders the next character can be selected from

Enumerator
Sequential 
Random 

Member Function Documentation

◆ DebugCharacterSwitchToTargetIndex()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.DebugCharacterSwitchToTargetIndex ( )
protectedvirtual

A test method that switches to the specified debug index

◆ DetermineNextIndex()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.DetermineNextIndex ( )
protectedvirtual

Determines the next index to go to based on the choice mode settings

◆ ForceCharacterSwitch()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.ForceCharacterSwitch ( )
virtual

A public method you can use to switch to the next character in the rotation

◆ ForceCharacterSwitchTo()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.ForceCharacterSwitchTo ( int  newIndex)
virtual

A public method you can use to switch to a specific character in the array

Parameters
newIndex

◆ GetInputManager()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.GetInputManager ( )
protectedvirtual

We grab the corresponding input manager

◆ InstantiateCharacters()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.InstantiateCharacters ( )
protectedvirtual

Instantiates and disables all characters in our list

◆ InstantiateVFX()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.InstantiateVFX ( )
protectedvirtual

Instantiates and disables the particle system if needed

◆ OperateSwitch()

virtual IEnumerator MoreMountains.CorgiEngine.CharacterSwitchManager.OperateSwitch ( )
protectedvirtual

A coroutine that changes the character, triggers an event, and sets its Health

Returns

◆ Start()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.Start ( )
protectedvirtual

On Awake we grab our input manager and instantiate our characters and VFX

◆ SwitchCharacter() [1/2]

virtual IEnumerator MoreMountains.CorgiEngine.CharacterSwitchManager.SwitchCharacter ( )
protectedvirtual

Switches to the next character in the list

◆ SwitchCharacter() [2/2]

virtual IEnumerator MoreMountains.CorgiEngine.CharacterSwitchManager.SwitchCharacter ( int  newIndex)
protectedvirtual

A coroutine to switch to a specific index

Parameters
newIndex
Returns

◆ Update()

virtual void MoreMountains.CorgiEngine.CharacterSwitchManager.Update ( )
protectedvirtual

On Update we watch for our input

Member Data Documentation

◆ _instantiatedCharacters

Character [] MoreMountains.CorgiEngine.CharacterSwitchManager._instantiatedCharacters
protected

◆ _instantiatedVFX

ParticleSystem MoreMountains.CorgiEngine.CharacterSwitchManager._instantiatedVFX
protected

◆ _switchEvent

CorgiEngineEvent MoreMountains.CorgiEngine.CharacterSwitchManager._switchEvent = new CorgiEngineEvent(CorgiEngineEventTypes.CharacterSwitch, null)
protected

◆ CharacterPrefabs

Character [] MoreMountains.CorgiEngine.CharacterSwitchManager.CharacterPrefabs

the list of possible characters prefabs to switch to

◆ CharacterSwitchVFX

ParticleSystem MoreMountains.CorgiEngine.CharacterSwitchManager.CharacterSwitchVFX

a particle system to play when a character gets changed

◆ CommonHealth

bool MoreMountains.CorgiEngine.CharacterSwitchManager.CommonHealth

if this is true, current health value will be passed from character to character

◆ CurrentIndex

int MoreMountains.CorgiEngine.CharacterSwitchManager.CurrentIndex = 0

the initial (and at runtime, current) index of the character prefab

◆ DebugCharacterSwitchToTargetIndexButton

bool MoreMountains.CorgiEngine.CharacterSwitchManager.DebugCharacterSwitchToTargetIndexButton

a test button that forces a character switch to the specified index in DebugTargetIndex

◆ DebugTargetIndex

int MoreMountains.CorgiEngine.CharacterSwitchManager.DebugTargetIndex = 1

the index that will be used when pressing the DebugCharacterSwitchToTargetIndex button below

◆ ForceCharacterSwitchButton

bool MoreMountains.CorgiEngine.CharacterSwitchManager.ForceCharacterSwitchButton

a test button that forces a character switch

◆ LinkedInputManager

InputManager MoreMountains.CorgiEngine.CharacterSwitchManager.LinkedInputManager

the input manager we'll read input on

◆ MaintainPreviousCharacterFacingDirection

bool MoreMountains.CorgiEngine.CharacterSwitchManager.MaintainPreviousCharacterFacingDirection = false

if this is true, newly switched to characters will flip (if needed) to face the direction the previous character was facing

◆ NextCharacterChoice

NextCharacterChoices MoreMountains.CorgiEngine.CharacterSwitchManager.NextCharacterChoice = NextCharacterChoices.Sequential

the order in which to pick the next character

◆ PlayerID

string MoreMountains.CorgiEngine.CharacterSwitchManager.PlayerID = "Player1"

the ID of the Player we want this CharacterSwitchManager to control

◆ PlayerIndex

int MoreMountains.CorgiEngine.CharacterSwitchManager.PlayerIndex = 0

the index of the Player in the LevelManager we want to target


The documentation for this class was generated from the following file: