コード例 #1
0
        /**
         *
         * Call scanBuffer() to see if a buffer contains any potential matches. Any
         * matches are given to the ScannerTarget specified. The count of matches is
         * returned.
         *
         * @param buf
         *            Buffer to scan
         * @param target
         *            ScannerTarget to notify when any matches are found
         * @return int count of matches
         */
        public int ScanBuffer(String buf, ScannerTarget target)

        {
            int match_count = 0;

            for (int i = 0; i < buf.Length; ++i)

            {
                // do a test on first character or on any other character where the
                // previous
                // character is matched by the prefix tester object
                bool needs_testing = (i == 0);
                if (i != 0)

                {
                    needs_testing = prefix_tester.isPrefix(buf[i - 1]);
                }

                // TODO: prefix_tester's result is currently ignored

                if (true)

                {
                    // find the longest matching word in a tree
                    TreeNode n = tree.findLongest(buf, i);
                    if (n != null)

                    {
                        target.matchFound(this, n);
                        match_count++;
                    }
                }
            }
            return(match_count);
        }
コード例 #2
0
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (this.linesDrawn)
        {
            return;
        }

        if (Time.frameCount % 20 == 0)
        {
            if (this.DroneLogic.ScannerScript.ScanFinished)
            {
                for (int i = 0; i < this.DroneLogic.ScannerScript.Targets.Length; i++)
                {
                    ScannerTarget target = this.DroneLogic.ScannerScript.Targets[i];

                    NavMeshPath path = new NavMeshPath();

                    // calculate path from player to scan targets
                    NavMesh.CalculatePath(this.DroneLogic.PlayerTransform.position, target.Target.position, NavMesh.AllAreas, path);

                    if (path.status != NavMeshPathStatus.PathInvalid)
                    {
                        this.DroneLogic.ScannerScript.AddDirections(target, path.corners);
                    }
                }

                this.linesDrawn = true;
            }
        }
    }
コード例 #3
0
    public void AddDirections(ScannerTarget target, Vector3[] corners)
    {
        #region create target icon

        // calculate rotation from player's position to first corner
        Quaternion rotationToTarget = Quaternion.LookRotation(corners[1] - this.playerTransform.position);

        // calculate icon's position = player.position + icon offset
        Vector3 iconPosition = this.playerTransform.position + rotationToTarget * target.IconOffset;

        // create icon game object at calculated location
        GameObject iconGameObject = GameObject.Instantiate(target.IconPrefab);
        iconGameObject.transform.position = iconPosition;
        // rotate towards player
        iconGameObject.transform.LookAt(this.playerTransform.position);

        this.directions.Add(iconGameObject);

        #endregion

        #region create direction line

        GameObject lineGameObject = new GameObject(target.Target.name + " - directions");

        LineRenderer line = lineGameObject.AddComponent <LineRenderer>();
        line.positionCount = corners.Length;
        //line.startColor = this.DirectionsColor;
        //line.endColor = this.DirectionsColor;
        line.startWidth = 1f;
        line.endWidth   = 1f;
        Material mat = new Material(Shader.Find("LightweightPipeline/Particles/Standard Unlit"));
        line.material       = mat;
        line.material.color = this.DirectionsColor;

        //TODO: increase line height above ground
        line.SetPositions(corners);

        this.directions.Add(lineGameObject);

        #endregion
    }