Пример #1
0
    public void Start()
    {
        const float weebleHeightOffset = 1.1f;

        foreach (Transform weebleTransform in GameObject.Find("Agents/Weebles").transform)
        {
            if (World.Instance != null)
            {
                MovingEntity movingEntity = weebleTransform.GetComponent <MovingEntity>();

                if (movingEntity != null)
                {
                    PathManager pathManager = weebleTransform.GetComponent <PathManager>();
                    if (pathManager != null)
                    {
                        SearchSpace searchSpace = pathManager.searchSpace;
                        if (searchSpace != null)
                        {
                            weebleTransform.position = movingEntity.PositionAt(searchSpace.GetRandomEntityPosition());
                        }
                        else
                        {
                            weebleTransform.position = movingEntity.PositionAt(World.Instance.GetRandomEntityPosition(movingEntity));
                        }
                    }
                    else
                    {
                        weebleTransform.position = movingEntity.PositionAt(World.Instance.GetRandomEntityPosition(movingEntity));
                    }
                }
                else
                {
                    weebleTransform.position = World.Instance.GroundPositionAt(World.Instance.GetRandomPosition(), weebleHeightOffset);
                }
            }
            else
            {
                weebleTransform.position = Vector3.up * weebleHeightOffset;
            }
        }
    }
Пример #2
0
    public void Update()
    {
        if (searchSpaceCanChange)
        {
            SetSearchSpace();
        }

        if (searchSpace == null || !searchSpace.enabled)
        {
            return;
        }

        // This is for manual testing via the Inspector
        if (requestPath)
        {
            PathRequestEventPayload request =
                new PathRequestEventPayload(searchSpace.gameObject, searchSpace.GetRandomEntityPosition());
            EventManager.Instance.Enqueue <PathRequestEventPayload>(Events.PathRequest, request);
            requestPath = false;
        }
    }