MTON_FRAMEWORK

m

Code

Interface

Classes

// used to compose /Objects

(char)

cInput.cs

// Handles almost all input logic

// How long has button been held...etc

(var)

public

OnBTTN

OnAttkDelegate

On__IODelegate

bool

b__IO { ... }

this.set__IO(value);

(func)

public

virtual

void

doAttk(bool bAttk){ ... }

OnAttkDelegate(bAttk);

private

void

set__IO(bool b__io){ ... }

this.On__IODelegate(b__io);

cRbody.cs

// Handles almost all position logic : Move, Jump ...etc

// Checks for ground state...etc

cAnimn.cs

//Listener for all valid events

//Almost all delegates get called from here!

(var)

public

DL_bVal

OnAttkDelegate

...

eStateB

attkST{ ... }

set{ ... }

if(value == eStateB.DN){ ... }

this.setAttk(true);

(func)

public

void

setAttk(bool bAttk){ ... }

this.OnAttkDelegate(bAttk);

cMcanm.cs

//manages String state to animator hash conversion

(var)

public

cAnimn

anST

// animation state

Animator

anim

// mecanim animator

void

Init(){ ... }

anST.OnAttkDelegate += SetAttk;

(func)

public

void

animator_Hash_ID(){ ... }

_bAttk_ID = Animator.StringToHash(this._bAttk );

//HACK : if Animator fails to find string, it'll return a value of 0

public void SetAttk(bool bAttk){ ... }

anim.SetTrigger(_bAttk_ID);

// Play Animation

cRadar.cs

//Player awareness scans eligible targets in level

(misc)

(env)

cLevel.cs

cHint.cs

(fx)

(emit)

Objects

// directly attach to GameObject

oPlayer.cs

oEnemy.cs

(class)

(structs)

public

(delegates)

OnEnable(){...}

io

//direct input

io.OnAttkDelegate += setAttk ;

rb

//rigidbody events

ht

//health logic

an

//animation : input + character/env state

//radar

(functions)

public

virtual

void

// POSITION

//GET

FixedUpdate(){ ... }

// Calculate position state delta for animator

//SET

(position update)

doMove(Vector3 moveDir){ ... }

//Handles movement and facing

setJump(bool bJump){ ... }

setCrouch(bool bDuck){ ... }

(collision update)

setGround(bool IN_GROUND){ ... }

setCeilng(bool IN_CEILING){ ... }

setRise(bool bRise){ ... }

// tuck and untuck collision

(health update)

doHitd(int iHurt){ ... }

//Taking damage

setDead(bool bDead){ ... }

(animation update)

doFace(Vector3 vFace){ ... }

setIdlV(bool bIdlV){ ... }

//Sudden landing visual swap out

setIdlH(bool bIdlH){ ... }

(fx update)

setFoot(bool bFoot){ ... }

setActV(bool bActvV){ .. }

doTrig(int iTrig){ ... }

???

// ATTACK

doAimd(Vector3 aimdDir){ ... }

setAttk(bool bAttk){ ... }

an.attkST = cAnimn.eStateB.DN ;

setRapd(bool bRapd){ ... }

setPowr(bool bPowr){ ... }

// RADAR

setRadr(bool bRadar){ ... }

set__IO(bool b__IO ){ ... }

// io.On__IODelegate += set__IO ;

setStill(bool bStll ){ ... }

// an.OnStllDelegate += setStill ;

oEmitter.cs

//Bullet spawner/Turret

(misc)

HintBox/

oHint_ACTN.cs

//player event => jump...etc

oHint_CAMR.cs

//camera event => framing player and boss..etc

oHint_FLOK.cs

//flock logic

BulletObj/

oBullet_Slam.cs

//Thwomper, boss tentacle...etc

ToBeSpawnedComponents/

oAudio_Enable.cs

oRbody_Enable.cs

// WIP...

oFlameThrower_BB.cs

// Hack of flamethrower ability...need to integrate better

oEquip.cs

oFloater.cs

__gCONSTANT.cs

//shared functions and variables like level instance

public

static

class

__gIO{ ... }

r

public static class __gIO{ //Project Global object to hold IO buttons //handles player one IO public const string _hAxs_p1 = "Horizontal" ; public const string _vAxs_p1 = "Vertical" ; public const string _hAim_p1 = "Horizontal" ; public const string _vAim_p1 = "Vertical" ; public const string _JUMP_p1 = "Jump" ; public const string _ATTK_p1 = "Fire1" ; }

//Project Global object to hold IO buttons

__gUtility{ ... }

public

static

T

AddComponent_mton<T>(GameObject IN_GO) where T:Component{ ... }

r

//Prevents duplicate components, checks to see that one doesn't already exist public static T AddComponent_mton<T>(GameObject IN_GO) where T:Component{ T cExist = IN_GO.GetComponent<T>(); if(cExist == null){// Debug.Log(" Adding " + cExist); // (Component)T.ToString()); return IN_GO.AddComponent<T>(); } else{// Debug.Log(" Found " + cExist); //(Component)T.ToString()); return cExist; } }

// Prevents duplicate components, checks to see that one doesn't already exist

GetCopyOf<T>(this Component comp, T other) where T : Component{ ... }

r

public static T GetCopyOf<T>(this Component comp, T other) where T : Component{ Type type = comp.GetType(); if (type != other.GetType()) return null; // type mis-match BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Default | BindingFlags.DeclaredOnly; PropertyInfo[] pinfos = type.GetProperties(flags); foreach (var pinfo in pinfos) { if (pinfo.CanWrite) { try { pinfo.SetValue(comp, pinfo.GetValue(other, null), null); } catch { } // In case of NotImplementedException being thrown. For some reason specifying that exception didn't seem to catch it, so I didn't catch anything specific. } } FieldInfo[] finfos = type.GetFields(flags); foreach (var finfo in finfos) { finfo.SetValue(comp, finfo.GetValue(other)); } return comp as T; } public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component{ return go.AddComponent<T>().GetCopyOf(toAdd) as T; }

// Uses reflection for deep copy of any component

IEnumerator

WaitUntilDistantLess<T>(Transform IN_xform_SRC, Transform IN_xform_TGT, float In_threshold, Func<T> funcToRun){ ... }

r

public static IEnumerator WaitUntilDistantLess<T>(Transform IN_xform_SRC, Transform IN_xform_TGT, float In_threshold, Func<T> funcToRun){ float distToOther = 0.0f ; while(distToOther < In_threshold){// distToOther = Vector3.Distance(IN_xform_SRC.position, IN_xform_TGT.position) ; float distX = Mathf.Abs(IN_xform_SRC.position.x - IN_xform_TGT.position.x) ; // check x float distY = Mathf.Abs(IN_xform_SRC.position.y - IN_xform_TGT.position.y) * 0.5f ; // vertical height too much delta change, weight down by 1/5th if(distY > distX){ distToOther = distY; } else{ distToOther = distX; } yield return null ; } funcToRun() ; // NOTE : anonymous method of type `System.Func<T>' must return a value ; else error }

void

CheckAndInitLayer(GameObject IN_GO, string IN_LAYERNAME){ ... }

r

public static void CheckAndInitLayer(GameObject IN_GO, string IN_LAYERNAME){ string curLayer = LayerMask.LayerToName(IN_GO.layer); if(curLayer != IN_LAYERNAME){ IN_GO.layer = LayerMask.NameToLayer (IN_LAYERNAME); Debug.LogWarning(IN_GO+" Layer/Level Hint Not Setup Correctly : Converting '" + curLayer + "' to : '" + IN_LAYERNAME + "' "); } }

__gEXTENSIONS.cs

Project

Layers