• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MonoBehaviour类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MonoBehaviour的典型用法代码示例。如果您正苦于以下问题:C# MonoBehaviour类的具体用法?C# MonoBehaviour怎么用?C# MonoBehaviour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MonoBehaviour类属于命名空间,在下文中一共展示了MonoBehaviour类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:ddionisio,项目名称:ludum-dare-25,代码行数:7,代码来源:AIJump.cs


示例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;
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:7,代码来源:CoroutineUtils.cs


示例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");
        }
    }
开发者ID:qtLex,项目名称:Good_Evil_Level_1,代码行数:25,代码来源:CCombinationLock.cs


示例4: PerformInjections

 public void PerformInjections(MonoBehaviour component)
 {
     foreach (IInjector injector in _injectors)
     {
         injector.PerformAllInjections(component);
     }
 }
开发者ID:edgarjcfn,项目名称:MakeyMakeyMaze,代码行数:7,代码来源:InjectorSingleton.cs


示例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);
	}
开发者ID:srferran,项目名称:ES2015A,代码行数:29,代码来源:InformationController.Extended.cs


示例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();
        }
    }
开发者ID:ddionisio,项目名称:game-off-2012,代码行数:27,代码来源:SceneActionCamera.cs


示例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;
        }
    }
开发者ID:ddionisio,项目名称:GitGirl,代码行数:31,代码来源:AISetVelocity.cs


示例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);

        }
    }
开发者ID:GhostSoar,项目名称:UnityGunShoot3D,代码行数:31,代码来源:MessageDispatcher.cs


示例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;
 }
开发者ID:hybrid1969,项目名称:UnityTwine,代码行数:7,代码来源:ImageFade.cs


示例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);
    }
开发者ID:4ONSports,项目名称:Prototype_2,代码行数:7,代码来源:GameEventsHandler.cs


示例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;
 }
开发者ID:heuristicus,项目名称:DD2438,代码行数:25,代码来源:GlobalMove.cs


示例12: MapGenerator2

 public MapGenerator2(DungeonParameter param, MonoBehaviour obj,RndGenerator rnd)
 {
     DgParam = param;
     this.obj = obj;
     Rnd = rnd;
     reset();
 }
开发者ID:sgmtjp,项目名称:Git-SODATERUTOWER,代码行数:7,代码来源:MapGenerator2.cs


示例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");
            }
        }
    }
开发者ID:qtLex,项目名称:Good_Evil_Level_1,代码行数:29,代码来源:CButtonAnimationController.cs


示例14: SimpleChat

 public SimpleChat(string identifier,MonoBehaviour currentMonoBehaviour,string senderName)
     : base(identifier,currentMonoBehaviour,senderName)
 {
     continueCheckMessages();
     rt = -messageTime;
     setReceiveFunction(receive);
 }
开发者ID:osijan,项目名称:cellule,代码行数:7,代码来源:testExtendClass.cs


示例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;
 }
开发者ID:SaladLab,项目名称:TicTacToe,代码行数:7,代码来源:LoginProcessor.cs


示例16: Start

	void Start() {
		target = GetComponent(behaviour) as MonoBehaviour;
		if (!target) { 
			Debug.LogWarning("Did not find component " + behaviour + " on " + gameObject.name);
			Destroy(this);
		}
	}
开发者ID:wfowler1,项目名称:Miscellaneous-Soundboards,代码行数:7,代码来源:ActivatesBehaviourOnFlag.cs


示例17: PlantCrop

    // Returns whether or not the crop planting worked, if it works, it takes the cost from the players money
    public bool PlantCrop(string _uniqueId, MonoBehaviour tileToPlant)
    {
        Crop CropInfo = null;

        //Checks to see if tile is empty
        if (PlantedCrops.ContainsKey(tileToPlant))
        {
            return false;
        }

        //Gives CropInfo a Crop value
        for (int value = 0; value < AvailableCrops.Count; ++value)
        {
            if (AvailableCrops[value].UniqueId == _uniqueId)
            {
                CropInfo = AvailableCrops[value];
            }
        }

        //If no crop is present and player has enough money, plant crop and decrease money
        if (CropInfo != null && Money >= CropInfo.Cost)
        {
            PlantedCrops.Add(tileToPlant, new Crop(CropInfo));
            Money = Money - CropInfo.Cost;
            return true;
        }
        else
        {
            return false;
        }
    }
开发者ID:J-Dodds,项目名称:SimpleFarmingGame,代码行数:32,代码来源:GameState.cs


示例18: publishScore

    public static IEnumerator publishScore(int level, int score,MonoBehaviour toPause)
    {
        yield return new WaitForEndOfFrame();
        try{
            if (!loged){
                CallFBLogin();
            }

            if (FB.IsLoggedIn)
            {

                var query = new Dictionary<string, string>();
                query["score"] = score.ToString();
                FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { FbDebug.Log("Result: " + r.Text); }, query);
            }
        }catch{
            PopUpMessage.ShowPopUp(Globals.texts.withoutConnection,Globals.texts.error,toPause);
        }

        /*if (FB.IsLoggedIn)
        {
            var querySmash = new Dictionary<string, string>();

            querySmash["ScoreByLevel"] = "http://samples.ogp.me/284034268417686";
            print(FB.AppId);

            FB.API ("/me/" + "orl.ag.orly" + ":smash", Facebook.HttpMethod.POST,
                    delegate(FBResult r) { FbDebug.Log("Result: " + r.Text); }, querySmash);
        }*/
    }
开发者ID:OrlandoAguilar,项目名称:Orly,代码行数:30,代码来源:FacebookClass.cs


示例19: Start

    public override void Start(MonoBehaviour behaviour, Sequencer.StateInstance aState)
    {
        Entity ai = (Entity)behaviour;
        AIState aiState = (AIState)aState;

        ai.state = state;

        Vector2 src = ai.transform.position;
        Vector2 dest = Player.instance.transform.position;

        switch(type) {
        case Type.xOnly:
            dest.y = src.y;
            break;

        case Type.yOnly:
            dest.x = src.x;
            break;
        }

        Vector2 dir = dest - src;
        float dist = dir.magnitude;
        dir = dir/dist;

        float spd = minSpeed < maxSpeed ? Random.Range(minSpeed, maxSpeed) : minSpeed;
        ai.entMove.velocity = dir*spd;

        aiState.d = dist/spd;
    }
开发者ID:ddionisio,项目名称:ludum-dare-25,代码行数:29,代码来源:AIMoveToPlayer.cs


示例20: setSelected

    public static void setSelected(GameObject obj)
    {
        if(objects[obj] == null)
            return;

        if(current_object == obj)
            return;

        current_file_loc = objects[obj].ToString();
        current_object = obj;

        string[] split_loc = current_file_loc.Split('/');
        string short_loc = split_loc[split_loc.Length - 1];

        string[] split_short_loc = short_loc.Split(':');

        string short_file_name = split_short_loc[0];
        string line_number = split_short_loc[1];

        current_line_number = Int32.Parse(line_number);

        string type_name = short_file_name.Split('.')[0];

        if(temp == null)
            temp = new GameObject("temp");

        temp.AddComponent(type_name);

        MonoBehaviour mb = temp.GetComponent(type_name) as MonoBehaviour;

        current_behaviour = mb;

        UnityEngine.Debug.Log(Fancy.current_behaviour);
    }
开发者ID:srfoster,项目名称:CodeSpells,代码行数:34,代码来源:Fancy.cs



注:本文中的MonoBehaviour类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MonoDevelop类代码示例发布时间:2022-05-24
下一篇:
C# TextEditor.TextEditorData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap