Esempio n. 1
0
 void changeFocus(GameObject target)
 {
     playerScript.focus = false;
     player             = target;
     playerScript       = player.GetComponent <playerScript_ex01>();
     playerScript.focus = true;
 }
Esempio n. 2
0
 private void Start()
 {
     if (defaultPlayer)
     {
         ActivePlayer = this;
     }
 }
Esempio n. 3
0
 void changeFocus(GameObject target)
 {
     playerScript.focus = false;
     player = target;
     playerScript = player.GetComponent<playerScript_ex01>();
     playerScript.focus = true;
 }
Esempio n. 4
0
 private void ChangePlayer(int index)
 {
     if (index >= players.Length)
     {
         return;
     }
     _activePlayer.enabled = false;
     _activePlayer         = players[index];
     _activePlayer.enabled = true;
 }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     initPos = new Vector3[] {
         new Vector3(-14.41F, -2.53F, 0),
         new Vector3(-13.38F, -1.92F, 0),
         new Vector3(-11.51F, -1.9F, 0)
     };
     resetPos();
     player             = red;
     playerScript       = player.GetComponent <playerScript_ex01>();
     playerScript.focus = true;
 }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     initPos = new Vector3[] {
         new Vector3(-14.41F, -2.53F, 0),
         new Vector3(-13.38F, -1.92F, 0),
         new Vector3(-11.51F, -1.9F, 0)
     };
     resetPos();
     player = red;
     playerScript = player.GetComponent<playerScript_ex01>();
     playerScript.focus = true;
 }
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (id > 10)
     {
         if (collision.gameObject.CompareTag("Player") || LayerMask.LayerToName(collision.gameObject.layer) == "Platforms" || collision.gameObject.CompareTag("" + (id - 10)))
         {
             playerScript_ex01 parent = this.transform.parent.GetComponent <playerScript_ex01>();
             parent.grounds++;
             parent.grounded = true;
         }
     }
 }
Esempio n. 8
0
 void Start()
 {
     GameObject[] tmp;
     tmp     = GameObject.FindGameObjectsWithTag("Player");
     players = new playerScript_ex01[tmp.Length];
     for (int i = 0; i < tmp.Length; i++)
     {
         players[i]         = tmp[i].GetComponent <playerScript_ex01>();
         players[i].enabled = false;
     }
     if (players != null)
     {
         _activePlayer         = players[0];
         _activePlayer.enabled = true;
     }
 }
Esempio n. 9
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (!other.CompareTag("Player"))
        {
            return;
        }
        playerScript_ex01 player = other.gameObject.GetComponent <playerScript_ex01>();

        if (player == null)
        {
            return;
        }
        if (player.index == playerIndex)
        {
            GameManager.instance.CharacterFinished(playerIndex, true);
        }
    }
Esempio n. 10
0
    private void Update()
    {
        if (Input.GetKeyDown(key))
        {
            ActivePlayer = this;
        }

        if (ActivePlayer != this)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        var velocity = _rigidbody2D.velocity;

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            velocity.x = -moveSpeed;
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            velocity.x = moveSpeed;
        }
        else
        {
            velocity.x = 0;
        }

        if (Input.GetKeyDown(KeyCode.Space) && _isGrounded)
        {
            velocity.y  = jumpPower;
            _isGrounded = false;
        }
        _rigidbody2D.velocity = velocity;
    }
Esempio n. 11
0
	// Update is called once per frame
	void Update () {
		if (!exit && focussed == this)
		{
			if (Input.GetKeyDown("space"))
			{
				if (GetComponent<Collider2D>().IsTouchingLayers(mapLayer))
				{
					tmpVelocity = GetComponent<Rigidbody2D>().velocity;
					tmpVelocity.y = jumpHeight;
					GetComponent<Rigidbody2D>().velocity = tmpVelocity;
					GetComponent<Rigidbody2D>().AddForce(Vector3.up * jumpHeight);
				}
			}
			else if (Input.GetKey("left"))
			{
				tmpVelocity = GetComponent<Rigidbody2D>().velocity;
				tmpVelocity.x = -moveSpeed;
				GetComponent<Rigidbody2D>().velocity = tmpVelocity;
			}
			else if (Input.GetKey("right"))
			{
				tmpVelocity = GetComponent<Rigidbody2D>().velocity;
				tmpVelocity.x = moveSpeed;
				GetComponent<Rigidbody2D>().velocity = tmpVelocity;
			}
		}
		else if (Input.GetKeyDown(key))
		{
			focussed = this;
		}
		if (Input.GetKeyDown("r"))
		{
			transform.localPosition = initialPos;
			GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
		}
	}
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     player = transform.parent.gameObject.GetComponent <playerScript_ex01>();
 }
Esempio n. 13
0
 void Start()
 {
     perso = GetComponentInParent <playerScript_ex01> ();
 }
Esempio n. 14
0
	// Use this for initialization
	void Start () {
		initialPos = transform.localPosition;
		if (defaultFocussed)
			focussed = this;
	}