Beispiel #1
0
 void changeFocus(GameObject target)
 {
     playerScript.focus = false;
     player             = target;
     playerScript       = player.GetComponent <playerScript_ex00>();
     playerScript.focus = true;
 }
Beispiel #2
0
 private void Start()
 {
     if (defaultPlayer)
     {
         ActivePlayer = this;
     }
 }
Beispiel #3
0
 void changeFocus(GameObject target)
 {
     playerScript.focus = false;
     player = target;
     playerScript = player.GetComponent<playerScript_ex00>();
     playerScript.focus = true;
 }
Beispiel #4
0
 // Use this for initialization
 void Start()
 {
     player = this;
     //print(selected_player2);
     selected_player++;
     id_player = selected_player;
 }
Beispiel #5
0
	// Update is called once per frame
	void Update () {
		if (focussed == this)
		{
			if (Input.GetKeyDown("space"))
			{
				if (GetComponent<Collider2D>().IsTouchingLayers(mapLayer))
				{
					tmp = GetComponent<Rigidbody2D>().velocity;
					tmp.y = jumpHeight;
					GetComponent<Rigidbody2D>().velocity = tmp;
				}
			}
			else if (Input.GetKey("left"))
			{
				tmp = GetComponent<Rigidbody2D>().velocity;
				tmp.x = -moveSpeed;
				GetComponent<Rigidbody2D>().velocity = tmp;
			}
			else if (Input.GetKey("right"))
			{
				tmp = GetComponent<Rigidbody2D>().velocity;
				tmp.x = moveSpeed;
				GetComponent<Rigidbody2D>().velocity = tmp;
			}
		}
		else if (Input.GetKeyDown(key))
		{
			focussed = this;
		}
		if (Input.GetKeyDown("r"))
		{
			transform.localPosition = initialPos;
			GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
		}
	}
Beispiel #6
0
 private void ChangePlayer(int index)
 {
     if (index >= players.Length)
     {
         return;
     }
     _activePlayer.enabled = false;
     _activePlayer         = players[index];
     _activePlayer.enabled = true;
 }
Beispiel #7
0
 // Use this for initialization
 void Start()
 {
     initPos = new Vector3[] {
         new Vector3(-4.21F, -0.36F, 0),
         new Vector3(-1.44F, 0.26F, 0),
         new Vector3(1.69F, 0.25F, 0)
     };
     resetPos();
     player             = red;
     playerScript       = player.GetComponent <playerScript_ex00>();
     playerScript.focus = true;
 }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     initPos = new Vector3[] {
         new Vector3(-4.21F, -0.36F, 0),
         new Vector3(-1.44F, 0.26F, 0),
         new Vector3(1.69F, 0.25F, 0)
     };
     resetPos();
     player = red;
     playerScript = player.GetComponent<playerScript_ex00>();
     playerScript.focus = true;
 }
Beispiel #9
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (id > 10)
     {
         if (collision.gameObject.CompareTag("Player") || LayerMask.LayerToName(collision.gameObject.layer) == "Platforms" || collision.gameObject.CompareTag("" + (id - 10)))
         {
             playerScript_ex00 parent = this.transform.parent.GetComponent <playerScript_ex00>();
             parent.grounds++;
             parent.grounded = true;
         }
     }
 }
Beispiel #10
0
 void Start()
 {
     GameObject[] tmp;
     tmp     = GameObject.FindGameObjectsWithTag("Player");
     players = new playerScript_ex00[tmp.Length];
     for (int i = 0; i < tmp.Length; i++)
     {
         players[i]         = tmp[i].GetComponent <playerScript_ex00>();
         players[i].enabled = false;
     }
     if (players != null)
     {
         _activePlayer         = players[0];
         _activePlayer.enabled = true;
     }
 }
Beispiel #11
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))
        {
            velocity.y = jumpPower;
        }
        _rigidbody2D.velocity = velocity;
    }
Beispiel #12
0
	// Use this for initialization
	void Start () {
		initialPos = transform.localPosition;
		if (defaultFocussed)
			focussed = this;
	}