init commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Sniper : Node, ITool {
|
||||
|
||||
public int ToolID { get{ return 0; } } // Match ToolID to ItemStat Index
|
||||
|
||||
Options _Options;
|
||||
Reference _Reference;
|
||||
|
||||
float BulletSpawnSpacing = 2; // Distance off the front of the camera that the bullet spawn
|
||||
|
||||
bool isZoomed = false;
|
||||
float ZoomFOV = 30;
|
||||
float _normalZoom;
|
||||
|
||||
float HipAccuracy = 5; // Maximum offset in degrees | 15 would be 7.5 deg in each direction
|
||||
float HipRecoil = 5; // Maximum offset in degrees | 5 would be 2.5 horizontally and 5 up
|
||||
|
||||
float AimAccuracy = 2; // Maximum offset in degrees
|
||||
float AimRecoil = 2; // Maximum offset in degrees
|
||||
|
||||
public void Equiped() {
|
||||
_Options = GetNode<Options>( "/root/Options" );
|
||||
_Reference = GetNode<Reference>("/root/Reference");
|
||||
_normalZoom = _Reference.Camera.Fov;
|
||||
}
|
||||
|
||||
public void KeyPress( Key key ) {
|
||||
|
||||
}
|
||||
|
||||
public void KeyRelease( Key key ) {
|
||||
|
||||
}
|
||||
|
||||
Vector3 Accuracy() {
|
||||
Random Random = new Random( DateTime.Now.Millisecond );
|
||||
if( isZoomed ) {
|
||||
float xAccuracy = ( ( Random.NextSingle() * 2 ) - 1 ) * AimAccuracy / 2;
|
||||
float yAccuracy = ( ( Random.NextSingle() * 2 ) - 1 ) * AimAccuracy / 2;
|
||||
return new Vector3( xAccuracy, yAccuracy, 0 );
|
||||
} else {
|
||||
float xAccuracy = ( ( Random.NextSingle() * 2 ) - 1 ) * HipAccuracy / 2;
|
||||
float yAccuracy = ( ( Random.NextSingle() * 2 ) - 1 ) * HipAccuracy / 2;
|
||||
return new Vector3( xAccuracy, yAccuracy, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void Recoil() {
|
||||
Random Random = new Random( DateTime.Now.Millisecond );
|
||||
Vector2 recoil;
|
||||
if ( isZoomed ) {
|
||||
float xRecoil = ( ( Random.NextSingle() * 2 ) - 1 ) * AimRecoil / 2;
|
||||
float yRecoil = Random.NextSingle() * AimRecoil;
|
||||
recoil = new Vector2( xRecoil, yRecoil );
|
||||
} else {
|
||||
float xRecoil = ( ( Random.NextSingle() * 2 ) - 1 ) * HipRecoil / 2;
|
||||
float yRecoil = Random.NextSingle() * HipRecoil;
|
||||
recoil = new Vector2( xRecoil, yRecoil );
|
||||
}
|
||||
_Reference.Camera.RotateX( 1 ); // IE Up and Down
|
||||
_Reference.Humanoid.RotateX( 1 ); // IE Left and Right
|
||||
}
|
||||
|
||||
public void LeftMouseDown() {
|
||||
Vector3 LookVector = -_Reference.Camera.GlobalBasis.Z;
|
||||
_Reference.GameHandler.Shoot(ToolID, LookVector, 200);
|
||||
//Recoil();
|
||||
}
|
||||
|
||||
public void LeftMouseUp() {
|
||||
|
||||
}
|
||||
|
||||
public void RightMouseDown() {
|
||||
isZoomed = true;
|
||||
_Reference.Camera.Fov = ZoomFOV;
|
||||
}
|
||||
|
||||
public void RightMouseUp() {
|
||||
isZoomed = false;
|
||||
_Reference.Camera.Fov = _normalZoom;
|
||||
}
|
||||
|
||||
public void UnEquipped() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user