Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. /* @SelfPass(int _posX, int _posY)
  2. * @param _posX posicion futura de la pelota
  3. * @param _posY posicion futura de la pelota
  4. * Detecta autopase para nivel 1
  5. * retorna true si es autopase
  6. * false si no es autopase
  7. * @by Mario Acosta
  8. * */
  9. public bool SelfPass(int _posX, int _posY)
  10. {
  11. int x,y;
  12. Vector2 _currentCoor;
  13. GameObject _player = null;
  14. _player = GameObject.FindWithTag((activePlayer.ToString()));
  15.  
  16.  
  17. //Guardamos la posicion del jugador
  18. _currentCoor = new Vector2(_player.transform.position.x, _player.transform.position.z);
  19. x = (int)_currentCoor.x;
  20. y = 10-(int)_currentCoor.y;
  21.  
  22. int _deltaX = (int)Mathf.Abs(x - _posX);
  23. int _deltaY = (int)Mathf.Abs(y - _posY); //con valor absoluto
  24.  
  25. if( (int)Mathf.Max(_deltaX, _deltaY) <= 1)
  26. {
  27. if(_deltaX == _deltaY || ((_deltaX == 0) && (_deltaY != 0)) || ((_deltaX != 0) && (_deltaY == 0)))
  28. {
  29. return true;
  30. }
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36. return false;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement