Exemplo n.º 1
0
    //controls change
    void altControl()
    {
        IYHFusionPlayer fp = GetComponentInParent <IYHFusionPlayer> ();

        if (fp != null)
        {
            if (fp.keyBoard)
            {
                keyBoard = true;
            }
            else
            {
                keyBoard = false;
            }
        }

        if (keyBoard)
        {
            movementX = "Horizontal_P" + owner;
            movementY = "Vertical_P" + owner;
        }
        else
        {
            movementX = "LeftStickX_P" + owner;
            movementY = "LeftStickY_P" + owner;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        fusionPlayer = fusion.GetComponent <IYHFusionPlayer> ();

        if (fusionPlayer.player1InControl)
        {
            cat.player1InControl = true;
        }
        else
        {
            cat.player1InControl = false;
        }

        if (fusionPlayer.player2InControl)
        {
            cat.player2InControl = true;
        }
        else
        {
            cat.player2InControl = false;
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        altControl();

        //detect whether input sth
        if (Input.GetAxis("LeftStickX_P" + owner) == 0 && Input.GetAxis("LeftStickY_P" + owner) == 0)
        {
            noInput = true;
        }
        else
        {
            noInput = false;
        }

        sp = GetComponentInParent <SoloPlayers> ();         //two smaller ones
        fp = GetComponentInParent <IYHFusionPlayer> ();     //two player together
        sr = GetComponent <SpriteRenderer> ();

//		Debug.Log(initPos);
        transform.localPosition = new Vector3(placement.x, placement.y, 0);

        //if it is fusionIndicator, it shows the in-between arrow of both arrows
        if (fusionIndicator == false)
        {
            //Debug.Log(movementX);
            //direction pointing at
            pointDirection = new Vector3((Input.GetAxis(movementX)), (Input.GetAxis(movementY)) * -1, 0);
            //Debug.Log(pointDirection);
            if (pointDirection != Vector3.zero)
            {
                //calc the angle it points at
                float angle = Mathf.Atan2(pointDirection.y, pointDirection.x) * Mathf.Rad2Deg;
                transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            }
            placement = new Vector2(Input.GetAxis(movementX), (Input.GetAxis(movementY) * -1)).normalized;

            //solo player is not null
//			if (sp != null) {
//				if (sp.touchingGround == true)
//				{
////					if (placement.y <= 0) {
////						transform.localPosition = new Vector2 (placement.x, 0);
////					}
//					if (placement.x == 0)
//					{
//						placement.x = sp.directionModifier;
//						placement.y = 0;
//					}
//				}
//			}

            //fusion player is not null
            if (fp != null)
            {
                if (fp.touchingGround == true)
                {
                    if (placement.y <= 0)
                    {
                        transform.localPosition = new Vector2(placement.x, 0);
                    }
                }
            }
        }
        else
        {
            placement      = new Vector2(fp.stickPosX, fp.stickPosY * -1);
            pointDirection = new Vector3(fp.stickPosX, fp.stickPosY * -1, 0);

            if (pointDirection != Vector3.zero)
            {
                //Debug.Log("in");
                float angle = Mathf.Atan2(pointDirection.y, pointDirection.x) * Mathf.Rad2Deg;
                //transform.LookAt(transform.position+pointDirection);
                transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            }
        }

        //Debug.Log(transform.localRotation.eulerAngles.z);
        //try to flip it but not working now
//		if (transform.localRotation.eulerAngles.z <= 180 && transform.localRotation.eulerAngles.z > 90) {
//			Debug.Log("flip");
//			Debug.Log(transform.localRotation.eulerAngles.z);
//			GetComponent<SpriteRenderer> ().flipY = true;
//		} else if(transform.localRotation.eulerAngles.z >= 0 && transform.localRotation.eulerAngles.z <= 90) {
//			Debug.Log("unflip");
//			GetComponent<SpriteRenderer> ().flipY = false;
//		}

        if (pointDirection == Vector3.zero)
        {
            sr.color = alphadOut;
        }
        else
        {
            if (overlapping)
            {
                sr.color = fusionColor;
            }
            else
            {
                if (owner == 1)
                {
                    sr.color = p1Color;
                }
                if (owner == 2)
                {
                    sr.color = p2Color;
                }
                if (fusionIndicator)
                {
                    sr.color = fusionColor;
                }
            }
        }
    }