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

Cellule.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 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 }

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