Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members

LTc.cs

Go to the documentation of this file.
00001 /*
00002 SimImmuno version 1.0
00003 Copyright (C) 2005 sebeuh.ajsinfo.net
00004 
00005 SimImmuno est libre, vous pouvez le redistribuer et/ou le modifier
00006 selon les termes de la Licence Publique Générale GNU publiée par la
00007 Free Software Foundation (version 2).
00008 
00009 SimImmuno est distribué car potentiellement utile, mais SANS AUCUNE GARANTIE,
00010 ni explicite ni implicite, y compris les garanties de commercialisation
00011 ou d'adaptation dans un but spécifique. Reportez-vous à la
00012 Licence Publique Générale GNU pour plus de détails.
00013 
00014 Texte de la license officielle (anglais) :
00015 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL.txt
00016 Traduction francaise (non-officielle) :
00017 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL-fr.txt
00018 */
00019 using System;
00020 
00021 namespace SimImmuno
00022 {
00023         [Serializable]
00024         public class LTc : Cellule
00025         {
00026                 public LTc(int x, int y,int spe) : base(x,y)
00027                 {
00028                         Life = 2000;
00029                         specificite = spe;
00030                         cell_plusproche = null;
00031                 }
00032 
00033                 public LTc(int x, int y,int spe, int life) : base(x,y)
00034                 {
00035                         Life = life;
00036                         specificite = spe;
00037                         cell_plusproche = null;
00038                 }
00039 
00040                 new public void Action()
00041                 {
00042                         Mouvement();
00043                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00044                         int tmp=0;
00045                         foreach(Cellule cell in ccol_copy)
00046                         {
00047                                 double dst = DistTo(cell,this);
00048                                 if(dst < 200)
00049                                 {
00050                                         if(cell is CellInfect || cell is InfectVIH)
00051                                         {
00052                                                 if(cell.specificite == specificite && tmp == 0)
00053                                                 {
00054                                                         frmMain.log.NewEvent("Production de perforine du LTc n°" + this.index.ToString() + " de spé:" + this.specificite.ToString());
00055                                                         Perforine(cell);
00056                                                         tmp++;
00057                                                 }
00058                                         }
00059                                 }
00060                         }
00061                         return;
00062                 }
00063 
00064                 private void Perforine(Cellule cell_infect)
00065                 {
00066                         int x = cell_infect.Location.X;
00067                         int y = cell_infect.Location.Y;
00068                         if(cell_infect is CellInfect)
00069                                 frmMain.log.NewEvent("Lyse de la cell. infectée n°" + cell_infect.index.ToString() + " de spé:" + cell_infect.specificite.ToString());
00070                         else if(cell_infect is InfectVIH)
00071                                 frmMain.log.NewEvent("Lyse de la cell. infectée VIH n°" + cell_infect.index.ToString() + " de spé:" + cell_infect.specificite.ToString());
00072                         frmMain.ccol.RemoveAt(cell_infect.index);
00073                         Debris db1 = new Debris(x,y);
00074                         frmMain.ccol.Add(db1);
00075                 }
00076 
00077                 private void Mouvement()
00078                 {
00079                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00080                         if(cell_plusproche != null)
00081                         {
00082                                 if((TestIfAlive(cell_plusproche)))
00083                                 {
00084                                         if(cell_plusproche.Location.X < this.Location.X)
00085                                                 this.Location.X = this.Location.X - 5;
00086                                         else
00087                                                 this.Location.X = this.Location.X + 5;
00088                                         if(cell_plusproche.Location.Y < this.Location.Y)
00089                                                 this.Location.Y = this.Location.Y - 5;
00090                                         else
00091                                                 this.Location.Y = this.Location.Y + 5;
00092                                 }
00093                                 else
00094                                         cell_plusproche = null;
00095                         }
00096                         else
00097                         {
00098                                 foreach(Cellule cell in ccol_copy)
00099                                 {
00100                                         if(DistTo(this,cell) < 20000)
00101                                         {
00102                                                 if(cell is CellInfect || cell is InfectVIH)
00103                                                 {
00104                                                         if(cell.specificite == this.specificite)
00105                                                         {
00106                                                                 if(!(TestIfDejaSelect(cell)))
00107                                                                 {
00108                                                                         if(cell_plusproche == null)
00109                                                                                 cell_plusproche = cell;
00110                                                                         if(DistTo(this,cell_plusproche) > DistTo(this,cell))
00111                                                                                 cell_plusproche = cell;
00112                                                                 }
00113                                                         }
00114                                                 }
00115                                         }
00116                                 }
00117                                 int tmp2 = rnd.Next(2);
00118                                 int x,y;
00119                                 if(tmp2 == 0)
00120                                 {
00121                                         x = this.Location.X + rnd.Next(-5,5);
00122                                         y = this.Location.Y + rnd.Next(-5,5);
00123                                 }
00124                                 else
00125                                 {
00126                                         x = this.Location.X - rnd.Next(-5,5);
00127                                         y = this.Location.Y - rnd.Next(-5,5);
00128                                 }
00129                                 this.Location.X = x;
00130                                 this.Location.Y = y;
00131                         }
00132                 }
00133 
00134                 private bool TestIfAlive(Cellule cell)
00135                 {
00136                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00137                         bool tmp = false;
00138                         foreach(Cellule icell in ccol_copy)
00139                         {
00140                                 if(icell.index == cell.index && icell.specificite == cell.specificite  && tmp == false)
00141                                 {
00142                                         if(icell is CellInfect || cell is InfectVIH)
00143                                         {
00144                                                 double dst = DistTo(cell,icell);
00145                                                 if(dst < 200)
00146                                                         tmp = true;
00147                                         }
00148                                 }
00149                         }
00150                         return tmp;
00151                 }
00152 
00153                 private bool TestIfDejaSelect(Cellule cell)
00154                 {
00155                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00156                         bool tmp = false;
00157                         foreach(Cellule icell in ccol_copy)
00158                         {
00159                                 if(icell is LTc && tmp == false)
00160                                 {
00161                                         if(icell.cell_plusproche == cell)
00162                                                 tmp = true;
00163                                         else
00164                                                 tmp = false;
00165                                 }
00166                         }
00167                         return tmp;
00168                 }
00169         }
00170 }

Generated on Sat Jun 4 15:03:42 2005 for SimImmuno by  doxygen 1.4.2