Exemplo n.º 1
0
        public BattleFormPvP(PlayerFighter p1, PlayerFighter p2)
        {
            InitializeComponent();

            pf1 = p1;
            pf2 = p2;

            currbattle    = new Battle(p1, p2);
            atcat.Click  += action;
            dodge.Click  += action;
            block.Click  += action;
            atcat2.Click += action;
            dodge2.Click += action;
            block2.Click += action;
            namlvlai.Text = pf2.Name + "\nLevel " + pf2.Level;
            namelvl.Text  = pf1.Name + "\nLevel " + pf1.Level;

            pturn = currbattle.BattleStart();
            changeturn(pturn);
            string fm = "`s speed allows him to attack first!";

            if (pturn == 2)
            {
                fm = pf1.Name + fm;
            }
            else
            {
                fm = pf2.Name + fm;
            }
            battlelog.Text         = currbattle.Message;
            battlelog.Text        += DateTime.Now.ToString("HH:mm:ss") + ": " + fm + Environment.NewLine;
            battlelog.TextChanged += tb_scrldwn;
        }
Exemplo n.º 2
0
        public BattleForm(PlayerFighter c)
        {
            InitializeComponent();

            currplayer1 = c;
            aif         = new AIFighter(currplayer1.Level);

            currbattle = new Battle(currplayer1, aif);

            atcat.Click += action;
            dodge.Click += action;
            block.Click += action;



            namlvlai.Text = aif.Name + "\nLevel " + aif.Level;
            namelvl.Text  = currplayer1.Name + "\nLevel " + currplayer1.Level;

            pturn = currbattle.BattleStart();
            changeturn(pturn);
            string fm = "`s speed allows him to attack first!";

            if (pturn == 2)
            {
                fm = currplayer1.Name + fm;
            }
            else
            {
                fm = aif.Name + fm;
            }
            battlelog.Text         = currbattle.Message;
            battlelog.Text        += DateTime.Now.ToString("HH:mm:ss") + ": " + fm + Environment.NewLine;
            battlelog.TextChanged += tb_scrldwn;
        }
Exemplo n.º 3
0
        public int BattleEnd(PlayerFighter player)
        {
            message = DateTime.Now.ToString("HH:mm:ss") + "BattleEnded\n" + Environment.NewLine;
            bool win = true;

            if (fp.Durability <= 0)
            {
                win = false;
            }

            int win2 = 1;

            if (fp.Durability <= 0)
            {
                win2 = 2;
                if (sp.Durability <= 0)
                {
                    message = message + DateTime.Now.ToString("HH:mm:ss") + ": It`s a draw!" + Environment.NewLine;
                    win2    = 3;
                }
                else
                {
                    message = message + DateTime.Now.ToString("HH:mm:ss") + ": Winner is " + sp.Name + Environment.NewLine;
                }
            }
            else
            {
                message = message + DateTime.Now.ToString("HH:mm:ss") + ": Winner is " + fp.Name + Environment.NewLine;
            }

            int z = player.expgot(win, sp.Level, durp2 - sp.Durability, durp1 - fp.Durability);

            player.statist_change(win2);
            return(z);
        }
