Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TankFireTest
- {
- public class Vector3
- {
- public Vector3(float ix, float iy, float iz)
- {
- X = ix;
- Y = iy;
- Z = iz;
- }
- public float X { get; set; }
- public float Y { get; set; }
- public float Z { get; set; }
- public static float DotProduct(Vector3 a, Vector3 b)
- {
- return (a.X * b.X) + (a.Y * b.Y) + (a.Z * b.Z);
- }
- public static float GetLength(Vector3 v)
- {
- float len2 = (v.X * v.X) + (v.Y * v.Y) + (v.Z * v.Z);
- return (float)Math.Sqrt(len2);
- }
- }
- class Program
- {
- bool TankCanFire( playerRange, enemyPosition )
- {
- if (playerRange <= enemyTankPosition )
- {
- return true;
- }
- return false;
- }
- static void Main(string[] args)
- {
- Vector3 playerPosition = new Vector3( 10, 15, 10 );
- Vector3 playerFacing = new Vector3(0.0f, 0.0f, 1.0f);
- float playerRange = 100.0f;
- Vector3 enemyTankPosition = new Vector3( -15, 10, 25 );
- Vector3 enemyFacing = new Vector3(0.0f, 0.0f, 1.0f);
- if (TankCanFire(playerRange,enemyPosition)== true)
- {
- Console.WriteLine("Firing!");
- }
- else
- {
- Console.WriteLine("Cannot fire");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment