当前位置: 首页>>代码示例>>C#>>正文


C# Controller2D类代码示例

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


Controller2D类属于命名空间,在下文中一共展示了Controller2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    //GameObject arm;
    void Start()
    {
        sounds = GetComponents<AudioSource> ();
        gruntSound = sounds [0];

        controller = GetComponent<Controller2D> ();
        animator = GetComponent<Animator> ();

        Cursor.SetCursor(cursorTexture, hotSpot, cursorMode);

        currentHealth = maxHealth;
        Debug.Log("Current Health: " + currentHealth);

        timeHit = Time.time;
        currentTime = Time.time;
        invincibilityTime = 1;

        direction = 1;
        _posX = transform.position.x;
        someScale = transform.localScale.x;

        gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
        //print ("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);

        pivot = transform.FindChild("Pivot").gameObject;
    }
开发者ID:SaviorsofBoredom,项目名称:GameDev,代码行数:29,代码来源:Player.cs

示例2: Start

    void Start() {
        controller = GetComponent<Controller2D>();
        SaveLoad.Load();
        Checkpoint.CheckpointsList = GameObject.FindGameObjectsWithTag("Checkpoint");

        Debug.Log("Player loaded checkpoint: " + SaveLoad.save.checkpoint);

        if (SaveLoad.save.checkpoint != "")
        {
            Checkpoint cp = GameObject.Find(SaveLoad.save.checkpoint).GetComponent<Checkpoint>();

            //cp.activated = true;
            cp.ActivateCheckpoint();

            this.Respawn();
        } 

        animator = GetComponent<Animator>(); //assign the Animator component on the player gameobject to our new reference var. 

        //set up jump physics
		gravity = -(2 * maxJumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		minJumpVelocity = Mathf.Sqrt (2 * Mathf.Abs (gravity) * minJumpHeight);
		print ("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);
	}
开发者ID:Cappo,项目名称:Terrachi,代码行数:25,代码来源:Player.cs

示例3: Start

    void Start()
    {
        controller = GetComponent<Controller2D> ();

        gravity = -(2 * jumpHeight) / (timeToJumpApex * timeToJumpApex);
        jumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
    }
开发者ID:memequeen2015,项目名称:abacus1,代码行数:7,代码来源:Player.cs

示例4: Start

	void Start() {
		controller = GetComponent<Controller2D> ();

		gravity = -(2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		print ("Gravity: " + gravity + "  Jump Velocity: " + jumpVelocity);
	}
开发者ID:Deolis,项目名称:2DPlatformer-Tutorial,代码行数:7,代码来源:Player.cs

示例5: Start

	void Start()
	{
		base.Start();
		controller = GetComponent<Controller2D>();
		spriteRenderer = GetComponent<SpriteRenderer>();
		enemySpeed = -enemySpeed;
	}
开发者ID:nzhul,项目名称:ritual,代码行数:7,代码来源:Enemy.cs

示例6: PowerActionEnter

	public override void PowerActionEnter(GameObject player, Controller2D controller){
		insideExplosionRange = true;
		target = player;
		controller.powerInvulnerable = true;
        if (playerController == null)
            playerController = controller;
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:7,代码来源:DefectionShield.cs

示例7: PowerActionEnter

	public override void PowerActionEnter(GameObject player, Controller2D controller){
		if( on ){
			portalTo.GetComponent<TeleportPortals>().on = false;
			player.transform.position = portalTo.transform.position;
		}
		Debug.Log( "PORTAL" );
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:7,代码来源:TeleportPortals.cs

示例8: PowerActionEnter

	public override void PowerActionEnter (GameObject player, Controller2D controller)
	{
		if (Analytics.Enabled) {
			GA.API.Design.NewEvent ("BlackHole Deaths", player.transform.position);
		}
		controller.Die();
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:7,代码来源:BlackHoleCenter.cs

示例9: PowerActionEnter

	//Note: Only the host can decide who got hit.
	public override void PowerActionEnter (GameObject player, Controller2D controller)
	{
		//cant stick to yourself again. also wait for response rpc before sending another one.
		if (controller.hasbomb || sentRPC) {
				return;
		}
		if (stickready) {
			//No need to confirm getting stuck if you're the server.
			if (Network.isServer)
            {
				if (Analytics.Enabled) 
                {
						GA.API.Design.NewEvent ("Players Stuck", player.transform.position);
				}
			
				networkView.RPC ("AttachToPlayer", RPCMode.Others, Network.player, firststick);
				//do this second so that firstick isnt changed until the end.
				AttachToPlayer (Network.player, firststick);
			} else {
				//We call this incase two people get stuck at around the same time, so that bombs dont
				//stick to different characters on different clients. 
				//Those with lower ping at a disadvantage (since their message gets there first)
				// but its probably not important for now.
								
				if (Analytics.Enabled) {
						GA.API.Design.NewEvent ("Bomb Transfers", player.transform.position);
				}

				sentRPC = true;
				networkView.RPC ("IThinkIGotStuck", RPCMode.Server);
			}
		}
		
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:35,代码来源:TransferExplosive.cs

示例10: PowerActionEnter

	public override void PowerActionEnter(GameObject player, Controller2D controller)
    {
        applyDmg = controller.GetComponent<PlayerStatus>();
		if (trapDuration > slowDuration)
        {
            if (!used)
            {
                used = true;

				player.rigidbody2D.drag = 0;
				applyDmg.Frozen();
                frozenEffect = (GameObject)Instantiate(Resources.Load("FrozenEffect"), player.transform.position, Quaternion.identity);
                frozenEffect.GetComponent<FrozenEffect>().player = controller;
                frozenplayer = controller;
                currentplayer = player;

                networkView.RPC("FreezeFollow", RPCMode.Others, Network.player);
				if(Analytics.Enabled){
					GA.API.Design.NewEvent("Times Frozen", player.transform.position);
				}
            }
        }
        else
        { 
            player.rigidbody2D.drag = 100f;
        }

	
		
	}
开发者ID:RobbSteel,项目名称:Lords-of-Distortion,代码行数:30,代码来源:FreezeTrap.cs

示例11: Start

	void Start()
	{
		spriteRenderer = GetComponent<SpriteRenderer>();
		controller = GetComponent<Controller2D>();
		animator = GetComponent<Animator>();
		abilityManager = GetComponent<AbilityManager>();
		gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); // This is some physics formula :)
		maxJumpVelocity = Mathf.Abs(gravity * timeToJumpApex);
		minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
		controller.OnEnemyCollision += OnEnemyCollision;
		controller.OnCollectableCollision += OnCollectableCollision;

		// TODO: Update enemies list on Update method but with Enumerator on every 1-2 seconds
		// TODO: We may not need to update the list on every frame but just to find the new closest enemy.
		// TODO: The update for the list entries must be done via message when new enemy dies or spawns.
		Enemies = GameObject.FindGameObjectsWithTag("Enemy").ToList();

		foreach (GameObject enemy in Enemies)
		{
			Enemy enemyComponent = enemy.GetComponent<Enemy>();
			enemyComponent.OnDeath += OnEnemyDeath;
		}

		// Currently not working. Find a way to fix this or use mouse targeting
		//StartCoroutine(FindClosestEnemy());
	}
开发者ID:nzhul,项目名称:ritual,代码行数:26,代码来源:Player.cs

示例12: Start

 protected virtual void Start()
 {
     player = GetComponent<Player>();
     input = player.InputPlayer;//GetComponent<InputController>();
     controller = GetComponent<Controller2D>();
     movementSpecial = GetComponent<OnMovementSpecial>();
 }
开发者ID:Juskelis,项目名称:Champloo,代码行数:7,代码来源:MovementState.cs

示例13: Start

    void Start()
    {
        gameControl = GameObject.FindGameObjectWithTag("GameController");

        target = GameObject.FindGameObjectWithTag("Player").transform.GetComponent<Controller2D>();
        focusArea = new FocusArea (target.collider.bounds, focusAreaSize);
    }
开发者ID:tomwb,项目名称:Unity-run-for-your-happy-end,代码行数:7,代码来源:CameraFollow.cs

示例14: Start

	void Start () {
		controller = GetComponent<Controller2D> ();
		
		gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
		maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
		minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity)  * minJumpHeight);
	}
开发者ID:HeartChess,项目名称:Heartchess,代码行数:7,代码来源:Player.cs

示例15: Start

 void Start()
 {
     audioSource = GetComponent<AudioSource> ();
     controller = GetComponent<Controller2D> ();
     shootTime = shootTimeNormal;
     direction = (Random.Range (1, 11) > 5 ? 1 : -1);
 }
开发者ID:romrz,项目名称:MonsterFight,代码行数:7,代码来源:Enemy.cs


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