コード例 #1
0
    /// <summary>
    ///     Moves the camera to a new position.
    /// </summary>
    private IEnumerator MoveCamera(Vector3 newPosition)
    {
        GameObject cameraObject = AppCentral.APP.GetCameraObject();

        if (cameraObject != null)
        {
            if (MovingCamera != null)
            {
                MovingCamera.Invoke();
            }

            Vector3 startPosition = cameraObject.transform.position;
            newPosition.y = startPosition.y;

            float progress = 0.0f;
            while (progress <= 1.0f)
            {
                progress = progress + Time.deltaTime;
                cameraObject.transform.position = Vector3.Lerp(startPosition, newPosition, progress);
                yield return(null);
            }

            if (DestinationReached != null)
            {
                DestinationReached.Invoke();
            }
        }
    }
コード例 #2
0
        void MoveFrame(float distance)
        {
            while (distance > 0)
            {
                var direction          = Entity.Position.DirectionTo(CurrentWaypoint);
                var distanceToWaypoint = Entity.Position.DistanceTo(CurrentWaypoint);

                var cell = Waypoints.Peek();

                if (distanceToWaypoint > distance)
                {
                    Entity.Position += direction * distance;
                    return;
                }

                Entity.Position = CurrentWaypoint;

                this.Log($"Pathfinding reached waypoint {CurrentWaypoint}");

                Waypoints.Dequeue();

                if (!HasWaypoints)
                {
                    this.Log($"Pathfinding reached destination");

                    DestinationReached?.Invoke(this, new CellEventArgs(cell));
                    return;
                }

                distance -= distanceToWaypoint;
            }
        }
コード例 #3
0
        protected void OnDestinationReached()
        {
            destination_set = false;

            entity_toFollow = null;
            direction       = Vector2.Zero;
            State           = STATE_CmpAI_Follower.NoneToFollow;

            if (DestinationReached != null)
            {
                DestinationReached.Invoke(this, new EntityArgs(this.parent, this));
            }
        }
コード例 #4
0
        public void OnDestinationReached(object sender, PathfinderComponent.CellEventArgs e)
        {
            this.Log(CurrentDestination
                ? $"Travel reached location {CurrentDestination}"
                : $"Travel reached missing location");

            if (!CurrentDestination)
            {
                return;
            }

            CurrentDestination.EntityRegistry.Register(Entity);

            DestinationReached?.Invoke(this, new MapComponent.LocationEventArgs(CurrentDestination));
        }
コード例 #5
0
        public void SetDestination(Vector2Int destinationCell)
        {
            var map = Entity ? Entity.Map ? Entity.Map : Locator.City ? Locator.City.Map : null : null;

            if (!map)
            {
                this.Log($"Pathfinding can not find path without being registered in a map.", LogType.Warning);
                return;
            }

            Waypoints.Clear();
            DestinationChanged?.Invoke(this, new CellEventArgs(destinationCell));

            this.Log($"Pathfinding sending entity from {Entity.CellPosition} to {destinationCell}");

            if (CellPosition == destinationCell)
            {
                this.Log($"Pathfinding entity was already at {destinationCell}");

                DestinationReached?.Invoke(this, new CellEventArgs(destinationCell));
                return;
            }

            var newWaypoints = Path.FindPath(CellPosition, destinationCell, map);

            Waypoints = newWaypoints ?? new Queue <Vector2Int>();

            if (Waypoints.Count == 0)
            {
                this.Log($"Pathfinding couldn't find a path!", LogType.Warning);

                DestinationReached?.Invoke(this, new CellEventArgs(destinationCell));
            }
            else
            {
                TotalWaypoints = Waypoints.Count;
            }
        }
コード例 #6
0
 private void OnDestinationReached(Vehicle vehicle, VehicleStationLocation vehicleStation, RootTask task)
 {
     //           NotificationUtils.ShowVehicleHint(vehicle, "OnDestinationReached " + vehicleStation.Location.Name);
     DestinationReached?.Invoke(vehicle, vehicleStation, task);
 }
コード例 #7
0
 public void NextStatus(Order order)
 {
     order._orderStatus = DestinationReached.GetInst();
 }
コード例 #8
0
ファイル: Camera2DCutscene.cs プロジェクト: emhean/Seraf
 private void OnDestinationReached()
 {
     DestinationReached?.Invoke(this, EventArgs.Empty);
 }