コード例 #1
0
ファイル: Patrol.cs プロジェクト: maukii/IGCC2018
    // Execute patrolState
    public override void Execute(Bot bot)
    {
        NavMeshAgent agent = bot.Agent;

        //  set next position if agent arived at nearby to destination

        if (agent.pathStatus != NavMeshPathStatus.PathInvalid)
        {
            if (!agent.pathPending && agent.remainingDistance < NEARBY_DISTANCE)
            {
                if (_iotTrget)
                {
                    _iotTrget.Disable();
                }

                _oldLight       = _lightingTarget;
                _oldHackable    = _hackableTarget;
                _lightingTarget = null;
                GotoNextPoint(agent);
            }

            // detecting
            if (!_lightingTarget)
            {
                SearchHackable(agent);

                SearchLightObject(agent);
            }
        }
    }
コード例 #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();
                }
            }
        }
    }