MOST Gate

A configurable gate system with input/output logic (math/custom), automatic text labeling (positive, negative, or empty), animations, and a customizable output hook with model management.

Gate Structure

Depending on the Gate Text (Output), MOST_Gate will automatically select the active model between Positive, Negative, and Custom models, all directly in edit mode

  • If Output Text is a Positive number or a True value >> the selected gate is Positive

  • If Output Text is a Negative number or a False value >> the selected gate is Negative

  • If Output Text is another value (string) >> the selected gate is Custom

Gate Post (TMP) is a Text to display the main gate output text

Fixed Output (TMP) is a Text to display the secondary gate output text (Fixed because it can't be edited by upgrade).

secondary gate output can be used if the main gate output is used for something else, like for the upgrades or other stuff (a lot of examples will be found on Gate prefab)

Set up The Gate

  • Gate Output: Set the text as a string. Numbers must start with a sign (+, -, x, ÷), with option to hide the sign The gate will automatically detect the type of output and activate the target game model

  • Gate Type: As an enum menu... You can add/edit types from Most_Gate cs Line 25

public enum GateType 
{ 
  Health,
  FireRate,
  FireRange,
  Upgrade,
  AddChildren,
  Currency,
  Other /* Edit or Add More Types */ 
}

  • Trigger the gate:

// Use the gate calculations to return the output and use it on your objects

Most_Gate.Calculation(); // returns the output text if it's a number
// ex: x6 returns 6, +5 returns 5, -3 returns -3

Most_Gate.Calculation(float input); // returns the output equation with the input
// ex: input = 10, gate text = +5, returns 15

Use Calculation() on your objects to trigger the gate

// In Game Example... 
// A game object with a collision system has power and health property

using UnityEngine;

public class CharacterControl_Gun : MonoBehaviour
{
    [Tooltip("This value will be updated using MOST_Gate")]
    [Min(0)] public float Power = 10;
    [Min(0)] public float Health = 50;
    
    // if this game object triggers a gate object
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Gate")) // Gate tag check
        {
            // accepts only if the object has Most_Gate system
            if (other.GetComponent<Most_Gate>()) 
            GateTriggered(other.GetComponent<Most_Gate>());
        }
    }
    
    void GateTriggered(Most_Gate gate)
    {
        if (gate.IsCollected) return; // if this gate not triggered before
        switch (gate.Type) // Type Check
        {
            case Most_Gate.GateType.Upgrade:
                Power = gate.Calculation(Power); 
                break;
                
            case Most_Gate.GateType.Upgrade:
                Health = gate.Calculation(Health); 
                break;
                
            default: Debug.Log("This Gate type is not defined on this character control");
    }
}

MORE... API reference

// Next to each line shows the return and set data Type 

Most_Gate.Calculation(); // returns the output text if it's a number
// ex: x6 returns 6, +5 returns 5, -3 returns -3

Most_Gate.Calculation(float input); // returns the output equation with the input
// ex: input = 10, gate text = +5, returns 15

Most_Gate.GetSign(); // returns a custom enum from Solo.MOST.IN.ONE namespace
 { Plus, Minus, Subtract, Multiply, NoSign }
// NoSign for non-num output

//_______________________________________________________________//

// return Gate Type
// You can update the Gate type at runtime without any issues
Most_Gate.Type return enum GateType

// true if this gate got triggered / Calculation()
Most_Gate.IsCollected return bool

// Main Gate output
Most_Gate.GateText return or set

// secondary Gate output
Most_Gate.OutputText return or set

// controls the output calculations scale
// for example // if the output +10 and rescale = 0.1f the calculation() will return 10 * .1f
Most_Gate.AmountRescale return or set

// make secondary gate output the target output in the calculation
Most_Gate.EnableFixedOutput return or set

// controls the upgrade system. enable or disable
Most_Gate.EnableUpgrade return or set

Last updated