Exemplo n.º 4
0
        static public PlayerFighter load(string nam)//zagruzka
        {
            string path = Directory.GetCurrentDirectory() + @"\Save";
            DataContractJsonSerializer loader = new DataContractJsonSerializer(typeof(PlayerFighter));

            using (FileStream fs = new FileStream((path + @"\" + nam + ".json"), FileMode.Open))
            {
                PlayerFighter loaded = (PlayerFighter)loader.ReadObject(fs);
                return(loaded);
            }
        }
Exemplo n.º 5
0
 public Battle(PlayerFighter p, AIFighter a)
 {
     fp        = new PlayerFighter(p);
     sp        = a;
     speeddif  = 0;
     prevturn  = 0;
     durp1     = fp.Durability;
     durp2     = sp.Durability;
     battleend = false;
     message   = DateTime.Now.ToString("HH:mm:ss") + ": Battle starts: " + fp.Name + " vs " + sp.Name + Environment.NewLine;
 }
Exemplo n.º 6
0
 public PlayerFighter(PlayerFighter other)
 {
     this.expcur     = other.expcur;
     this.name       = other.name;
     this.level      = other.level;
     this.strenght   = other.strenght;
     this.speed      = other.speed;
     this.agility    = other.agility;
     this.durability = other.durability;
     this.luck       = other.luck;
     this.explvlup   = other.explvlup;
 }
Exemplo n.º 7
0
        private void Loading(object sender, EventArgs e)
        {
            Button b = sender as Button;

            PlayerFighter currentplayer = PlayerFighter.load(b.Name);
            GameMain      f1            = new GameMain();

            f1.Owner = this.Owner;
            f1.Show();
            f1.currplayer = currentplayer;
            this.Close();
        }
Exemplo n.º 8
0
        private void Select(object sender, EventArgs e)
        {
            Button b = sender as Button;

            if (b.Parent.Name == "panel1")
            {
                p1 = PlayerFighter.load(b.Name);
                selectp(panel1, p1);
            }
            else
            {
                p2 = PlayerFighter.load(b.Name);
                selectp(panel2, p2);
            }
        }
Exemplo n.º 9
0
        public void save(PlayerFighter pers)//sohranenie
        {
            string path = Directory.GetCurrentDirectory() + @"\Save";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            DataContractJsonSerializer saver = new DataContractJsonSerializer(typeof(PlayerFighter));

            using (FileStream fs = new FileStream((path + @"\" + pers.Name + ".json"), FileMode.Create))
            {
                saver.WriteObject(fs, pers);
            }
        }
Exemplo n.º 10
0
        private void selectp(Panel p, PlayerFighter cp)
        {
            p.Controls.Clear();
            Label namelvl = new Label();

            namelvl.AutoSize = true;
            namelvl.Font     = new Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            namelvl.Location = new Point(20, 10);
            namelvl.Text     = "Name: " + cp.Name + "     level " + cp.Level;
            p.Controls.Add(namelvl);
            Label str = new Label();

            str.AutoSize = true;
            str.Font     = new Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            str.Location = new Point(20, 60);
            str.Text     = "Strenght: " + cp.Str;
            p.Controls.Add(str);
            Label speed = new Label();

            speed.AutoSize = true;
            speed.Font     = new Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            speed.Location = new Point(20, 100);
            speed.Text     = "Speed: " + cp.Speed;
            p.Controls.Add(speed);
            Label agil = new Label();

            agil.AutoSize = true;
            agil.Font     = new Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            agil.Location = new Point(20, 140);
            agil.Text     = "Agility: " + cp.Agility;
            p.Controls.Add(agil);
            Label durab = new Label();

            durab.AutoSize = true;
            durab.Font     = new Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            durab.Location = new Point(20, 180);
            durab.Text     = "Durability: " + cp.Durability;
            p.Controls.Add(durab);
            Label luck = new Label();

            luck.AutoSize = true;
            luck.Font     = new Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            luck.Location = new Point(20, 220);
            luck.Text     = "Luck: " + cp.Luck;
            p.Controls.Add(luck);
        }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            PlayerFighter currentplayer = new PlayerFighter(textBox1.Text, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0);
            string        path          = Directory.GetCurrentDirectory() + @"\Save\" + textBox1.Text + ".json";

            if (!File.Exists(path))
            {
                currentplayer.save(currentplayer);
                GameMain f1 = new GameMain();
                f1.Owner = this.Owner;
                f1.Show();
                f1.currplayer = currentplayer;
                this.Close();
            }
            else
            {
                MessageBox.Show("This name is already taken. Choose a different one, or delete existing character throught Load menu");
            }
        }