Beispiel #1
0
    private void InsertIntoBasket(SkarpetkaController sock)
    {
        if (sock.Pair == null)
        {
            Debug.LogError("WTF?");
            return;
        }

        Sock firstSock  = sock.GetComponent <Sock>();
        Sock secondSock = sock.Pair.GetComponent <Sock>();

        if (firstSock.Equals(secondSock))
        {
            //TODO beautiful animation of successful paired socks
            Destroy(firstSock.gameObject);
            Destroy(secondSock.gameObject);
            CorrectInsertion.Invoke();

            GameState.remainingSocksPairs--;

            if (GameState.remainingSocksPairs <= 0)
            {
                //Win level
                gameStateManager.victory();
            }
        }
        else
        {
            //TODO animation of wrong paired socks
            //sock.MoveTo(StartPos);
            Pile.RemovePairedSocks(firstSock, secondSock);
            Destroy(firstSock.gameObject);
            Destroy(secondSock.gameObject);

            WrongInsertion.Invoke();
            GameState.remainingLifes -= 2;
            FindObjectOfType <UIManager>().UpdateLifes(GameState.remainingLifes);
            GameState.remainingSocksPairs -= 2;

            if (GameState.remainingLifes <= 0)
            {
                gameStateManager.GameOver();
            }
        }
    }