예제 #1
0
    private void Update()
    {
        //Tests for death conditions and handles death
        if (Physics2D.OverlapCircle(entityImage.position, .1f, spike) || Physics2D.OverlapCircle(entityImage.position, .1f, enemy))
        {
            Vibrate(false);
            overlayController.ShowDeathPanel(true);
        }

        //Tests for win conditions and handles win
        else if (Physics2D.OverlapCircle(entityImage.position, .1f, goal))
        {
            Vibrate(false);
            overlayController.ShowVictoryPanel(true);
        }

        //else updates isOnEnemyPath and tileInFront(if nessesary)
        else
        {
            SetIsOnEnemyPath();

            //Checks if the mask in front is the same as the mask of tileInFront                 (a mask that would be -1 i.e. doenst exist becomes 0 and is interpreted by IsMaskInFrontOf as there being no mask in front of it)
            if (!IsMaskInFrontOf((int)Math.Pow(2, LayerMask.NameToLayer(tileInFront))))
            {
                //DebugLog("Tile: "+tileInFront+" layer: "+ LayerMask.NameToLayer(tileInFront)+"|");
                DetectTileInFront();
            }
        }
    }