Advertisement
PsyOps

Base.cs Rewrite

Dec 5th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace BaseDuel
  7. {
  8.     public class Base2
  9.     {
  10.         private string m_BaseName;
  11.         public string BaseName
  12.         { get { return m_BaseName; } }
  13.  
  14.         private ushort[] m_AlphaBaseRegion;
  15.         private ushort[] m_AlphaStart;
  16.         public ushort AlphaStartX
  17.         {   get { return m_AlphaStart[0]; } }
  18.         public ushort AlphaStartY
  19.         {   get { return m_AlphaStart[1]; } }
  20.         public bool PlayerInAlphaBase(ushort x, ushort y)
  21.         {
  22.             return m_Collision(0, x, y);
  23.         }
  24.  
  25.         private ushort[] m_BravoBaseRegion;
  26.         private ushort[] m_BravoStart;
  27.         public ushort BravoStartX
  28.         { get { return m_BravoStart[0]; } }
  29.         public ushort BravoStartY
  30.         { get { return m_BravoStart[1]; } }
  31.         public bool PlayerInBravoBase(ushort x, ushort y)
  32.         {
  33.             return m_Collision(1, x, y);
  34.         }
  35.  
  36.         private ushort[] m_MainRegion;      // stored in pixels
  37.         public bool PlayerInBase(ushort x, ushort y)
  38.         {
  39.             return m_Collision(2, x, y);
  40.         }
  41.  
  42.         private bool m_Collision(byte type, ushort x, ushort y)
  43.         {
  44.             ushort[] region = new ushort[4];
  45.  
  46.             switch (type)
  47.             {
  48.                 case 0:
  49.                     region = m_AlphaBaseRegion;
  50.                     break;
  51.                 case 1:
  52.                     region = m_BravoBaseRegion;
  53.                     break;
  54.                 case 2:
  55.                     region = m_MainRegion;
  56.                     break;
  57.             }
  58.  
  59.             if (x > region[0] && x < region[2] && y > region[1] && y < region[3])
  60.                 return true;
  61.  
  62.             return false;
  63.         }
  64.  
  65.         private ushort[] m_BotSpecCoords;   // stored in tiles
  66.         public ushort BotSpecX
  67.         { get { return m_BotSpecCoords[0]; } }
  68.         public ushort BotSpecY
  69.         { get { return m_BotSpecCoords[1]; } }
  70.  
  71.         public Base2(string BaseName,ushort[] BaseCoords)
  72.         {
  73.             this.m_BaseName = BaseName;
  74.             this.m_BotSpecCoords = new ushort[] {
  75.             (ushort)Math.Floor((double)(BaseCoords[2] - BaseCoords[0])/2),
  76.             (ushort)Math.Floor((double)(BaseCoords[3] - BaseCoords[1])/2)
  77.             };
  78.             this.m_MainRegion = new ushort[] {
  79.                 (ushort)(BaseCoords[0] * 16),
  80.                 (ushort)(BaseCoords[1] * 16),
  81.                 (ushort)(BaseCoords[2] * 16),
  82.                 (ushort)(BaseCoords[3] * 16)
  83.             };
  84.             this.m_AlphaStart = new ushort[] {
  85.             (ushort)Math.Floor((double)(BaseCoords[6] - BaseCoords[4])/2),
  86.             (ushort)Math.Floor((double)(BaseCoords[7] - BaseCoords[5])/2)
  87.             };
  88.             this.m_AlphaBaseRegion = new ushort[] {
  89.                 (ushort)(BaseCoords[4] * 16),
  90.                 (ushort)(BaseCoords[5] * 16),
  91.                 (ushort)(BaseCoords[6] * 16),
  92.                 (ushort)(BaseCoords[7] * 16)
  93.             };
  94.             this.m_BravoStart = new ushort[] {
  95.             (ushort)Math.Floor((double)(BaseCoords[10] - BaseCoords[8])/2),
  96.             (ushort)Math.Floor((double)(BaseCoords[11] - BaseCoords[9])/2)
  97.             };
  98.             this.m_BravoBaseRegion = new ushort[] {
  99.                 (ushort)(BaseCoords[8] * 16),
  100.                 (ushort)(BaseCoords[9] * 16),
  101.                 (ushort)(BaseCoords[10] * 16),
  102.                 (ushort)(BaseCoords[11] * 16)
  103.             };
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement