Ejemplo n.º 1
0
        public DeadPlayer(Position[] points, Player src)
        {
            Source = src;
            _points = points.ToList();
            Alive = true;
            Length = points.Length;
            MovementLength = Config.data.BASE_MOVEMENT_LENGTH;
            MakeInvulnerable(1000);

            r = new Random();

            if (r.Next(2) == 1)
                turningLeft = true;
            else turningLeft = false;
            Color = Config.data.DEAD_SNAKE_COLOR;
            RealPlayer = false;

            if (Length > 1)
            {
                var dY = (points[1].Y - points[0].Y);
                var dX = (points[1].X - points[0].X);

                if (dX != 0)
                {
                    Heading = (int)(Math.Atan(dY / dX) * 180 / Math.PI);
                    if (dX > 0) Heading += 180;
                }
                else if (dY > 0) Heading = 90;
                else Heading = 270;
            }
            else Heading = 0;
            startTurn();
            setMoveTimer();
        }
Ejemplo n.º 2
0
 public void Die(Player source)
 {
     if (Die())
     {
         if(RealPlayer)
             source.Score += 5;
         else
         {
             if (((DeadPlayer)this).Source != source)
             {
                 source.Score += 5;
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void s_Splitted(Player sender, DeadPlayer deadPart)
 {
     AddSnake(deadPart);
 }
Ejemplo n.º 4
0
 private void s_Fire(Player sender, Shot shot)
 {
     shot.Died += shot_Died;
     lock (_shots)
         _shots.Add(shot);
 }
Ejemplo n.º 5
0
        private void AddSnake(Player s)
        {
            if (string.IsNullOrEmpty(s.Color))
                s.Color = Settings.COLORS[r.Next(Settings.COLORS.Length)];

            s.Died += snake_Died;
            s.Fire += s_Fire;
            s.Splitted += s_Splitted;

            lock (_snakes)
                _snakes.Add(s);
            if (s.RealPlayer)
                OnlineCount++;
        }