Beispiel #1
0
        private Thread FighterStartFight(FighterViewModel attacker, FighterViewModel deffender, int sleep = 0)
        {
            var t = new Thread(() => Fight(attacker, deffender, sleep));

            t.Start();
            return(t);
        }
Beispiel #2
0
 public BattleViewModel()
 {
     Fighter1           = new FighterViewModel();
     Fighter2           = new FighterViewModel();
     ButtonFightContent = "Fight";//
     ThreadIsStarted    = false;
 }
Beispiel #3
0
        private void Fight(FighterViewModel attacker, FighterViewModel deffender, int sleep)
        {
            Thread.Sleep(sleep);
            string attack_res = "";

            while (playersIsNotDead())
            {
                attack_res = attacker.getAttackRessult(deffender.Fighter);
                deffender.takeDamage(attack_res);
                attacker.rest();
            }
            ThreadIsStarted = false;
        }