Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @SelfPass(int _posX, int _posY)
- * @param _posX posicion futura de la pelota
- * @param _posY posicion futura de la pelota
- * Detecta autopase para nivel 1
- * retorna true si es autopase
- * false si no es autopase
- * @by Mario Acosta
- * */
- public bool SelfPass(int _posX, int _posY)
- {
- int x,y;
- Vector2 _currentCoor;
- GameObject _player = null;
- _player = GameObject.FindWithTag((activePlayer.ToString()));
- //Guardamos la posicion del jugador
- _currentCoor = new Vector2(_player.transform.position.x, _player.transform.position.z);
- x = (int)_currentCoor.x;
- y = 10-(int)_currentCoor.y;
- int _deltaX = (int)Mathf.Abs(x - _posX);
- int _deltaY = (int)Mathf.Abs(y - _posY); //con valor absoluto
- if( (int)Mathf.Max(_deltaX, _deltaY) <= 1)
- {
- if(_deltaX == _deltaY || ((_deltaX == 0) && (_deltaY != 0)) || ((_deltaX != 0) && (_deltaY == 0)))
- {
- return true;
- }
- }
- else
- {
- return false;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement