Esempio n. 1
0
        public Enemy(Character p)
        {
            this.player = p;
            health = 500;
            speed = 0;
            ShootDelay = 10000;
            direction = Direction.Stop;

            normalColor = Color.Green;

            sprite.BackColor = normalColor;
            sprite.Size = new Size(40, 40);

            characterLabel = new Label();
            characterLabel.AutoSize = true;
            characterLabel.Name = "EnemyLabel";
            characterLabel.Text = this.health.ToString();
            characterLabel.Size = sprite.Size;
            characterLabel.ForeColor = normalColor;
            characterLabel.BackColor = Color.Transparent;

            Thread t = new Thread(DamageBlink);
            t.Name = "DamageBlink";
            IsDamaged = false;
            t.IsBackground = true;
            t.Start();

            Thread t2 = new Thread(AI_Thread);
            t2.Name = "AI_Thread";
            t2.IsBackground = true;
            t2.Start();
        }
Esempio n. 2
0
        public Laser(Character host, Point location, Direction direction)
            : base(host, "Laser", location)
        {
            speed = 7; //is too fast sometimes to get detected for the collision, but is intended feature
            damage = 200;
            lifetime = 20;
            sprite.BackColor = host.NormalColor;
            this.direction = direction;
                       switch (direction)
                        {
                            case Direction.Up:
                                sprite.Size = new Size(2, 30);
                                break;

                            case Direction.Down:
                                sprite.Size = new Size(2, 30);
                                break;

                           case Direction.Left:
                                sprite.Size = new Size(30, 2);
                                break;

                           case Direction.Right:
                                sprite.Size = new Size(30, 2);
                                break;
                        }
        }
 public Projectile(Character host, String name, Point location)
     : base()
 {
     this.host = host;
     this.name = name;
     Location = location;
 }
Esempio n. 4
0
 public Bullet(Character host, Point location)
     : base(host, "Bullet", location)
 {
     speed = 2;
     damage = 100;
     lifetime = 150;
     sprite.BackColor = host.NormalColor;
     sprite.Size = new Size(10, 10);
 }
Esempio n. 5
0
 /// <summary>
 /// Checks if the character (enemy or player) is colliding with any texture. If yes, it will put the character back to before it collided
 /// </summary>
 /// <param name="Character">Character instance (player or enemey)</param>
 public void UpdateCharacterCollision(Character Character)
 {
     int gridIndex = Grid.ColideWithBlock(Character.Position, Character.Size);
     //First checks if gridIndex is a posible arrayIndex, then checks if the block contains a texture
     //If it does then it means that there is a collision here(and not empty space)
     if (gridIndex != -1 && Grid.GridTexture[gridIndex] != -1)
     {
         //Collides with top
         Vector2 pos2, size2;
         pos2.X = Character.Position.X + Character.Size.X / 2;
         pos2.Y = Character.Position.Y;
         size2.X = 1;
         size2.Y = Character.Size.Y / 6;
         gridIndex = Grid.ColideWithBlock(pos2, size2);
         if (gridIndex != -1 && Grid.GridTexture[gridIndex] != -1)
         {
             Character.Acceleration.Y = -1f; //-1 instead of 0 so it wont be glued to the top if the system renders to fast
             Character.Position.Y = Grid.GetPositionFromIndex(gridIndex).Y + Grid.GridElementSize.Y;
         }
         //Collides with bottom
         pos2.X = Character.Position.X + (Character.Size.X / 2);
         pos2.Y = Character.Position.Y + Character.Size.Y - (Character.Size.Y / 6);
         size2.X = 1;
         size2.Y = Character.Size.Y / 6;
         gridIndex = Grid.ColideWithBlock(pos2, size2);
         if (gridIndex != -1 && Grid.GridTexture[gridIndex] != -1)
         {
             Character.Acceleration.Y = 0;
             Character.Position.Y = Grid.GetPositionFromIndex(gridIndex).Y - Character.Size.Y;
         }
         //Collides with Left
         pos2.X = Character.Position.X;
         pos2.Y = Character.Position.Y + 20;
         size2.X = 1;
         size2.Y = Character.Size.Y -40;
         gridIndex = Grid.ColideWithBlock(pos2, size2);
         if (gridIndex != -1 && Grid.GridTexture[gridIndex] != -1)
         {
             if (Character.Acceleration.X < 0) Character.Acceleration.X = 0;
             Character.Position.X = Grid.GetPositionFromIndex(gridIndex).X + Grid.GridElementSize.X + 0.5f;
         }
         //Collides with Right
         pos2.X = Character.Position.X + Character.Size.X;
         pos2.Y = Character.Position.Y + 20;
         size2.X = 1;
         size2.Y = Character.Size.Y - 40;
         gridIndex = Grid.ColideWithBlock(pos2, size2);
         if (gridIndex != -1 && Grid.GridTexture[gridIndex] != -1)
         {
             if (Character.Acceleration.X > 0) Character.Acceleration.X = 0;
             Character.Position.X = Grid.GetPositionFromIndex(gridIndex).X - Character.Size.X;
         }
     }
 }
Esempio n. 6
0
        public Missile(Character host, Point location, Character target)
            : base(host, "Missile", location)
        {
            speed = 2;
            damage = 10;
            lifetime = 10000; //in milliseconds
            changeDirectionDelay = 200; //in ms

            sprite.BackColor = host.NormalColor;
            sprite.Size = new Size(10, 10);
            this.target = target;

            Thread t = new Thread(Homing);
            t.Name = "MissileHoming";
            t.Start();
        }
 public CharacterCustomization(bool Shiro)
 {
     if (Shiro) character = Character.Shiro("Red");
     else character = Character.Kuro("Red");
 }
Esempio n. 8
0
 public bool IsEnemyTeam(Character Character)
 {
     return (this.Team != Character.Team || this.Team == -1 || Character.Team == -1) && Character != this;
 }
Esempio n. 9
0
 private void UpdateCharacterLabel(Character c, String s)
 {
     c.CharacterLabel.Text = s;
 }