本文整理汇总了C#中MonoBehaviour类的典型用法代码示例。如果您正苦于以下问题:C# MonoBehaviour类的具体用法?C# MonoBehaviour怎么用?C# MonoBehaviour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MonoBehaviour类属于命名空间,在下文中一共展示了MonoBehaviour类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance aState)
{
Entity ai = (Entity)behaviour;
EntityMovement em = ai.entMove;
em.Jump(speedMin < speedMax ? Random.Range(speedMin, speedMax) : speedMin);
ai.state = state;
}
示例2: run_list
public static IEnumerator run_list(MonoBehaviour runner, IEnumerable<ActionWrapper> actions){
foreach (ActionWrapper aw in actions) {
Debug.Log("Running Coroutine");
yield return runner.StartCoroutine(aw.run());
}
yield return null;
}
示例3: ProcessMessage
void ProcessMessage(MonoBehaviour behaviour)
{
bool AllOn = true;
bool AllOff = true;
if (!Eneble){
return;
}
for(int i = 0; i < TriggerButtonsOn.Length; i++){
if(TriggerButtonsOn[i].State == c2StateButton.eButtonState.Off){
AllOn = false;
}
}
for(int i = 0; i < TriggerButtonsOff.Length; i++){
if(TriggerButtonsOff[i].State == c2StateButton.eButtonState.On){
AllOff = false;
}
}
if(AllOn && AllOff){
State = true;
animation.CrossFade("Open");
}
}
示例4: PerformInjections
public void PerformInjections(MonoBehaviour component)
{
foreach (IInjector injector in _injectors)
{
injector.PerformAllInjections(component);
}
}
示例5: displayInformationForUnit
private void displayInformationForUnit(IGameEntity entity) {
//Remove previous values
hideExtendedInformationPanel();
//Display window info
windowInfo.GetComponent<Image>().enabled = true;
currentPanel = Panel.UNIT;
currentObject = (MonoBehaviour)entity;
List<String> titles = new List<String>();
titles.Add("Attack rate");
titles.Add("Attack range");
titles.Add("Movement rate");
titles.Add("Resistance");
titles.Add("Sight range");
titles.Add("Strenght");
titles.Add("Weapon Ability");
List<String> values = new List<String>();
values.Add(entity.info.unitAttributes.attackRate.ToString());
values.Add(entity.info.unitAttributes.attackRange.ToString());
values.Add(entity.info.unitAttributes.movementRate.ToString());
values.Add(entity.info.unitAttributes.resistance.ToString());
values.Add(entity.info.unitAttributes.sightRange.ToString());
values.Add(entity.info.unitAttributes.strength.ToString());
values.Add(entity.info.unitAttributes.weaponAbility.ToString());
displayInformation(titles, values);
}
示例6: Start
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state)
{
Main.instance.cameraController.mode = mode;
if(attachToPath.Length > 0) {
GameObject go = ((SceneController)behaviour).SearchObject(attachToPath);
if(go != null) {
Main.instance.cameraController.attach = go.transform;
}
else {
Debug.LogWarning("Path not found: "+attachToPath);
}
}
else if(attachToWaypoint.Length > 0) {
Transform t = WaypointManager.instance.GetWaypoint(attachToWaypoint);
if(t != null) {
Main.instance.cameraController.attach = t;
}
else {
Debug.LogWarning("Can't find waypoint: "+attachToWaypoint);
}
}
if(immediate) {
Main.instance.cameraController.CancelMove();
}
}
示例7: Start
public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance state)
{
Entity ai = (Entity)behaviour;
PlanetAttach pa = ai.planetAttach;
AIState aiState = (AIState)state;
float speed = speedMin < speedMax ? Random.Range(speedMin, speedMax) : speedMin;
if(speed > 0) {
if(followPlayer) {
Player player = SceneLevel.instance.player;
aiState.curPlanetDir = pa.GetDirTo(player.planetAttach, followPlayerHorizontal);
}
else if(!useDir) {
aiState.curPlanetDir = Util.Vector2DRot(new Vector2(1, 0), angle*Mathf.Deg2Rad);
}
pa.velocity = aiState.curPlanetDir*speed;
ai.action = Entity.Action.move;
}
else {
pa.velocity = Vector2.zero;
ai.action = Entity.Action.idle;
}
if(resetAccel) {
pa.accel = Vector2.zero;
}
}
示例8: DispatchMessage
public void DispatchMessage(float delay, /*fa song zhe */int sender, /*jie shou zhe */int receiver, int msg,MonoBehaviour _be)
{
//jie shou zhe de zhi zhen
BaseGameEntity pReceiver = EntityManager.Instance ().GetEntityFromID (receiver);
//chuang jian yi ge xiao xi
Telegram telegram = new Telegram (0, sender, receiver, msg,_be);
if (delay <= 0.0f) {
//li ji fa song xiao xi
Discharge (pReceiver, telegram);
} else {
//yan chi fa song xiao xi
float CurrentTime = Time.realtimeSinceStartup;
telegram.DispatchTime = CurrentTime + delay;
foreach(Telegram val in PriorityQ)
{
if(val.Sender == sender && val.Receiver == receiver && val.Msg ==msg)
{
return ;
}
}
PriorityQ.Add (telegram);
}
}
示例9: Start
public static YieldInstruction Start(CanvasGroup group, MonoBehaviour script, float from, float to, float time)
{
Stop(group, script);
var coroutine = script.StartCoroutine(AnimateGroup(group, from, to, time));
_fades.Add(group, coroutine);
return coroutine;
}
示例10: SubscribeToEvent
public static void SubscribeToEvent(EGameEvent _e, MonoBehaviour _subscriber)
{
Initialize();
// assert _gameEvent >= GameEvent.EVT_GOAL_SCORED && _gameEvent < GameEvent.COUNT
evtSubscribers [(int)_e].Add (_subscriber);
}
示例11: changeMotionModel
public MonoBehaviour changeMotionModel(GlobalControl.motionModels newMotionModel)
{
//First, remove previous motion model
DestroyImmediate (motionComponent);
//Add the new motion model
switch (newMotionModel){
case GlobalControl.motionModels.DISCRETE:
motionComponent = (MonoBehaviour)gameObject.AddComponent<MoveDiscrete>();
break;
case GlobalControl.motionModels.KINEMATIC:
motionComponent = (MonoBehaviour)gameObject.AddComponent<MoveKinematic>();
break;
case GlobalControl.motionModels.DYNAMIC:
motionComponent = (MonoBehaviour)gameObject.AddComponent<MoveDynamic>();
break;
case GlobalControl.motionModels.DIFFERENTIAL:
motionComponent = (MonoBehaviour)gameObject.AddComponent<MoveDifferential>();
break;
case GlobalControl.motionModels.CAR:
motionComponent = (MonoBehaviour)gameObject.AddComponent<MoveCar>();
break;
}
motionModel = newMotionModel;
return motionComponent;
}
示例12: MapGenerator2
public MapGenerator2(DungeonParameter param, MonoBehaviour obj,RndGenerator rnd)
{
DgParam = param;
this.obj = obj;
Rnd = rnd;
reset();
}
示例13: ProcessMessage
void ProcessMessage(MonoBehaviour behaviour)
{
bool OpenCondition = true;
bool NotYorButton = true;
foreach (c2StateButton target in TriggerButtons){
if (target == null) {continue;};
if (target == behaviour){
NotYorButton = false;
}
if (target.State != c2StateButton.eButtonState.On){
OpenCondition = false;
break;
}
}
if (!NotYorButton){
if (OpenCondition){
animation.CrossFade("PullDown");
}
else{
animation.CrossFade("PullUp");
}
}
}
示例14: SimpleChat
public SimpleChat(string identifier,MonoBehaviour currentMonoBehaviour,string senderName)
: base(identifier,currentMonoBehaviour,senderName)
{
continueCheckMessages();
rt = -messageTime;
setReceiveFunction(receive);
}
示例15: Login
public static Task Login(MonoBehaviour owner, IPEndPoint endPoint, string id, string password, Action<string> progressReport)
{
var task = new UnitySlimTaskCompletionSource<bool>();
task.Owner = owner;
owner.StartCoroutine(LoginCoroutine(endPoint, id, password, task, progressReport));
return task;
}