// Use this for initialization
    void Start()
    {
        GameObject goTemp = (GameObject)GameObject.FindGameObjectWithTag ("Glove");
        _fistController = goTemp.GetComponent<FistController>();

        _anim = gameObject.GetComponent<Animator> ();
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        // Changes the players different colours.
        if (playerIndex == 1) // Player 1 = Cyan
        {
            gameObject.GetComponent <SpriteRenderer>().color = Color.cyan;
            fistObject.GetComponent <SpriteRenderer>().color = Color.cyan;
        }
        else if (playerIndex == 2) // Player 2 = Yellow
        {
            gameObject.GetComponent <SpriteRenderer>().color = Color.yellow;
            fistObject.GetComponent <SpriteRenderer>().color = Color.yellow;
        }
        else if (playerIndex == 3) // Player 3 = Red
        {
            gameObject.GetComponent <SpriteRenderer>().color = Color.red;
            fistObject.GetComponent <SpriteRenderer>().color = Color.red;
        }
        else if (playerIndex == 4) // Player 4 = Green
        {
            gameObject.GetComponent <SpriteRenderer>().color = Color.green;
            fistObject.GetComponent <SpriteRenderer>().color = Color.green;
        }

        myRigidBody2D = GetComponent <Rigidbody2D>();
        fistScript    = fistObject.GetComponent <FistController>();

        playerHealth = 100.0f; // Default health is 100
        beenPunched  = false;
        isWhosWho    = false;

        // If the player wasn't selected in the main menu
        if (PlayerCount.NumOfPlayers < playerIndex)
        {
            // Disable it
            healthText.SetActive(false);
            healthBar.SetActive(false);
            gameObject.SetActive(false);
        }

        // Sets player to a controller (4 players max)
        if (playerIndex == 1)
        {
            controllerPrefix = "P1";
        }
        else if (playerIndex == 2)
        {
            controllerPrefix = "P2";
        }
        else if (playerIndex == 3)
        {
            controllerPrefix = "P3";
        }
        else if (playerIndex == 4)
        {
            controllerPrefix = "P4";
        }
    }
示例#3
0
 private IEnumerator AddForceToTorso(FistController joystick, Rigidbody2D torsoRb, Transform forcePoint, float torsoForce)
 {
     while (isBeingCarried)
     {
         if (IsColliding)
         {
             torsoRb.AddForceAtPosition(torsoForce * -joystick.Direction, forcePoint.position);
         }
         yield return(new WaitForFixedUpdate());
     }
 }
 public override void PrepareAction(AIController controller)
 {
     fistController = controller.GetComponent <FistController>();
 }
示例#5
0
 public void Carry(FistController joystick, Rigidbody2D torsoRb, Transform forcePoint, float torsoForce)
 {
     isBeingCarried   = true;
     gameObject.layer = 8;
     StartCoroutine(AddForceToTorso(joystick, torsoRb, forcePoint, torsoForce));
 }