por Mike Ton 9 anos atrás
1314
Mais informações
jumpDNHandler(){ ... }
override
OnDisable(){ ... }
io_MTView.OnJumpDN -= jumpDNHandler;
//MUST : remove events on disable, else memory leaks and other catastrophes
OnEnable(){ ... }
io_MTView.OnJumpDN += jumpDNHandler;
//binding IO events
public class Player : IHealth, IXform, IInput{...}
//implement IXform ....IHealth....etc
Vector3
position{ ... }
set{ ... }
xform.position = value;
//WTH is "value" coming from...keyword???
get{ ... }
return xform.position;
Transform
xform{ get; set; }
//not understanding {get; set; } template???
doMove(){ ... }
// insert normal function code here
//MUST : Else error
//All properties and methods must be implemented in importing class
//Interface property must be public???
//events vs. delegates : events more secure, can not be overwritten and adjusted by externals
void Update(){ ... }
if(Input.GetButtonDown("Jump")){ ... }
OnJumpDN();
public
static
event
bnEVENT
OnJumpRL ;
//onJump Release
OnJumpDN ;
//onJump Press
delegate
void
bnEVENT() ;
//Interface with default methods and properties ???
public interface IHealth{ ... }
public interface IXform{ ... }
(properties)
Vector3 position{ get; set; }
Transform xform{ get; set;}
(methods)
void doMove();
(cleanup)
public override void GameOver(){ ... }
StopAllCoroutines();
public IEnumerator SpawnPipes(){ ... }
while(mtonFlapperGame.State == mtonFlapperState.Playing){ ... }
yield return new WaitForSeconds(mtonFlapperGame.PipeSpawnSpeed);
mtonFlapperGame.Pipes.Add(new PipeViewModel(PipeController));
(init)
public override void Play(){ ... }
StartCoroutine(SpawnPipes());
StartCoroutine function always returns immediately, however you can yield the result. This will wait until the coroutine has finished executio
The execution of a coroutine can be paused at any point using the yield statement. The yield return value specifies when the coroutine is resumed.
The IEnumerator allows the program to yield things like the WaitForSeconds function, which lets you tell the script to wait without hogging the CPU