Example #1
0
    //from http://answers.unity3d.com/questions/209472/detecting-when-all-rigidbodies-have-stopped-moving.html
    //modified by Marshall Mason
    IEnumerator CheckObjectsHaveStopped()
    {
        Rigidbody2D[] GOS         = FindObjectsOfType(typeof(Rigidbody2D)) as Rigidbody2D[];
        bool          allSleeping = false;

        while (!allSleeping)
        {
            allSleeping = true;
            GOS         = FindObjectsOfType(typeof(Rigidbody2D)) as Rigidbody2D[];
            foreach (Rigidbody2D GO in GOS)
            {
                if (!GO.IsSleeping())
                {
                    allSleeping = false;
                    yield return(null);

                    break;
                }
            }
        }

        yield return(new WaitForSeconds(1));

        trackingShot = false;
        if (player != null)
        {
            Destroy(player.gameObject);
        }
    }
Example #2
0
    public IEnumerator RollAttackDice(System.Action <Player> callBack)
    {
        // TODO change the first param to be dynamic!
        DiceRollerBase.showDiceArea(1, true);
        Rigidbody[] GOS         = FindObjectsOfType(typeof(Rigidbody)) as Rigidbody[];
        bool        allSleeping = false;

        while (!allSleeping)
        {
            allSleeping = true;

            foreach (Rigidbody GO in GOS)
            {
                if (!GO.IsSleeping())
                {
                    allSleeping = false;
                    yield return(null);

                    break;
                }
            }
        }

        DiceRollerBase.getDiceResults(GOS);

        Player result = null;

        if (LocalDataWrapper.getPlayer().getLastDiceResults()[0] == DiceRollerBase.DICE_RESULT_HIT_OR_EVADE || LocalDataWrapper.getPlayer().getLastDiceResults()[0] == DiceRollerBase.DICE_RESULT_CRIT)
        {
            result = MatchDatas.getPlayers()[0];
        }
        else
        {
            result = MatchDatas.getPlayers()[1];
        }

        callBack(result);
    }