void Awake() { playerCount = MyPlayerManager.players.Count; SetupPlayer(straightPunchTagName, uppercutTagName, downAirTagName); playerRigidbody = GetComponent <Rigidbody2D>(); playerCollider = GetComponent <Collider2D>(); playerGroundCheckCollider = playerGroundCheck.GetComponent <Collider2D>(); gameManager = GameObject.Find("GameManager"); gameManagerScript = gameManager.GetComponent <GameManager>(); oneWayPlateformMask = LayerMask.GetMask("OneWayPlateform"); energyDecrease = false; spendEnergy = false; currentEnergy = maximumEnergy; energyGauge.fillAmount = maximumEnergy / maximumEnergy; if (splitWall == null) { splitWall = GameObject.Find("Split Wall"); } if (splitWall != null && splitWallMovement == null) { splitWallMovement = splitWall.GetComponent <WallSplitMovement>(); } guiStyle.normal.textColor = Color.white; }
private void Start() { hasHit = false; rb = GetComponent <Rigidbody2D>(); _collider = GetComponent <Collider2D>(); buttonCollider = GetComponent <Collider2D>(); splitWallTransform = splitWallTransform.GetComponent <Transform>(); if (splitWall == null) { splitWall = GameObject.Find("Split Wall"); } if (splitWall != null && splitWallMovement == null) { splitWallMovement = splitWall.GetComponent <WallSplitMovement>(); } currentVelocity = startVelocity; }
public void Punch(int playerNumber, int playerStrenght, int playerTotalStrenght) { //Debug.Log("Player Number = " + playerNumber); Debug.Log("punch function called"); if (playerNumber == 1) { if (WallSplitMovement.horizontalVelocity >= .0f) { hasJustHitButton = true; Physics2D.IgnoreLayerCollision(9, 11, true); WallSplitMovement.ApplyHorizontalForce(playerStrenght); } else if (WallSplitMovement.horizontalVelocity < .0f) { hasJustHitButton = true; Physics2D.IgnoreLayerCollision(9, 11, true); WallSplitMovement.ApplyHorizontalForce(playerTotalStrenght); } } if (playerNumber == 2) { if (WallSplitMovement.horizontalVelocity <= .0f) { hasJustHitButton = true; Physics2D.IgnoreLayerCollision(9, 11, true); WallSplitMovement.ApplyHorizontalForce(-playerStrenght); } else if (WallSplitMovement.horizontalVelocity > .0f) { hasJustHitButton = true; Physics2D.IgnoreLayerCollision(9, 11, true); WallSplitMovement.ApplyHorizontalForce(-playerTotalStrenght); } } }