Exemple #1
0
        protected virtual void DoHit(int damage)
        {
            if (crosshairHitInfo.voxelIndex < 0)
            {
                return;
            }

            lastHitButtonPressed = Time.time;
            seekTarget           = crosshairHitInfo;
            // make character approach target if needed
            seeking = !TargetIsReachable();
            if (seeking)
            {
                seekAction = SeekAction.Hit;
            }
            else
            {
                StartCoroutine(CompleteHit(damage));
            }
        }
Exemple #2
0
        public IAction ReactTo(VehicleState state, int waypoint)
        {
            var projectedState = lastAction == null
                ? state
                : motionModel.CalculateNextState(state, lastAction, reactionTime).Last().state;

            projectedPosition.OnNext(projectedState.Position);

            var target = findClosestPoint(projectedState);

            selectedTarget.OnNext(path[target].State.Position);

            var throttle = 0.1; // target.Speed / vehicleModel.MaxSpeed;
            var steering = calculateSteering(state, target);

            var action = new SeekAction(throttle, steering);

            lastAction = action;
            return(action);
        }
Exemple #3
0
        private static void EditImage(JobParameter param, JobType type, SeekAction imageSeekAction)
        {
            ImageProcessParameter processParameter = new ImageProcessParameter(param, type);

            try
            {
                Bitmap image = processParameter.Image.CreateBitmapDeepCopy();

                var imageData =
                    image.LockBits(
                        new Rectangle(0, 0, processParameter.Image.ImgWidth, processParameter.Image.ImgHeight),
                        ImageLockMode.ReadWrite,
                        processParameter.Image.ImgPixelFormat);

                imageSeekAction(imageData, processParameter.PixelAction, param.Worker, processParameter.Image.BytesPerPixel);

                if (param.Worker.CancellationPending)
                {
                    param.Args.Cancel = true;
                    image.UnlockBits(imageData);
                    return;
                }

                param.Worker.ReportProgress(100);

                image.Save(Paths.GetOutputImageFullName(param.JobId, "jakubsChange", processParameter.Description));

                param.Args.Result = processParameter.Result;

                image.UnlockBits(imageData);
            }catch (Exception)
            {
                param.Worker.CancelAsync();
                if (param.Worker.CancellationPending)
                {
                    param.Args.Cancel = true;
                }
            }
        }
Exemple #4
0
        void CheckCommonKeys()
        {
            bool leftAltPressed     = input.GetButton(InputButtonNames.LeftAlt);
            bool leftShiftPressed   = input.GetButton(InputButtonNames.LeftShift);
            bool leftControlPressed = input.GetButton(InputButtonNames.LeftControl);

            bool fire1Clicked = false;
            bool fire2Clicked = false;

            bool overUI = EventSystem.current.IsPointerOverGameObject();

            if (!overUI)
            {
                fire1Clicked = input.GetButtonDown(InputButtonNames.Button1);
                fire2Clicked = input.GetButtonClick(InputButtonNames.Button2);
            }

            if (!leftShiftPressed && !leftAltPressed && !leftControlPressed)
            {
                if (crosshairOnBlock && input.GetButtonClick(InputButtonNames.Button1))
                {
                    env.TriggerVoxelClickEvent(crosshairHitInfo.chunk, crosshairHitInfo.voxelIndex, 0);
                }
                if (fire1Clicked)
                {
                    firePressed = true;
                    if (ModelPreviewCancel())
                    {
                        firePressed          = false;
                        lastHitButtonPressed = Time.time + 0.5f;
                    }
                    if (firePressed && Time.time - lastHitButtonPressed > player.GetHitDelay())
                    {
                        timeSeeking       = Time.time;
                        lastReachDistance = float.MaxValue;
                        if (crosshairHitInfo.item != null)
                        {
                            crosshairHitInfo.item.PickItem();
                            crosshairOnBlock = false;
                            firePressed      = false;
                        }
                        else
                        {
                            DoHit(player.GetHitDamage());
                        }
                    }
                }

                if (fire2Clicked)
                {
                    timeSeeking       = Time.time;
                    lastReachDistance = float.MaxValue;
                    seekTarget        = crosshairHitInfo;
                    // make character approach target if needed
                    seeking = !TargetIsReachable(true);
                    if (seeking)
                    {
                        seekAction = SeekAction.Move;
                    }
                    else
                    {
                        DoBuild(curPos, transform.forward, crosshairHitInfo.voxelCenter);
                    }
                }
            }


            if (input.GetButtonDown(InputButtonNames.Build))
            {
                env.SetBuildMode(!env.buildMode);
                if (env.buildMode)
                {
                    env.ShowMessage("<color=green>Entered <color=yellow>Build Mode</color>. Press <color=white>B</color> to cancel.</color>");
                }
                else
                {
                    env.ShowMessage("<color=green>Back to <color=yellow>Normal Mode</color>.</color>");
                }
            }
            else if (input.GetButtonDown(InputButtonNames.SeeThroughUp))
            {
                env.seeThroughHeightOffset++;
            }
            else if (input.GetButtonDown(InputButtonNames.SeeThroughDown))
            {
                env.seeThroughHeightOffset--;
            }
        }