类别 全部 - framework - classes - interface - levels

作者:Mike Ton 9 年以前

384

Unity3D_MTON_FRAMEWORK

The provided content outlines a detailed framework for a project that includes various layers of code, each responsible for specific functionalities. It lists interfaces that handle different aspects such as input, equipment, and health, among others.

Unity3D_MTON_FRAMEWORK

MTON_FRAMEWORK

Project

Layers

Code

__gEXTENSIONS.cs
__gCONSTANT.cs

static

class

__gUtility{ ... }

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

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 + "' ");

}

}

IEnumerator

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

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

}

T

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

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

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

//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

__gIO{ ... }

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

//shared functions and variables like level instance
Objects
// WIP...

oFloater.cs

oEquip.cs

oFlameThrower_BB.cs

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

ToBeSpawnedComponents/

oRbody_Enable.cs

oAudio_Enable.cs

BulletObj/

oBullet_Slam.cs

//Thwomper, boss tentacle...etc

HintBox/

oHint_FLOK.cs

//flock logic

oHint_CAMR.cs

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

oHint_ACTN.cs

//player event => jump...etc

oEmitter.cs

//Bullet spawner/Turret

oPlayer.cs

(class)

(functions)

// RADAR

setRadr(bool bRadar){ ... }

setStill(bool bStll ){ ... }

// an.OnStllDelegate += setStill ;

set__IO(bool b__IO ){ ... }

// io.On__IODelegate += set__IO ;

// ATTACK

setPowr(bool bPowr){ ... }

setRapd(bool bRapd){ ... }

an.attkST = cAnimn.eStateB.DN ;

doAimd(Vector3 aimdDir){ ... }

// POSITION

//SET

doTrig(int iTrig){ ... }

???

(fx update)

setActV(bool bActvV){ .. }

setFoot(bool bFoot){ ... }

(animation update)

setIdlH(bool bIdlH){ ... }

setIdlV(bool bIdlV){ ... }

//Sudden landing visual swap out

doFace(Vector3 vFace){ ... }

(health update)

setDead(bool bDead){ ... }

doHitd(int iHurt){ ... }

//Taking damage

(collision update)

setRise(bool bRise){ ... }

// tuck and untuck collision

setCeilng(bool IN_CEILING){ ... }

setGround(bool IN_GROUND){ ... }

(position update)

setCrouch(bool bDuck){ ... }

setJump(bool bJump){ ... }

doMove(Vector3 moveDir){ ... }

//Handles movement and facing

//GET

FixedUpdate(){ ... }

// Calculate position state delta for animator

(delegates)

OnEnable(){...}

//radar

an

//animation : input + character/env state

ht

//health logic

rb

//rigidbody events

io

io.OnAttkDelegate += setAttk ;

//direct input

(structs)

s_RbodyProperties

sRB

s_EmitProperties

sEM

s_DispOProperties

sDP

oEnemy.cs

oBoss.cs

//oEnemy ai logic, plus level hazard

//oPlayer minus Input, swapped out for ai

// directly attach to GameObject
Classes
(emit)

cEmit_Particle.cs

cEmit_HeatSeek.cs

cEmit_Bullet.cs

cEmit_Audio.cs

cCurve.cs

cTween.cs

cSpawn.cs

cHint.cs

cLevel.cs

(utility)

Sound

getSoundManager(){ ... }

(spawning fx)

(spawning entity)

(enums)

enum

(Transform)

e_Icon{ ... }

e_Flyr{ ... }

e_Slams{ ... }

e_Bllt{ ... }

e_Enmy{ ... }

e_Anim{ ... }

// Must be Animator

e_psFX{ ... }

// Must be particle system

(camera)

// Ad hoc pooler, and spawns almost everything needed by player, enemy, level and gui

// Approaching monlithicness

(misc)

cHealth.cs

cEquip.cs

cXform.cs

cRadar.cs

//Player awareness scans eligible targets in level

cMcanm.cs

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

anim.SetTrigger(_bAttk_ID);

// Play Animation

animator_Hash_ID(){ ... }

_bAttk_ID = Animator.StringToHash(this._bAttk );

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

Init(){ ... }

anST.OnAttkDelegate += SetAttk;

Animator

anim

// mecanim animator

cAnimn

anST

// animation state

//manages String state to animator hash conversion

cAnimn.cs

setAttk(bool bAttk){ ... }

this.OnAttkDelegate(bAttk);

eStateB

attkST{ ... }

set{ ... }

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

this.setAttk(true);

DL_bVal

...

//Listener for all valid events

//Almost all delegates get called from here!

cRbody.cs

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

// Checks for ground state...etc

cInput.cs

(func)

private

set__IO(bool b__io){ ... }

this.On__IODelegate(b__io);

virtual

void

doAttk(bool bAttk){ ... }

OnAttkDelegate(bAttk);

(var)

public

bool

b__IO { ... }

this.set__IO(value);

OnBTTN

On__IODelegate

OnAttkDelegate

// Handles almost all input logic

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

// used to compose /Objects
Interface
(fx)

__iTweenMTON.cs

__iCurve.cs

__iEmit.cs

//effects and animated sprites

(env)

__iHint.cs

__iLevel.cs

(char)

__iHealth.cs

__iEquip.cs

__iAnimn.cs

__iRbody.cs

__iXform.cs

__iInput.cs