00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 using System;
00020 using System.Drawing;
00021 using System.Collections;
00022
00023 namespace SimImmuno
00024 {
00025 [Serializable]
00026 public class Cellule
00027 {
00028 public const int MaxLifeTime = 1000;
00029 public Point Location;
00030 public int Life;
00031 public int specificite;
00032 public static Random rnd;
00033 public int index;
00034 public CellulesCollection ccol_copy;
00035 public Cellule cell_plusproche;
00036
00037 public Cellule(int x, int y)
00038 {
00039 Location = new Point(x,y);
00040 Life = rnd.Next(MaxLifeTime);
00041 }
00042
00043 public Cellule(int x, int y, int life)
00044 {
00045 Location = new Point(x,y);
00046 Life = life;
00047 }
00048
00049 public void Action()
00050 {
00051 if(this is Antigen)
00052 {
00053 ((Antigen)this).Action();
00054 return;
00055 }
00056 else if(this is LB)
00057 {
00058 ((LB)this).Action();
00059 return;
00060 }
00061 else if(this is LBm)
00062 {
00063 ((LBm)this).Action();
00064 return;
00065 }
00066 else if(this is CellInfect)
00067 {
00068 ((CellInfect)this).Action();
00069 return;
00070 }
00071 else if(this is Plasmocyte)
00072 {
00073 ((Plasmocyte)this).Action();
00074 return;
00075 }
00076 else if(this is Anticorp)
00077 {
00078 ((Anticorp)this).Action();
00079 return;
00080 }
00081 else if(this is CI)
00082 {
00083 ((CI)this).Action();
00084 return;
00085 }
00086 else if(this is Phagocyte)
00087 {
00088 ((Phagocyte)this).Action();
00089 return;
00090 }
00091 else if(this is LT4)
00092 {
00093 ((LT4)this).Action();
00094 return;
00095 }
00096 else if(this is LT4m)
00097 {
00098 ((LT4m)this).Action();
00099 return;
00100 }
00101 else if(this is LT8m)
00102 {
00103 ((LT8m)this).Action();
00104 return;
00105 }
00106 else if(this is LT8)
00107 {
00108 ((LT8)this).Action();
00109 return;
00110 }
00111 else if(this is LTc)
00112 {
00113 ((LTc)this).Action();
00114 return;
00115 }
00116 else if(this is Debris)
00117 {
00118 ((Debris)this).Action();
00119 return;
00120 }
00121 else if(this is VIH)
00122 {
00123 ((VIH)this).Action();
00124 return;
00125 }
00126 else if(this is InfectVIH)
00127 {
00128 ((InfectVIH)this).Action();
00129 return;
00130 }
00131 else
00132 {
00133 if(rnd.Next(400)==1)
00134 {
00135 Divide();
00136 }
00137 Mouvement();
00138 return;
00139 }
00140
00141 }
00142
00143 private void Divide()
00144 {
00145 if(frmMain.ccol.Count < 1000)
00146 {
00147 int x = rnd.Next(-5,5);
00148 int y = rnd.Next(-5,5);
00149 Cellule cell = new Cellule(Location.X+x,Location.Y+y);
00150 frmMain.ccol.Add(cell);
00151 }
00152 }
00153
00154 public double DistTo(Cellule cell_source,Cellule cell_dest)
00155 {
00156 int x = cell_source.Location.X-cell_dest.Location.X;
00157 int y = cell_source.Location.Y-cell_dest.Location.Y;
00158 return Math.Pow((double)x,2)+Math.Pow((double)y,2);
00159 }
00160
00161 private void Mouvement()
00162 {
00163 int tmp = rnd.Next(2);
00164 int x,y;
00165 if(tmp == 0)
00166 {
00167 x = this.Location.X + rnd.Next(-5,5);
00168 y = this.Location.Y + rnd.Next(-5,5);
00169 }
00170 else
00171 {
00172 x = this.Location.X - rnd.Next(-5,5);
00173 y = this.Location.Y - rnd.Next(-5,5);
00174 }
00175 this.Location.X = x;
00176 this.Location.Y = y;
00177 }
00178 }
00179 }