PsyOps

Drone.MakeDrone

Jun 25th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using BattleCore.Events;
  7. using BattleCore;
  8.  
  9. namespace Drone
  10. {
  11.     class MakeDrone
  12.     {
  13.         // This will hold all packet info to be updated by dronetimer
  14.         private PlayerPositionEvent _Position = new PlayerPositionEvent();
  15.         /// <summary>
  16.         /// Drone PlayerPosition
  17.         /// </summary>
  18.         public PlayerPositionEvent Position
  19.         {
  20.             get { return _Position; }
  21.             set { _Position = value; }
  22.         }
  23.  
  24.         // Tracks weapons
  25.         WeaponTracker _WepTrack = new WeaponTracker();
  26.         // Controls energy
  27.         EnergyControl _Energy = new EnergyControl();
  28.         // Controls rotation
  29.         Rotation _Rotation = new Rotation();
  30.         // Tracks players to see who is closest
  31.         PlayerTracker _PlayTrack = new PlayerTracker();
  32.         // Drone timer interval
  33.         double _Rate;
  34.  
  35.         /// <summary>
  36.         /// All variables needed by drone.
  37.         /// </summary>
  38.         /// <param name="DronePosition">Position packet info.</param>
  39.         /// <param name="rate">Interval between updates to game.</param>
  40.         /// <param name="range">How far from drone player has to be before it initiates.</param>
  41.         /// <param name="rotation">Rotation drone turns back to when there are no targets left.</param>
  42.         public void SetVariables(PlayerPositionEvent DronePosition, double rate, ushort range, byte rotation)
  43.         {
  44.             // Entering all settings required by drone from cfg
  45.             _Position = DronePosition;
  46.             _Rotation.SetVariables(_Position.MapPositionX, _Position.MapPositionY,rotation);
  47.             _Rate = rate;
  48.             _WepTrack.Rate = (ushort)rate;
  49.  
  50.             _PlayTrack.SetVariables(_Position.MapPositionX, _Position.MapPositionY, range);
  51.         }
  52.         public void SetVariables2(ushort maxenergy, double rechargerate, ushort bombalive, ushort bulletalive, ushort bombspeed,ushort bombthrust, ushort bulletspeed)
  53.         {
  54.             _Energy.SetVariables(maxenergy, rechargerate, _Rate);
  55.             _WepTrack.SetVariables(bombalive, bulletalive, bombspeed,bombthrust, bulletspeed);
  56.         }
  57.  
  58.         /// <summary>
  59.         /// Update rotation and recharge.
  60.         /// </summary>
  61.         public void UpdateDrone()
  62.         {
  63.             // ROTATION
  64.             if (!_PlayTrack.ListEmpty)
  65.                 _Rotation.UpdatedRotation(_Position, _Rotation.RotationToTarget(_PlayTrack.ClosestPlayer.MapPositionX, _PlayTrack.ClosestPlayer.MapPositionY));
  66.             else if (_PlayTrack.ListEmpty)
  67.                 _Rotation.NoTarget(_Position);
  68.  
  69.             // RECHARGE
  70.             _Energy.RechargeEnergy(_Position);
  71.  
  72.             // Weapon Tracking
  73.             _WepTrack.UpdateWeaponTracker();
  74.         }
  75.         //-------------------------------------\\
  76.         //       Energy                         |
  77.         //-------------------------------------//
  78.         public void Damage(string assaulter,ushort damage)
  79.         {
  80.             _Energy.DealDamage(assaulter,damage,_Position);
  81.         }
  82.         public bool Alive
  83.         { get { return _Energy.IsAlive; } }
  84.         public string Killer
  85.         { get { return _Energy.BotKiller; } }
  86.         //-------------------------------------\\
  87.         //       Weapon Tracker                 |
  88.         //-------------------------------------//
  89.         public Queue<WeaponTracker.WeaponFired> ExpiredShots
  90.         {
  91.             get { return _WepTrack.ExpiredShots; }
  92.             set { _WepTrack.ExpiredShots = value; }
  93.         }
  94.         public WeaponTracker.WeaponFired LastFired
  95.         {
  96.             get { return _WepTrack.LastFired; }
  97.             set { _WepTrack.LastFired = value; }
  98.         }
  99.         //-------------------------------------\\
  100.         //       Player Tracker                 |
  101.         //-------------------------------------//
  102.         /// <summary>
  103.         /// Player movement within drone range
  104.         /// </summary>
  105.         /// <param name="position">PlayerPosition Packet</param>
  106.         public void NearMovement(PlayerPositionEvent position)
  107.         {
  108.             _PlayTrack.PlayerMovement(position);
  109.  
  110.             string wep = position.Weapon.Type.ToString().ToLower();
  111.  
  112.             if (wep.Contains("bullet") || wep.Contains("bomb") || wep.Contains("thor"))
  113.             {
  114.                 _WepTrack.NewShot(position);
  115.             }
  116.         }
  117.         /// <summary>
  118.         /// Search and remove player from list.
  119.         /// </summary>
  120.         /// <param name="PlayerName">Player name.</param>
  121.         public void RemovePlayer(string PlayerName)
  122.         {
  123.             _PlayTrack.RemovePlayer(PlayerName);
  124.         }
  125.     }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment