Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: C#  |  size: 4.15 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2.  
  3. //Berechnet die Flugdauer, die Lagerkapzität sowie den Verbaucht
  4. namespace Frohgame
  5. {
  6.         public class MathFleet
  7.         {
  8.  
  9.                 public class ObjectOffset
  10.                 {
  11.                         public int Antrieb;
  12.                         public int Mutli;
  13.                         public int Speed1;
  14.                         public int Speed2;
  15.                         public int Verbrauch;
  16.                         public int Platz;
  17.                         public int Count;
  18.                 }
  19.                 /// <summary>
  20.                 /// Diese Daten müssen alle vorher Gesetzt werden!
  21.                 /// </summary>
  22.                 private SetDatas read = new SetDatas ();
  23.                 public class SetDatas
  24.                 {
  25.                        
  26.                         public int Verbrennungstriebwerk = 6;
  27.                         public int Impuls = 0;
  28.                         public int Hyper = 0;
  29.                         public bool isSpeedFactor = false;
  30.                         public int Speed = 100;
  31.                         //Galaxywerte
  32.                         public int StartGalaxy = 7;
  33.                         public int StartSystem = 22;
  34.                         public int StartPlanet = 12;
  35.                         public int TargetGalaxy = 8;
  36.                         public int TargetSystem = 22;
  37.                         public int TargetPlanet = 12;
  38.                         //Schiff Counter da wird bisschen Komplizierter als ich dachte
  39.                         public int LightFighterCount = 4;
  40.                 }
  41.  
  42.                 public class FleetData
  43.                 {
  44.                         Dictionary<int, ObjectOffset> Offsets = new Dictionary<int, ObjectOffset> ();
  45.                
  46.                         public FleetData ()
  47.                         {
  48.                                 //Todo weitere Daten hinzufügen
  49.                                 Offsets.Add (
  50.                                 (int)FROHGAME.Core.Military.LightFighter,
  51.                                 new ObjectOffset () {
  52.                                     Antrieb = 115,
  53.                                         Multi = 10,
  54.                                         Speed1 = 12500,
  55.                                         Speed2 = 0,
  56.                                         Verbrauch = 20,
  57.                                         Platz = 50,
  58.                                         Count = read.LightFighterCount,
  59.                                 }
  60.                         );     
  61.                                 return 0;
  62.                         }
  63.                 }
  64.                
  65.                 public int Distance (int StartGalaxy, int StartSystem,
  66.                                      int StartPlanet, int TargetGalaxy,
  67.                                      int TargetSystem, int TargetPlanet)
  68.                 {      
  69.                         int dist = 0;
  70.                         if ((TargetGalaxy - StartGalaxy) != 0) {
  71.                                 dist = Math.Abs (TargetGalaxy - StartGalaxy) * 20000;
  72.                         } else if ((TargetSystem - StartSystem) != 0) {
  73.                                 dist = Math.Abs (TargetSystem - StartSystem) * 5 * 19 + 2700;
  74.                         } else if ((TargetPlanet - StartPlanet) != 0) {
  75.                                 dist = Math.Abs (TargetPlanet - StartPlanet) * 5 + 1000;
  76.                         } else {
  77.                                 dist = 5;              
  78.                         }
  79.                         return dist;
  80.                        
  81.                 }
  82.                
  83.                 public int Duration ()
  84.                 {
  85.                         int SpeedFactor = 1;   
  86.                         if (read.isSpeedFactor) {
  87.                                 SpeedFactor = 2;
  88.                         }
  89.                         int msp = MaxSpeed ();
  90.                         int dis = Distance (); 
  91.                         int ret = Math.Round (((35000 / read.Speed * Math.sqrt (dist * 10 / msp) + 10) / speedfactor));
  92.                        
  93.                         return ret;
  94.                 }
  95.                
  96.                 public int Consumption ()
  97.                 {
  98.                         int Consumption = 0;
  99.                         int BasicConsumption = 0;
  100.                         int Values;
  101.                         int i; 
  102.                        
  103.                         int msp = MaxSpeed ();
  104.                         int sp = Speed;
  105.                         int dist = Distance ();
  106.                         int dur = Duration ();
  107.                        
  108.                         int SpeedFactor = 1;
  109.                         if (read.isSpeedFactor) {
  110.                                 SpeedFactor = 2;
  111.                         }
  112.                         ObjectOffset offset;
  113.                         for (ID = 202; ID <= 215; ID++) {
  114.                                 offset = Offsets [ID];
  115.                                 if (ID != 212) {
  116.                                         if (offset.Count > 0) {
  117.                                                 int shipspeed = GetSpeed (ID);
  118.                                                 spd = 35000 / (dur * SpeedFactor - 10) * Math.Sqrt (dist * 10 / shipspeed);
  119.                                                 BasicConsumption = offset.Verbrauch * offset.Count;
  120.                                                 Consumption += BasicConsumption * dist / 35000 * ((spd / 10) + 1) * ((spd / 10) + 1);
  121.                                         }      
  122.                                 }
  123.                         }
  124.                         Consumption = Math.Round (Consumption) + 1;
  125.                         return Consumption;
  126.                 }
  127.                        
  128.                 //int dis = Distance();
  129.                        
  130.                 //Hier muss die ID der Flotte angeben Like: FROHGAME.Core.Military.LightFighter
  131.                 public int GetSpeed (int element)
  132.                 {
  133.                         ObjectOffset offset = Offsets [element];
  134.                        
  135.                         int Antrieb = offset.Antrieb;
  136.                         int Multi = offset.Mutli;
  137.                         int Speed1 = offset.Speed1;
  138.                         int Speed2 = offset.Speed2;
  139.                        
  140.                         if ((element == 202) && (offset.Antrieb >= 4)) {
  141.                                 Multi = 20;
  142.                                 stufe = read.Verbrennungstriebwerk;
  143.                                 Speed1 = Speed2;
  144.                         }
  145.                         if ((element == 211) && (offset.Antrieb >= 7)) {
  146.                                 Mutli = 30;
  147.                                 stufe = read.Impuls;
  148.                                 Speed1 = Speed2;
  149.                                 Speed1 = Speed1 + Speed1 * stufe * mutli / 100;
  150.                                 return Speed1;
  151.                         }
  152.                 }
  153.                
  154.                 public int MaxSpeed ()
  155.                 {              
  156.                         ObjectOffset offset = Offsets;                 
  157.                         int msp = 1000000000;
  158.                         for (ID = 202; id <= 215; ID++) {
  159.                                 offset = Offsets [ID];
  160.                                 if (ID != 212) {  
  161.                                         if (offset.Count > 0) {
  162.                                                 speed = GetSpeed (ID);
  163.                                                 msp = Math.Min (msp, speed);
  164.                                         }
  165.                                 }
  166.                         }
  167.                         return msp;
  168.                 }
  169.  
  170.         }
  171. }