00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 using System;
00020
00021 namespace SimImmuno
00022 {
00023 [Serializable]
00024 public class Antigen : Cellule
00025 {
00026 public Antigen(int x, int y) : base(x,y)
00027 {
00028 Life = 10000;
00029 specificite = rnd.Next(4);
00030 }
00031
00032 public Antigen(int x, int y, int spe) : base(x,y)
00033 {
00034 Life = 10000;
00035 specificite = spe;
00036 }
00037
00038 public Antigen(int x, int y, int spe, int life) : base(x,y)
00039 {
00040 Life = life;
00041 specificite = spe;
00042 }
00043
00044 new public void Action()
00045 {
00046 Mouvement();
00047 ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00048 int tmp = 0;
00049 foreach(Cellule cell in ccol_copy)
00050 {
00051 double dst = DistTo(cell,this);
00052 if(dst < 200)
00053 {
00054 if(tmp == 0 && !(cell is Antigen) && !(cell is LB) && !(cell is CellInfect) && !(cell is Anticorp) && !(cell is CI) && !(cell is Debris) && !(cell is InfectVIH) && !(cell is LT4) && !(cell is LT4m) && !(cell is LT8) && !(cell is LT8m) && !(cell is LTc) && !(cell is Phagocyte) && !(cell is Plasmocyte) && !(cell is VIH))
00055 {
00056 Infection(cell);
00057 frmMain.log.NewEvent("Infection de la cellule n°" + cell.index.ToString() + " (spé:" + specificite.ToString() +")");
00058 tmp++;
00059 }
00060 }
00061 }
00062 return;
00063 }
00064
00065 private void Infection(Cellule cell)
00066 {
00067 int x = cell.Location.X;
00068 int y = cell.Location.Y;
00069 frmMain.ccol.RemoveAt(cell.index);
00070 CellInfect icell = new CellInfect(x,y,specificite);
00071 frmMain.ccol.Add(icell);
00072 }
00073
00074 private void Mouvement()
00075 {
00076 int tmp = rnd.Next(2);
00077 int x,y;
00078 if(tmp == 0)
00079 {
00080 x = this.Location.X + rnd.Next(-5,5);
00081 y = this.Location.Y + rnd.Next(-5,5);
00082 }
00083 else
00084 {
00085 x = this.Location.X - rnd.Next(-5,5);
00086 y = this.Location.Y - rnd.Next(-5,5);
00087 }
00088 this.Location.X = x;
00089 this.Location.Y = y;
00090 }
00091 }
00092 }