// Start is called before the first frame update
    public bool GhostHide(PlayerHideScript GhostPlayerHideScript)
    {
        //////TODO: Checks needed if multiple ghosts allowed.
        //CheckOccupancy();
        //Debug.Log(GhostOccupying);
        //// If statement is lazy, so if checkoccupancy = false it won't trigger the changedomoticzswitch
        //if (GhostOccupying == false)
        //{
        //    // Check and excecute changing of
        //    if ((mainConnectionScript.ChangeDomoticzSwitchStatus(idx, true) == true))
        //    {
        //        GhostOccupying = true;
        //        return true;
        //    }
        //    else { return false; }
        //}
        //else { return false; }

        // This is only for single player!!
        // TODO: Error handling
        if (ghostOccupying == false)
        {
            StartCoroutine(mainConnectionScript.ChangeDomoticzSwitchStatus(idx, true));
            StartCoroutine(mainConnectionScript.GhostCheckIfCaught(checkedHidableObjectidx, GhostPlayerHideScript));
            ghostOccupying = true;
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #2
0
    public IEnumerator GhostCheckIfCaught(int checkedHidableObjectidx, PlayerHideScript GhostPlayerHideScript)
    {
        switchIsOn = false;

        yield return(StartCoroutine(CheckDomoticzSwitchStatus(checkedHidableObjectidx)));


        bool ghostIsCaught = switchIsOn;

        if (ghostIsCaught)
        {
            GhostPlayerHideScript.GhostCaught();
            StartCoroutine(ChangeDomoticzSwitchStatus(checkedHidableObjectidx, false));
        }
        else if (GhostPlayerHideScript.ghostIsHidden)
        {
            yield return(StartCoroutine(GhostCheckIfCaught(checkedHidableObjectidx, GhostPlayerHideScript)));
        }
    }