public override IEnumerator TakeTurn()
    {
        DidAction      = false;
        projectileShot = null;

        MazeUnit possibleTarget = VisionUtils.FindVisibleEnemy(transform, visionRange, enemyLayers, visionBlockingLayers);

        if (possibleTarget)
        {
            Attack(possibleTarget);
            DidAction = true;

            if (ShouldAnimate())
            {
                animator.SetTrigger("Attack");

                yield return(null);

                while (!IsAnimationIdle())
                {
                    yield return(null);
                }
            }

            while (projectileShot)
            {
                yield return(null);
            }
        }
    }
Beispiel #2
0
        public async Task <JsonResult> FromFile(IFormFile imgFile)
        {
            using (var stream = new MemoryStream())
            {
                await imgFile.CopyToAsync(stream);

                var visionUtil = new VisionUtils(_azureSettings);
                return(Json(await visionUtil.GetResult(stream)));
            }
        }
Beispiel #3
0
    // OnPreCull is called just before rendering begins
    private void OnVisionUpdate()
    {
#if !UNITY_EDITOR
        Quaternion orientation;
        Vector3    position;
        VisionUtils.GetCameraTransform(out position, out orientation);
        transform.localRotation = orientation;
        transform.localPosition = position;

        RegenerateProjectionIfNecessary();
#else
#endif
    }
Beispiel #4
0
    /*!
     * @brief	get's the transform to position sphero as \a position and \a orientation components
     * @param	position Vector3 to store sphero's position
     * @param	orientation Quaternion to store sphero's orientation
     */
    private void GetSpheroTransform(out Vector3 position, out Quaternion orientation)
    {
        float yaw;

        if (ARUNBridge.CurrentARResult.CalibratingPutCount >= kPutCountForVisionHeading)
        {
            yaw = ComputeSpheroHeadingVision();
        }
        else
        {
            yaw = ComputeSpheroHeadingCalibration();
        }

        orientation = Quaternion.Euler(0.0f, -yaw, 0.0f);
        position    = VisionUtils.s_spheroToUnityTransform * SpheroNativePosition();

        VisionUtils.AdjustSpheroTransformUsingHeadBob(ref position, ref orientation);
    }
    public override IEnumerator TakeTurn()
    {
        DidAction = false;

        if (turnsSinceLastMove != -1)
        {
            turnsSinceLastMove++;
        }

        // Still lock on targets even if we can't move right now
        if (!target)
        {
            target = VisionUtils.FindVisibleEnemy(transform, visionRange, enemyLayers, visionBlockingLayers);
        }

        if (turnsSinceLastMove != -1 && turnsSinceLastMove < turnsPerMove)
        {
            yield break;
        }

        if (target)
        {
            List <Vector2Int> path = AStar.FindPath(
                Maze.Instance,
                unit.GetMovement().GetMazePos(),
                target.GetMovement().GetMazePos(),
                Maze.Instance.GetValidNeighbourCoords(target.GetMovement().GetMazePos()));

            if (path.Count > pursuitSteps)
            {
                target = null;
                yield break;
            }

            if (path.Count >= 1 && unit.GetMovement().AttemptMoveToPos(path[1]))
            {
                turnsSinceLastMove = 0;
                DidAction          = true;
            }
        }

        yield break;
    }
Beispiel #6
0
        public async Task <JsonResult> Index(string imageUrl)
        {
            var visionUtil = new VisionUtils(_azureSettings);

            return(Json(await visionUtil.GetResult(imageUrl)));
        }