예제 #1
0
 public void Fight(Spartan s1, Spartan s2)
 {
     Random r = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
     int dmg1 = s1.power - s2.defence + s1.agility - s2.agility;
     int dmg2 = s2.power - s1.defence + s2.agility - s1.agility;
     if ((dmg1<=0)&&(dmg2 <=0))
     {
         dmg1 = r.Next(0, 3);
         dmg2 = r.Next(0, 3);
     }
     s2.health = dmg1 > 0 ? s2.health - dmg1 : s2.health;
     s1.health = dmg2 > 0 ? s1.health - dmg2 : s1.health;
     if (s1.health<=0)
     {
         s1.IAmOut(this);
         //s2.hunt = true;
         BigHunt(s1.Team);
         BigHunt(s2.Team);
     }
     if (s2.health <= 0)
     {
         s2.IAmOut(this);
         //s1.hunt = true;
         BigHunt(s1.Team);
         BigHunt(s2.Team);
     }
 }
예제 #2
0
 public void AddSpartan(Spartan s)
 {
     FieldArray[s.x, s.y, 0] = s.id;
     FieldArray[s.x, s.y, 1] = s.team;
     if (s.team == Spartan.TEAM_RED)
     {
         RedTeamList.Add(s);
     }
     else
     {
         BlueTeamList.Add(s);
     }
 }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            field.Init();
            Random r = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
            for (int i = 0; i < Field.MaxY; i++)
            {
                Spartan s = new Spartan(this, Spartan.TEAM_RED);
                s.team = Spartan.TEAM_RED;
                s.x = 0;
                s.y = i;
                s.vectorx = Field.MaxX - 1;
                s.vectory = i;
                s.health = r.Next(10, 20);
                s.power = r.Next(1, 10);
                s.agility = r.Next(1, 10);
                s.defence = r.Next(1, 10);

                s.EnemyTeam = field.BlueTeamList;
                s.Team = field.RedTeamList;
                field.AddSpartan(s);

            }
            for (int i = 0; i < Field.MaxY; i++)
            {
                Spartan s = new Spartan(this, Spartan.TEAM_BLUE);
                s.team = Spartan.TEAM_BLUE;
                s.x = Field.MaxX - 1;
                s.y = i;
                s.vectorx = 0;
                s.vectory = i;
                s.health = r.Next(10, 20);
                s.power = r.Next(1, 10);
                s.agility = r.Next(1, 10);
                s.defence = r.Next(1, 10);

                s.EnemyTeam = field.RedTeamList;
                s.Team = field.BlueTeamList;
                field.AddSpartan(s);
            }
            field.DrawSpartans(this);
        }
예제 #4
0
        public void GetTarget(Spartan s)
        {
            Spartan enemy;
            List<Spartan> alives = s.EnemyTeam.FindAll(i => i.IsAlive);

            if ((s.Enemy==null)||(!s.Enemy.IsAlive))
            {
                if (alives.Count > 0)
                {

                    enemy = alives[FieldGlobalRandom.Next(0, alives.Count - 1)];
                    s.Enemy = enemy;
                }
                else
                {
                    s.vectorx = s.x;
                    s.vectory = s.y;
                    return;
                }
            }
            else
            {
                enemy = s.Enemy;
            }
            s.vectorx = enemy.x;
            s.vectory = enemy.y;
        }