示例#1
0
        public override void reset()
        {
            base.reset();
            Game     game = Game.GAME_INSTANCE;
            Location l    = this.getLocation();

            l.addYaw(-game.getGamePad().AnalogRightX);
            l.addPitch(game.getGamePad().AnalogRightY);

            if (game.getGamePad().AnalogLeftX != 0)
            {
                Location clone = l.clone();
                clone.addYaw(90);
                double p = clone.getPitch();
                clone.setPitch(0);
                clone = clone.getRelativeInFacingDirection(-game.getGamePad().AnalogLeftX / 10.0);
                clone.addYaw(-90);
                clone.setPitch(p);
                l.set(clone);
            }

            if (game.getGamePad().AnalogLeftY != 0)
            {
                Location clone = l.clone();
                clone = clone.getRelativeInFacingDirection(-game.getGamePad().AnalogLeftY / 10.0);
                l.set(clone);
            }

            Location newTarget = l.getRelativeInFacingDirection(1);

            this.getTarget().set(newTarget);
            newTarget.Dispose();
        }
示例#2
0
        public double determinePitch(Location target, double offset = 90)
        {
            double dX    = this.getDistanceX(target);
            double dY    = this.getDistanceY(target);
            double dZ    = this.getDistanceZ(target);
            double pitch = Math.Atan2(Math.Sqrt(dZ * dZ + dX * dX), dY) + Math.PI;

            pitch = MathUtils.toDegrees(pitch) + offset;
            if (this.getOwner() != null && this.getOwner().getParent() != null)
            {
                Location pAbs = this.getOwner().getParent().getLocation().getAbsoluteLocation();
                pitch -= pAbs.getPitch();
                pAbs.Dispose();
            }
            return(pitch);
        }