Esempio n. 1
0
        /// <summary>
        /// Battle Constructor, created once a unit engages an enemy in battle
        /// </summary>
        /// <param name="m">The player's unit</param>
        /// <param name="e">The enemy's unit</param>
        /// <param name="fregion">The region where the battle was engaged</param>
        /// <param name="fgoal">The region's condition for victory</param>
        public Battle(Unit m, Unit e, Region fregion, Objective fgoal)
        {
            MainWindow.BackgroundImage = Content.Graphics.Instance.Images.background.bg_smallMenu;

            orgls = new List<String>();

            region = fregion;
            goal = fgoal;
            ally = m;
            enemy = e;
            tm=new Tilemap("battle");

            cmap = new CharMap(tm);
            cmap.ShowMisc = true;

            map = new Map(tm);
            map.ArrowEnabled = true;
            map.SelectionEnabled = false;
            map.changeCurp = changeCurp;
            map.curSelection = sel;
            map.focus(5, 6);
            MainWindow.add(map);

            lbl_actions = new Label("Actions");
            lbl_actions.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_actions.Position = new Vector2(280, 390);
            lbl_actions.Visible = false;
            MainWindow.add(lbl_actions);

            menu_actions = new Menu(5);
            menu_actions.Position = new Vector2(280, 390);
            menu_actions.Visible = false;
            MainWindow.add(menu_actions);
            menu_actions.Enabled = false;
            menu_actions.ArrowEnabled = false;

            lbl_moved = new Label("MOVED");
            lbl_moved.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.SPECIAL;
            lbl_moved.Position = new Vector2(520, 414);
            lbl_moved.Visible = false;
            MainWindow.add(lbl_moved);

            lbl_enemyTurn = new Label("DAMAGE");
            lbl_enemyTurn.Color = Color.Red;
            lbl_enemyTurn.Position = new Vector2(50, 50/*420*/);
            lbl_enemyTurn.Visible = false;
            MainWindow.add(lbl_enemyTurn);

            lbl_name = new Label("Name");
            lbl_name.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_name.Position = new Vector2(50, 390);
            MainWindow.add(lbl_name);

            lbl_charName = new Label("Derp");
            lbl_charName.Position = new Vector2(110, 390);
            MainWindow.add(lbl_charName);

            lbl_lvl = new Label("Level");
            lbl_lvl.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_lvl.Position = new Vector2(50, 420);
            MainWindow.add(lbl_lvl);

            lbl_charLvl = new Label("20");
            lbl_charLvl.Position = new Vector2(110, 420);
            MainWindow.add(lbl_charLvl);

            lbl_exp = new Label("Exp");
            lbl_exp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_exp.Position = new Vector2(150, 420);
            MainWindow.add(lbl_exp);

            lbl_charExp = new Label("42");
            lbl_charExp.Position = new Vector2(200, 420);
            MainWindow.add(lbl_charExp);

            lbl_hp = new Label("HP");
            lbl_hp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_hp.Position = new Vector2(50, 450);
            MainWindow.add(lbl_hp);

            lbl_curHp = new Label("100");
            lbl_curHp.Position = new Vector2(90, 450);
            MainWindow.add(lbl_curHp);

            lbl_hpSlash = new Label("/");
            lbl_hpSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_hpSlash.Position = new Vector2(140, 450);
            MainWindow.add(lbl_hpSlash);

            lbl_maxHp = new Label("100");
            lbl_maxHp.Position = new Vector2(160, 450);
            MainWindow.add(lbl_maxHp);

            lbl_mp = new Label("MP");
            lbl_mp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_mp.Position = new Vector2(50, 480);
            MainWindow.add(lbl_mp);

            lbl_curMp = new Label("50");
            lbl_curMp.Position = new Vector2(90, 480);
            MainWindow.add(lbl_curMp);

            lbl_mpSlash = new Label("/");
            lbl_mpSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_mpSlash.Position = new Vector2(140, 480);
            MainWindow.add(lbl_mpSlash);

            lbl_maxMp = new Label("50");
            lbl_maxMp.Position = new Vector2(160, 480);
            MainWindow.add(lbl_maxMp);

            lbl_moveLeft = new Label("Move Left");
            lbl_moveLeft.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_moveLeft.Position = new Vector2(50, 510);
            MainWindow.add(lbl_moveLeft);

            lbl_move = new Label("");
            lbl_move.Position = new Vector2(150, 510);
            MainWindow.add(lbl_move);

            lbl_enter = new Label("ENTER");
            lbl_enter.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_enter.Position = new Vector2(520, 462);
            MainWindow.add(lbl_enter);

            lbl_enterAction = new Label("Select Unit");
            lbl_enterAction.Position = new Vector2(600, 462);
            MainWindow.add(lbl_enterAction);

            lbl_v = new Label("V");
            lbl_v.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_v.Position = new Vector2(520, 438);
            MainWindow.add(lbl_v);

            lbl_vAction = new Label("View Character");
            lbl_vAction.Position = new Vector2(550, 438);
            MainWindow.add(lbl_vAction);

            lbl_esc = new Label("ESC");
            lbl_esc.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_esc.Position = new Vector2(520, 486);
            lbl_esc.Visible = false;
            MainWindow.add(lbl_esc);

            lbl_escAction = new Label("Cancel Movement");
            lbl_escAction.Position = new Vector2(570, 486);
            lbl_escAction.Visible = false;
            MainWindow.add(lbl_escAction);

            lbl_e = new Label("E");
            lbl_e.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_e.Position = new Vector2(520, 510);
            MainWindow.add(lbl_e);

            lbl_eAction = new Label("End Turn");
            lbl_eAction.Position = new Vector2(550, 510);
            MainWindow.add(lbl_eAction);

            lbl_turnCount = new Label("Turn: " + turnCount + " / 10");
            lbl_turnCount.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_turnCount.Position = new Vector2(520, 390);
            MainWindow.add(lbl_turnCount);

            lbl_dmg = new Label("");
            lbl_dmg.Color = Color.Red;
            lbl_dmg.Position = new Vector2(0, 0);
            lbl_dmg.Visible = false;
            MainWindow.add(lbl_dmg);

            lbl_actionTaken = new Label("");
            lbl_actionTaken.Color = Color.Black;
            lbl_actionTaken.Position = new Vector2(250, 30);
            lbl_actionTaken.Font = Content.Graphics.Instance.ActionFont;
            lbl_actionTaken.Visible = false;
            MainWindow.add(lbl_actionTaken);

            lbl_armyTurn = new Label("TO BATTLE, COMRADES!");
            lbl_armyTurn.Font = Content.Graphics.Instance.TurnFont;
            lbl_armyTurn.center(50);
            lbl_armyTurn.doneShowing = armyTurnDone;
            lbl_armyTurn.visibleTemp(2000);
            MainWindow.add(lbl_armyTurn);

            lbl_battleOutcome = new Label("VICTORY!");
            lbl_battleOutcome.Font = Content.Graphics.Instance.TurnFont;
            lbl_battleOutcome.center(50);
            lbl_battleOutcome.doneShowing = endOfBattle;
            lbl_battleOutcome.Visible = false;
            MainWindow.add(lbl_battleOutcome);

            deploy(m, true);
            deploy(e, false);

            cmap.update(map);

            freemode = true;
            actionMode = false;
            targetMode = false;
            spellMode = false;
            itemMode = false;

            changeCurp(null, new EventArgObject(new Point(5, 6)));
            scp = new Point(5, 6);
            endTurnP = new Point(5, 6);

            setAllNotMoved();

            ai = new AI();
            ai.set(map, tm, cmap);
            ai.done = ai_done;

            MainWindow.InputEnabled = false;
        }
        public EquipmentManage(Character fc, Unit u)
        {
            MainWindow.BackgroundImage = Content.Graphics.Instance.Images.background.bg_bigMenu;

            selEq = 0;
            c = fc;
            unit = u;

            uitemls = new List<Item>();

            lbl_name = new Label("Character Name");
            lbl_name.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_name.Position = new Vector2(50, 50);
            MainWindow.add(lbl_name);

            lbl_cname = new Label(c.Name);
            lbl_cname.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_cname.Position = new Vector2(250, 50);
            MainWindow.add(lbl_cname);

            lbl_title = new Label("Character Equipment");
            lbl_title.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.TITLE;
            lbl_title.Position = new Vector2(250, 100);
            MainWindow.add(lbl_title);

            lbl_eq = new Label("Equipment");
            lbl_eq.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_eq.Position = new Vector2(140, 130);
            MainWindow.add(lbl_eq);

            menu_eq = new Menu(3);
            menu_eq.Position = new Vector2(120, 140);
            MainWindow.add(menu_eq);

            lbl_weapon = new Label("Weapon");
            lbl_weapon.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_weapon.Position = new Vector2(10, 180);
            MainWindow.add(lbl_weapon);

            lbl_armor = new Label("Armor");
            lbl_armor.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_armor.Position = new Vector2(10, 200);
            MainWindow.add(lbl_armor);

            lbl_accesory = new Label("Accesory");
            lbl_accesory.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_accesory.Position = new Vector2(10, 220);
            MainWindow.add(lbl_accesory);

            lbl_uitem = new Label("Unit's Item");
            lbl_uitem.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_uitem.Position = new Vector2(450, 130);
            MainWindow.add(lbl_uitem);

            menu_uitem = new Menu(8);
            menu_uitem.Position = new Vector2(430, 140);
            MainWindow.add(menu_uitem);

            lbl_enter = new Label("ENTER");
            lbl_enter.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_enter.Position = new Vector2(50, 410);
            MainWindow.add(lbl_enter);

            lbl_enterGive = new Label("Equip Item");
            lbl_enterGive.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_enterGive.Position = new Vector2(120, 410);
            MainWindow.add(lbl_enterGive);

            lbl_v = new Label("V");
            lbl_v.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_v.Position = new Vector2(50, 440);
            MainWindow.add(lbl_v);

            lbl_vView = new Label("View Item");
            lbl_vView.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_vView.Position = new Vector2(80, 440);
            MainWindow.add(lbl_vView);

            lbl_u = new Label("U");
            lbl_u.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_u.Position = new Vector2(50, 470);
            MainWindow.add(lbl_u);

            lbl_uAction = new Label("Unequip Item");
            lbl_uAction.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_uAction.Position = new Vector2(80 , 470);
            MainWindow.add(lbl_uAction);

            lbl_esc = new Label("ESC");
            lbl_esc.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_esc.Position = new Vector2(50, 500);
            MainWindow.add(lbl_esc);

            lbl_escAction = new Label("Go Back");
            lbl_escAction.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_escAction.Position = new Vector2(100, 500);
            MainWindow.add(lbl_escAction);

            update_menuUItem();
            update_menuEq();

            inMenuEq = true;

            menu_uitem.TabStop = false;
            menu_uitem.unfocusLink();

            update_lblView();

            if (unit == null)
            {
                lbl_enter.Visible = false;
                lbl_enterGive.Visible = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Deploy unit on the battlefield and set up the Character Map
        /// </summary>
        /// <param name="u">The unit deployed</param>
        /// <param name="m">The unit's organization is "main" (player-controlled)</param>
        private void deploy(Unit u, bool m)
        {
            Point off;

            if (m)
                off = new Point(4, 5);
            else
                off = new Point(4, 0);

            for (int i = 0; i < 4; i++)
                for (int e = 0; e < 4; e++)
                    if (u.isChar(i, e))
                    {
                        if (m)
                            u.get(i, e).Organization = "main";

                        cmap.set(off.X + i, off.Y + e, u.get(i, e));
                    }
        }
Esempio n. 4
0
        private void prophet_sret(object o, EventArgs e)
        {
            Character c = new Caster("The Prophet");
            c.toLvl(17);

            Unit u = new Unit(c, "The Prophet");

            GameState.CurrentState.mainArmy.Units.Add(u);

            StateManager.Instance.goBack();
        }
Esempio n. 5
0
        /// <summary>
        /// Try to place a generated character at its best place according to class
        /// </summary>
        /// <param name="u">Unit to add the Character to</param>
        /// <param name="c">Character to add</param>
        private void placePref(Unit u, Character c)
        {
            int[,] prefPos;

            int[,] archer={{0,0}, {3,0}, {1,0}, {2,0}};
            int[,] caster = { { 1, 2 }, { 2, 2 }, { 0, 2 }, { 3, 2 } };
            int[,] fighter = { { 1, 3 }, { 2, 3 }, { 0, 3 }, { 3, 3 } };
            int[,] healer = { { 1, 1 }, { 2, 1 }, { 1, 2 }, { 2, 2 } };
            int[,] scout = { { 0, 1 }, { 3, 1 }};
            int[,] none={{0,0}};

            if (ctype == Character.Class_Type.ARCHER)
                prefPos=archer;
            else if (ctype == Character.Class_Type.CASTER)
                prefPos = caster;
            else if (ctype == Character.Class_Type.FIGHTER)
                prefPos = fighter;
            else if (ctype == Character.Class_Type.HEALER)
                prefPos = healer;
            else if (ctype == Character.Class_Type.SCOUT)
                prefPos = scout;
            else
                prefPos=none;

            place(u, c, prefPos);
        }
        public static Unit unit(XmlElement e)
        {
            Character c = null;
            Point lp = new Point();

            foreach (XmlElement te in e.ChildNodes)
                if (te.Name == "Pos" && te.GetAttribute("leader") == "True")
                {
                    c = xmlToChar(te["Character"]);
                    lp = new Point(int.Parse(te.GetAttribute("x")), int.Parse(te.GetAttribute("y")));
                }

            if (c == null)
                return null;

            Unit u = new Unit(c, lp.X, lp.Y);

            foreach (XmlElement te in e.ChildNodes)
                if (te.Name == "Pos" && te.GetAttribute("leader") == "False")
                {
                    c = xmlToChar(te["Character"]);
                    u.set(int.Parse(te.GetAttribute("x")), int.Parse(te.GetAttribute("y")), c);
                }

            u.Name = e.GetAttribute("name");
            u.Organization = e.GetAttribute("org");

            u.Inventory = inventory(e["Inventory"]);

            return u;
        }
Esempio n. 7
0
        /// <summary>
        /// Generates Main Army
        /// </summary>
        private void genArmy()
        {
            if (sel_class.SelectedValue == "Fighter")
                GameState.CurrentState.mainChar = new Fighter(txt_name.Text);
            else if (sel_class.SelectedValue == "Archer")
                GameState.CurrentState.mainChar = new Archer(txt_name.Text);
            else if (sel_class.SelectedValue == "Healer")
                GameState.CurrentState.mainChar = new Healer(txt_name.Text);
            else if (sel_class.SelectedValue == "Caster")
                GameState.CurrentState.mainChar = new Caster(txt_name.Text);
            else if (sel_class.SelectedValue == "Scout")
                GameState.CurrentState.mainChar = new Scout(txt_name.Text);
            else
                GameState.CurrentState.mainChar = new Fighter(txt_name.Text);

            GameState.CurrentState.mainChar.toLvl(5);

            Army a = new Army();

            Unit u = new Unit(GameState.CurrentState.mainChar);

            Fighter f1 = new Fighter("Patrick");
            f1.toLvl(3);

            Archer a1 = new Archer("Violaine");
            a1.toLvl(4);

            Character.Stats.Traits gat=new Character.Stats.Traits();
            gat.norm();
            gat.dex=10;

            Item ga=new Item("Art Bow", Item.Item_Type.WEAPON, 20, gat);
            a1.equipWeapon(ga);

            Caster cc = new Caster("Brendan");
            cc.levelUp();

            Healer h1 = new Healer("Sophie");

            Scout s1 = new Scout("Steven");

            u.set(3, 2, f1);
            u.set(3, 3, a1);
            u.set(0, 3, cc);
            u.set(1, 1, h1);
            a.Standby.Add(s1);

            a.Units.Add(u);

            a.setOrgAll("main");

            Item i = new Item("Heal Potion", Item.Item_Type.CONSUMABLE, 100, new Character.Stats.Traits(), new Item.OtherEffect(10, 0));

            a.Inventory.Items.Add(i);

            GameState.CurrentState.mainArmy = a;
        }
Esempio n. 8
0
        /// <summary>
        /// Tries to place a Character in the Unit in the first available spot
        /// </summary>
        /// <param name="u">Unit to place the Character in</param>
        /// <param name="c">Character to place</param>
        /// <returns>true if the unit was placed, false if there is no spot left</returns>
        private bool place(Unit u, Character c)
        {
            for (int i=0; i<4; i++)
                for (int e = 0; e < 4; e++)
                    if (u.get(i, e) == null)
                    {
                        u.set(i, e, c);
                        return true;
                    }

            return false;
        }
Esempio n. 9
0
        public Unit clone()
        {
            /*
             Character[,]  map;
             */

            Character l = leader.clone();
            Unit u = new Unit(l);

            u.name = name;
            u.org = org;
            u.deployed = deployed;
            u.movement = movement;
            u.spd = spd;
            u.dead = dead;
            u.us = us;

            u.map=new Character[4,4];
            Character c;

            for (int i = 0; i < map.GetLength(0); i++)
                for (int e = 0; e < map.GetLength(1); e++)
                    if (map[i,e] != null)
                    {
                        c=map[i,e].clone();
                        u.map[i,e]=c;

                        if (map[i, e] == leader)
                            u.leader = c;
                    }

            return u;
        }
Esempio n. 10
0
        public UnitInventory(Unit u)
        {
            MainWindow.BackgroundImage = Content.Graphics.Instance.Images.background.bg_bigMenu;

            inv = u.Inventory;

            lbl_money = new Label("Money");
            lbl_money.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_money.Position = new Vector2(50, 50);
            MainWindow.add(lbl_money);

            lbl_cmoney = new Label(GameState.CurrentState.mainArmy.Money.ToString());
            lbl_cmoney.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_cmoney.Position = new Vector2(150, 50);
            MainWindow.add(lbl_cmoney);

            lbl_title = new Label("Unit Inventory");
            lbl_title.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.TITLE;
            lbl_title.Position = new Vector2(250, 100);
            MainWindow.add(lbl_title);

            lbl_items = new Label("Items");
            lbl_items.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_items.Position = new Vector2(90, 130);
            MainWindow.add(lbl_items);

            menu_items = new Menu(8);
            menu_items.Position = new Vector2(70, 150);
            MainWindow.add(menu_items);

            lbl_r = new Label("R");
            lbl_r.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_r.Position = new Vector2(50, 440);
            MainWindow.add(lbl_r);

            lbl_rReturn = new Label("Return to army inventory");
            lbl_rReturn.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_rReturn.Position = new Vector2(80, 440);
            MainWindow.add(lbl_rReturn);

            lbl_v = new Label("V");
            lbl_v.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_v.Position = new Vector2(50, 470);
            MainWindow.add(lbl_v);

            lbl_vView = new Label("View Item");
            lbl_vView.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_vView.Position = new Vector2(80, 470);
            MainWindow.add(lbl_vView);

            lbl_esc = new Label("ESC");
            lbl_esc.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_esc.Position = new Vector2(50, 500);
            MainWindow.add(lbl_esc);

            lbl_escAction = new Label("Go Back");
            lbl_escAction.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_escAction.Position = new Vector2(100, 500);
            MainWindow.add(lbl_escAction);

            update_menuItems();
        }
Esempio n. 11
0
                /// <summary>
                /// Generates a TileMap with the given UnitMap and Unit (and Tilemap and Organization)
                /// </summary>
                /// <param name="umap">The UnitMap to use</param>
                /// <param name="unit">The Unit to be based on</param>
                /// <param name="tm">Tilemap (not the pathfind one)</param>
                /// <param name="org">Organization to base the map from (determins who is ally and who is enemy)</param>
                /// <returns>a PathFind.TileMap</returns>
                public static TileMap gen(UnitMap umap, Tilemap tm, Unit unit)
                {
                    TileMap ptm = new TileMap(tm.NumX, tm.NumY);

                    for(int i=0; i<tm.NumX; i++)
                        for(int e=0; e<tm.NumY; e++)
                            if(!unit.canMove(tm.get(i, e).Type))
                                ptm.set(i, e, Tile_Type.BLOCK_TERRAIN);
                            else if(!umap.canMove(i, e, unit.Organization))
                                ptm.set(i, e, Tile_Type.BLOCK_UNIT);
                            else
                                ptm.set(i, e, Tile_Type.NOTHING);

                    return ptm;
                }
Esempio n. 12
0
        public CharManage(Character selectedChar, Unit u)
        {
            MainWindow.BackgroundImage = Content.Graphics.Instance.Images.background.bg_bigMenu;

            c = selectedChar;
            unit = u;

            lbl_charMng = new Label("Character Management");
            lbl_charMng.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.TITLE;
            lbl_charMng.Position = new Vector2(50, 30);

            charPic = new PictureBox();
            charPic.Image = Graphic.getSprite(c);
            charPic.Size = new Vector2(384, 384);
            charPic.Position = new Vector2(0, 30);

            MainWindow.add(lbl_charMng);
            MainWindow.add(charPic);

            lbl_name = new Label(c.Name);
            lbl_name.Position = new Vector2(340, 80);
            MainWindow.add(lbl_name);

            lbl_class = new Label(c.Type.ToString());
            lbl_class.Position = new Vector2(340, 110);
            MainWindow.add(lbl_class);

            lbl_level = new Label("Level:");
            lbl_level.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_level.Position = new Vector2(340, 140);
            MainWindow.add(lbl_level);

            lbl_clevel = new Label(c.Lvl.ToString());
            lbl_clevel.Position = new Vector2(400, 140);
            MainWindow.add(lbl_clevel);

            lbl_exp = new Label("Exp:");
            lbl_exp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_exp.Position = new Vector2(460, 140);
            MainWindow.add(lbl_exp);

            lbl_cexp = new Label(c.Exp.ToString());
            lbl_cexp.Position = new Vector2(505, 140);
            MainWindow.add(lbl_cexp);

            lbl_hp = new Label("HP:");
            lbl_hp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_hp.Position = new Vector2(340, 170);
            MainWindow.add(lbl_hp);

            lbl_currHp = new Label(c.stats.hp.ToString());
            lbl_currHp.Position = new Vector2(460, 170);
            MainWindow.add(lbl_currHp);

            lbl_hpSlash = new Label("/");
            lbl_hpSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_hpSlash.Position = new Vector2(500, 170);
            MainWindow.add(lbl_hpSlash);

            lbl_maxHp = new Label(c.stats.maxHp.ToString());
            lbl_maxHp.Position = new Vector2(515, 170);
            MainWindow.add(lbl_maxHp);

            lbl_mana = new Label("Mana:");
            lbl_mana.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_mana.Position = new Vector2(340, 200);
            MainWindow.add(lbl_mana);

            lbl_currMana = new Label(c.stats.mana.ToString());
            lbl_currMana.Position = new Vector2(460, 200);
            MainWindow.add(lbl_currMana);

            lbl_manaSlash = new Label("/");
            lbl_manaSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_manaSlash.Position = new Vector2(500, 200);
            MainWindow.add(lbl_manaSlash);

            lbl_maxMana = new Label(c.stats.maxMana.ToString());
            lbl_maxMana.Position = new Vector2(515, 200);
            MainWindow.add(lbl_maxMana);

            lbl_state = new Label("State:");
            lbl_state.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_state.Position = new Vector2(340, 230);
            MainWindow.add(lbl_state);

            lbl_cstate = new Label(c.stats.state.ToString());
            lbl_cstate.Position = new Vector2(460, 230);
            MainWindow.add(lbl_cstate);

            lbl_force = new Label("Strength:");
            lbl_force.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_force.Position = new Vector2(340, 260);
            MainWindow.add(lbl_force);

            lbl_cforce = new Label(c.stats.traits.str.ToString());
            lbl_cforce.Position = new Vector2(460, 260);
            MainWindow.add(lbl_cforce);

            lbl_dex = new Label("Dexterity:");
            lbl_dex.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_dex.Position = new Vector2(340, 290);
            MainWindow.add(lbl_dex);

            lbl_cdex = new Label(c.stats.traits.dex.ToString());
            lbl_cdex.Position = new Vector2(460, 290);
            MainWindow.add(lbl_cdex);

            lbl_intel = new Label("Intelligence:");
            lbl_intel.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_intel.Position = new Vector2(340, 320);
            MainWindow.add(lbl_intel);

            lbl_cintel = new Label(c.stats.traits.intel.ToString());
            lbl_cintel.Position = new Vector2(460, 320);
            MainWindow.add(lbl_cintel);

            lbl_sag = new Label("Wisdom:");
            lbl_sag.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_sag.Position = new Vector2(550, 260);
            MainWindow.add(lbl_sag);

            lbl_csag = new Label(c.stats.traits.wis.ToString());
            lbl_csag.Position = new Vector2(670, 260);
            MainWindow.add(lbl_csag);

            lbl_spd = new Label("Speed:");
            lbl_spd.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_spd.Position = new Vector2(550, 290);
            MainWindow.add(lbl_spd);

            lbl_cspd = new Label(c.stats.traits.spd.ToString());
            lbl_cspd.Position = new Vector2(670, 290);
            MainWindow.add(lbl_cspd);

            lbl_con = new Label("Constitution:");
            lbl_con.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_con.Position = new Vector2(550, 320);
            MainWindow.add(lbl_con);

            lbl_ccon = new Label(c.stats.traits.con.ToString());
            lbl_ccon.Position = new Vector2(670, 320);
            MainWindow.add(lbl_ccon);

            lbl_move = new Label("Movement:");
            lbl_move.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_move.Position = new Vector2(550, 350);
            MainWindow.add(lbl_move);

            lbl_cmove = new Label(c.stats.movement.ToString());
            lbl_cmove.Position = new Vector2(670, 350);
            MainWindow.add(lbl_cmove);

            lbl_org = new Label("Organization:");
            lbl_org.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD;
            lbl_org.Position = new Vector2(340, 350);
            MainWindow.add(lbl_org);

            lbl_corg = new Label(c.Organization);
            lbl_corg.Position = new Vector2(460, 350);
            MainWindow.add(lbl_corg);

            lbl_esc = new Label("ESC");
            lbl_esc.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            lbl_esc.Position = new Vector2(50, 440);
            MainWindow.add(lbl_esc);

            lbl_escAction = new Label("Go Back");
            lbl_escAction.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            lbl_escAction.Position = new Vector2(100, 440);
            MainWindow.add(lbl_escAction);

            lbl_e = new Label("E");
            lbl_e.Position = new Vector2(50, 470);
            lbl_e.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL;
            if (selectedChar.Organization == "enemy")
                lbl_e.Visible = false;
            else
                lbl_e.Visible = true;
            MainWindow.add(lbl_e);

            lbl_eAction = new Label("Equipment");
            lbl_eAction.Position = new Vector2(80, 470);
            lbl_eAction.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.NORM;
            if (selectedChar.Organization == "enemy")
                lbl_eAction.Visible = false;
            else
                lbl_eAction.Visible = true;
            MainWindow.add(lbl_eAction);
        }
Esempio n. 13
0
        public static XmlElement unit(XmlDocument doc, Unit u)
        {
            XmlElement e = doc.CreateElement("Unit");
            XmlElement te;

            e.SetAttribute("name", u.Name);
            e.SetAttribute("org", u.Organization);

            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    if (!u.isChar(i, j))
                        continue;

                    te = doc.CreateElement("Pos");
                    te.SetAttribute("x", i.ToString());
                    te.SetAttribute("y", j.ToString());
                    te.SetAttribute("leader", u.isLeader(i, j).ToString());
                    te.AppendChild(charToXml(doc, u.get(i, j)));
                    e.AppendChild(te);
                }

            e.AppendChild(inventory(doc, u.Inventory));

            return e;
        }
Esempio n. 14
0
 public void setDefeatUnit(Unit fu)
 {
     type = Objective_Type.DEFEAT_UNIT;
     u = fu;
 }
Esempio n. 15
0
        public void move(int sx, int sy, int dx, int dy, Unit u)
        {
            if (!umap[sx, sy].Contains(u))
                return;

            umap[dx, dy].Add(u);
            umap[sx, sy].Remove(u);
        }
Esempio n. 16
0
        /// <summary>
        /// Tries to place a Character in the Unit in the preferred spot in order provided. Otherwise it
        /// places the Character in the first available spot.
        /// </summary>
        /// <param name="u">Unit to place the Character in</param>
        /// <param name="prefPos">Prefered positions in order</param>
        /// <param name="c">Character to place</param>
        /// <returns>true if the unit was placed, false if there is no spot left</returns>
        private bool place(Unit u, Character c, int[,] prefPos)
        {
            for(int i=0; i<prefPos.GetLength(0); i++)
                if(place(u, c, prefPos[i,0], prefPos[i,1]))
                    return true;

            return place(u, c);
        }
Esempio n. 17
0
 public void rem(int x, int y, Unit u)
 {
     umap[x, y].Remove(u);
 }
Esempio n. 18
0
        /// <summary>
        /// Tries to place a Character at the given place in a unit
        /// </summary>
        /// <param name="u">Unit to place the Character in</param>
        /// <param name="c">Character to place</param>
        /// <param name="x">Position in x</param>
        /// <param name="y">Position in y</param>
        /// <returns>true if the unit was placed, false if there was already someon in the spot</returns>
        private bool place(Unit u, Character c, int x, int y)
        {
            if (u.get(x, y) != null)
                return false;

            u.set(x, y, c);

            return true;
        }
Esempio n. 19
0
 public void add(int x, int y, Unit u)
 {
     umap[x, y].Add(u);
 }
Esempio n. 20
0
        public Unit gen()
        {
            Character leader=Character.genClass(ctype, name);
            leader.Organization = org;

            if (num == 1 || num == 0)
                leader.toLvl(lvl);
            else if(num==2)
                leader.toLvl(lvl + 1);
            else
                leader.toLvl(lvl + 2);

            Unit unit=new Unit(leader);
            unit.Organization = org;

            unit.set(0, 0, null);
            placePref(unit, leader);

            if (num == 2)
            {
                Character c = Character.genClass(ctype, Character.genName(ctype));
                c.Organization = org;
                c.toLvl(lvl);
                placePref(unit, c);
            }
            else
            {
                int mc = (int)Math.Ceiling(num*0.60)-1;
                int ld = -1;
                Character c;
                Character.Class_Type curtype;

                Array ctype_val = Enum.GetValues(typeof(Character.Class_Type));
                Random rand = new Random();

                for (int i = 0; i < num; i++)
                {
                    if (i < mc)
                        curtype = ctype;
                    else
                        curtype = (Character.Class_Type)ctype_val.GetValue(rand.Next(ctype_val.Length));

                    c = Character.genClass(curtype, Character.genName(curtype));
                    c.Organization = org;
                    c.toLvl(lvl+ld);

                    placePref(unit, c);

                    if (ld == 1)
                        ld = -1;
                    else
                        ld++;
                }
            }

            return unit;
        }
Esempio n. 21
0
        public static Boolean battle(CharMap cmap, Tilemap tm, String org, Map map, Unit ally, Unit enemy, Label dmg, Label action, ref Boolean gameOver, ref Boolean defeat, GameTime gameTime)
        {
            Character c = cmap.get(map.CursorPosition.X, map.CursorPosition.Y);
            Character m;
            Point p;
            Point ne;

            if (c != null && c.Organization == org && c.stats.movement != 0)
            {
                if(c is Healer)
                    ne = nearest(cmap, map.CursorPosition, "ennemy");
                else
                    ne = nearest(cmap, map.CursorPosition, "main");

                if (isAdj(map.CursorPosition, ne))
                {
                    c.stats.movement = 0;
                    p = map.CursorPosition;
                }
                else
                {
                    //finds path to nearest ennemy
                    p = pathFind(cmap, tm, map.CursorPosition, nearest(cmap, map.CursorPosition, "main"), org);
                    if (c.stats.movement > 0)
                    {
                            cmap.move(map.CursorPosition.X, map.CursorPosition.Y, p.X, p.Y);
                            map.changeCursor(new Point(p.X, p.Y));
                    }
                    c.stats.movement--;
                }

                if (c.stats.movement == 0)
                {
                    Point tar = targetCharacter(c, p, cmap);

                    if (tar != new Point(-1, -1))
                    {
                        m = cmap.get(tar.X, tar.Y);
                        map.CurLs.Add(tar, Content.Graphics.Instance.Images.gui.cursorRed);

                        if (c is Fighter)
                            dmg.Text = ((Fighter)c).attack(m);
                        else if (c is Archer)
                            dmg.Text = ((Archer)c).attack(m);
                        else if (c is Scout)
                            dmg.Text = ((Scout)c).attack(m);
                        else if (c is Healer)
                        {
                            dmg.Text = ((Healer)c).heal(m).ToString();
                            action.Text = "Heal";
                        }
                        else if (c is Caster)
                        {
                            dmg.Text = ((Caster)c).attack(m, new Spell("DerpCast", 1, 5, 1, 5));
                            action.Text = "DerpCast";
                        }
                        else
                            dmg.Text = "Cant";

                        if (action.Text == "")
                            action.Text = "Attack";

                        dmg.Position = new Vector2(tar.X * 64 - map.getTlc.X * 64, tar.Y * 64 - map.getTlc.Y * 64 + 20);
                        dmg.visibleTemp(500);
                        action.visibleTemp(500);

                        if (dmg.Text != "miss" || dmg.Text != "Cant")
                        {
                            enemy.set(c.Position.X, c.Position.Y, c);
                            ally.set(m.Position.X, m.Position.Y, m);
                            if (m.stats.hp <= 0)
                            {
                                if (m.isMainChar())
                                    gameOver = true;

                                ally.delete(m.Position.X, m.Position.Y);
                                cmap.set(tar.X, tar.Y, null);
                                cmap.update(map);

                                if (ally.Characters.Count <= 0)
                                    defeat = true;
                            }
                        }
                    }
                }
                return false;
            }
            else
            {
                for (int e = cmap.NumY - 1; e >= 0; e--)
                    for (int i = cmap.NumX - 1; i >= 0; i--)
                        if (cmap.isChar(i, e) && cmap.get(i, e).stats.movement != 0 && cmap.get(i, e).Organization == org)
                        {
                            if (map.CursorPosition != new Point(i, e))
                            {
                                map.CurLs.Clear();
                                dmg.Visible = false;
                                action.Visible = false;
                                action.Text = "";
                                map.changeCursor(new Point(i, e));
                                return false;
                            }
                        }
            }

            cmap.resetAllMovement(org);
            return true;
        }