Advertisement
Manu404

SimFishFish

Jul 8th, 2011
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Media;
  6.  
  7. namespace SimFishLib
  8. {
  9.     public delegate void MoveRandom();
  10.     public delegate void Move(int i);
  11.  
  12.     public class Fish
  13.     {
  14.         public int X { get; set; }
  15.         public int Y { get; set; }
  16.         public string GUID { get; set; }
  17.         public SolidColorBrush b { get; set; }
  18.  
  19.         Random rnd = new Random();
  20.  
  21.         public bool side = true;
  22.  
  23.         public Move MoveNearX;
  24.         public Move MoveNearY;
  25.  
  26.         public void MoveNearXPlus(int i)
  27.         {
  28.             int tmp = (rnd.Next(5, 10) + i);        
  29.             while (tmp > 400) tmp = (400 % tmp);
  30.             if(tmp < 0) tmp = (int)System.Math.Abs(tmp);
  31.             this.X = tmp;
  32.         }
  33.  
  34.         public void MoveNearYPlus(int i)
  35.         {
  36.             int tmp = (rnd.Next(5, 10) + i);
  37.             while (tmp > 400) tmp = (400 % tmp);
  38.             if (tmp < 0) tmp = (int)System.Math.Abs(tmp);
  39.             this.Y = tmp;
  40.         }
  41.  
  42.         public MoveRandom MoveX;
  43.         public MoveRandom MoveY;
  44.  
  45.         public void MoveXPlus()
  46.         {
  47.             this.X += rnd.Next(1, 10);
  48.         }
  49.  
  50.         public void MoveXMinus()
  51.         {
  52.             this.X -= rnd.Next(1, 10);
  53.         }
  54.  
  55.         public void MoveYPlus()
  56.         {
  57.             this.Y += rnd.Next(1, 10);
  58.         }
  59.  
  60.         public void MoveYMinus()
  61.         {
  62.             this.Y -= rnd.Next(1, 10);
  63.         }
  64.  
  65.         public Fish(int i)
  66.         {
  67.             X = i + 1;
  68.             Y = 100;
  69.             Random r = new Random();
  70.             Color c = new Color();
  71.             c.B = (byte)X;
  72.             c.R = (byte)Y;
  73.             c.G = (byte)r.Next(1, 255);
  74.             c.A = (byte)255;
  75.             b = new SolidColorBrush(c);
  76.             this.GUID = new Guid().ToString();
  77.  
  78.             MoveX = MoveXPlus;
  79.             MoveY = MoveYPlus;
  80.  
  81.             MoveNearX = MoveNearXPlus;
  82.             MoveNearY = MoveNearYPlus;
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement