コード例 #1
0
ファイル: Patrol.cs プロジェクト: maukii/IGCC2018
    // Assume this is the IoT target or something
    bool FindIoT(GameObject target)
    {
        _iotTrget = target.GetComponent <IoTBaseObj>();

        // TRUE = its on
        if (_iotTrget != null && _iotTrget.GetActivated())
        {
            // Check the type of the IoT.
            switch (target.GetComponent <IoTBaseObj>().GetIoTType())
            {
            case "Door":
                return(true);

            case "Audio":
                return(true);

            case "Light":
                return(true);

            default:
                // If not tagged properly, ignore it
                return(false);
            }
        }
        return(false);
    }
コード例 #2
0
    void SearchDoor(NavMeshAgent agent)
    {
        // ray reset
        Vector3 rayPos = agent.transform.position;

        rayPos.y = rayPos.y + RAY_HEIGHT;
        Ray ray = new Ray(rayPos, agent.transform.up * -1);

        // ray casting to around Objects
        RaycastHit[] hitinfos = Physics.SphereCastAll(ray, _detectingRange / 4);

        // if detect hackable object change target
        foreach (var hitinfo in hitinfos)
        {
            // detect "IoT" object by tag
            GameObject hitObj = hitinfo.transform.gameObject;
            _iotTrget = hitObj.GetComponent <IoTBaseObj>();

            if (_iotTrget != null && _iotTrget.GetActivated())
            {
                // Check the type of the IoT.
                if (_iotTrget.GetIoTType() == "Door")
                {
                    _iotTrget.Disable();
                }
            }
        }
    }