Example #1
0
        public void attemptDamageUnit(UnitController u)
        {
            if (u == m_sourceUnit)
                return;

            if (m_hitUnits.Contains(u) || !u.m_unit.m_alive)
                return;

            // Need a get radius method for unit controllers to make sure this actually works.
            float x = u.m_unit.x_pos - m_sourceUnit.m_unit.x_pos;
            float y = u.m_unit.y_pos - m_sourceUnit.m_unit.y_pos;
            float rad = 32 + m_arcLength;

            // Intersectionnn!
               // Debug.WriteLine((x * x) + (y * y) + " " + rad);
            if ((x * x) + (y * y) < (rad*rad))
            {
                float nx = m_sourceUnit.m_unit.x_pos + (float)Math.Cos(m_arcTurn * m_count + m_arcStart) * (m_arcLength+16);
                float ny = m_sourceUnit.m_unit.y_pos + (float)Math.Sin(m_arcTurn * m_count + m_arcStart) * (m_arcLength+16);

                float n2x = m_sourceUnit.m_unit.x_pos + (float)Math.Cos(m_arcTurn * m_count + m_arcStart) * (m_arcLength/2 + 16);
                float n2y = m_sourceUnit.m_unit.y_pos + (float)Math.Sin(m_arcTurn * m_count + m_arcStart) * (m_arcLength/2 + 16);

                if( (Math.Abs(nx - u.m_unit.x_pos) <= 16 && Math.Abs(ny - u.m_unit.y_pos) <= 16) || (Math.Abs(n2x - u.m_unit.x_pos) <= 16 && Math.Abs(n2y - u.m_unit.y_pos) <= 16) )
                {
                    m_hitUnits.Add(u);
                    u.calculateDamageEffects(m_sourceUnit);
                }
            }
        }
Example #2
0
        public DamageArc(UnitController s, float arcLen, float arcS, float arcE, float ts)
        {
            m_sourceUnit = s;
            m_hitUnits = new List<UnitController>();
            m_arcLength = arcLen;
            m_arcStart = arcS + s.m_unit.facing;
            m_arcTurn = (arcE - arcS) / ((float)m_arcCount-1);
            m_turnSpeed = ts;

            m_time = 0;
            m_count = -1;
        }
        public BattleGroup(UnitController uc, int faction)
        {
            m_display = false;

            m_leader = uc;
            m_factionNumber = faction;

            m_units = new List<UnitController>();
            m_units.Add(uc);
            m_timeDisplayed = 0.0f;

            uc.m_battleGroup = this;
        }
Example #4
0
        public bool TESTFAKEAI(UnitController uc, float percentSecond, Random ran)
        {
            List <String> blank  = new List <string>();
            List <String> attack = new List <string>();

            attack.Add("UNIT-COMMAND-START-ATTACK");
            List <String> forward = new List <String>();

            forward.Add("UNIT-MOVE-FORWARD");

            if (uc.m_unit.m_important != true)
            {
                int x = ran.Next(300);
                if (x == 1)
                {
                    uc.handleCommand(attack, percentSecond);
                    return(true);
                }
                else if (x % 2 == 0)
                {
                    if (x % 4 == 0)
                    {
                        forward.Add("UNIT-TURN-RIGHT");
                    }
                    else if (x % 4 == 2)
                    {
                        forward.Add("UNIT-TURN-LEFT");
                    }
                    uc.handleCommand(forward, percentSecond);
                }
                else
                {
                    uc.handleCommand(blank, percentSecond);
                }
            }
            return(false);
        }
Example #5
0
 public void addUnit(UnitController u)
 {
     unitList.Add(u);
     if (u.m_unit.m_important)
     {
         m_camera.addPossibleFocus(u.m_unit);
     }
 }
Example #6
0
        public bool TESTFAKEAI(UnitController uc, float percentSecond, Random ran)
        {
            List<String> blank = new List<string>();
            List<String> attack = new List<string>();
            attack.Add("UNIT-COMMAND-START-ATTACK");
            List<String> forward = new List<String>();
            forward.Add("UNIT-MOVE-FORWARD");

            if (uc.m_unit.m_important != true)
            {
                int x = ran.Next(300);
                if (x == 1)
                {
                    uc.handleCommand(attack, percentSecond);
                    return true;
                }
                else if (x % 2 == 0)
                {
                    if (x % 4 == 0)
                        forward.Add("UNIT-TURN-RIGHT");
                    else if (x % 4 == 2)
                        forward.Add("UNIT-TURN-LEFT");
                    uc.handleCommand(forward, percentSecond);
                }
                else
                {
                    uc.handleCommand(blank, percentSecond);
                }
            }
            return false;
        }
        public void trySetTarget(UnitController uc)
        {
            if (m_target == null || m_target.m_unit.m_stats["HP"] <= 0)
            {
                m_target = uc;
            }

            else
            {
                if (m_target.m_unit.m_stats["LEVEL"] < uc.m_unit.m_stats["LEVEL"])
                {
                    m_target = uc;
                }
            }
        }
 public void tryRemoveTarget(UnitController uc)
 {
     if (uc == m_target)
         m_target = null;
 }
        public void calculateDamageEffects(UnitController uc)
        {
            Animation a = Animation.getAnimation("UNIT-CHARGE-EXPLODE");
            a.m_color = Color.DarkRed;
            a.setSlide(0);
            m_unit.m_animations.Add(a);

            float power = ((float)uc.m_unit.m_stats["POWER"] / (float)m_unit.m_stats["ENDURE"]);
            power = (float) Math.Pow((double)power, (double)DAMAGECONSTANT);
            power *= uc.m_unit.m_weapon.m_swingData[uc.m_swingCount]["BASE-DAMAGE"];

            m_unit.m_stats["HP"] -= (int)Math.Ceiling(power);
            m_unit.m_stats["CHP"] -= (int)Math.Ceiling(power/4);

            uc.trySetTarget(this);

            if ( m_unit.m_stats["HP"] <= 0 )
            {
                uc.tryRemoveTarget(this);
                if ( m_unit.m_important )
                {
                    Random ran = new Random();
                    if ( ran.Next(100) <= 10 )
                    {
                        m_unit.m_stats["CHP"] = (int)((float)m_unit.m_stats["CHP"] / 1.2);
                        Debug.WriteLine("YOU HAVE BEEN WOUNDED");
                    }
                    else if ( ran.Next(100) >= 95 )
                    {
                        m_unit.m_stats["CHP"] = 0;
                        action = CommandTimer.getCommandFromTemplate("UNIT-DEAD");
                        Debug.WriteLine("YOU HAVE DIED LOL");
                        m_unit.m_alive = false;
                    }
                    else {
                        Debug.WriteLine("YOU HAVE BEEN ROUTED");
                    }
                    attemptHealHealth(9999);
                    attemptHealFocus(9999);
                    m_unit.x_pos = -100; m_unit.y_pos = -100;
                }
                else {
                    m_unit.m_alive = false;
                    m_unit.m_stats["CHP"] = 0;
                    action = CommandTimer.getCommandFromTemplate("UNIT-DEAD");
                }
                uc.m_unit.m_killCount++;
            }

            if (m_unit.m_stats["CHP"] <= 0)
            {
                m_unit.m_alive = false;
                action = CommandTimer.getCommandFromTemplate("UNIT-DEAD");
            }
        }
Example #10
0
 public void addUnit(UnitController u)
 {
     m_units.Add(u);
     u.m_battleGroup = this;
 }
Example #11
0
 public void addUnit(UnitController u)
 {
     m_units.Add(u);
     u.m_battleGroup = this;
 }
Example #12
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            #region loadTextures
            spriteBatch = new SpriteBatch(GraphicsDevice);
            p_icon = Content.Load<Texture2D>("P_Icon");
            bar_edge = Content.Load<Texture2D>("Bar_Edge");
            bar_eglow = Content.Load<Texture2D>("Bar_EdgeGlow");
            bar_mid = Content.Load<Texture2D>("Bar_Mid");
            bar_font = Content.Load<SpriteFont>("BarFont");
            bar_filt = Content.Load<Texture2D>("Bar_Filter");
            ko_font = Content.Load<SpriteFont>("KOCountFont");
            map_edge = Content.Load<Texture2D>("Map_Border");
            map_officer = Content.Load<Texture2D>("Map_Officer");
            #endregion

            setupDefaultAnimations();

            Minimap.initialize(bb);
            mm = new Minimap(8000, 8000, 4000, 4000, 32, 32, 128, 96, 100, map_edge, map_officer);
            mm.setDisplay(true);

            Unit a = new Unit(10050, 10080, 0, "Player");
            a.setTexture(p_icon, Color.Azure);
            a.setStats(250, 170, 100, 100, 100, 100, 100, 120, 1, 0, 4000);
            a.m_important = true;
            UnitController PLAYERCONTROLLER = new UnitController(a);
            mm.addWatchUnit(PLAYERCONTROLLER);
            BattleGroup bgA = new BattleGroup(PLAYERCONTROLLER, 1);

            WeaponAnimation whammer = WeaponAnimation.getAnimation("WEAPON-SPRITE-WARHAMMER");
            Weapon.addNewWeaponTemplate("Warhammer", Color.LightGray, whammer, new Dictionary<string, int>());
            Weapon.addSwingToWeapon("Warhammer", 18.0f, 0.8f, -1.2f, 0.6f, 10);
            Weapon.addSwingToWeapon("Warhammer", 18.0f, -1.2f, 1.0f, 0.7f, 14);
            Weapon.addSwingToWeapon("Warhammer", 24.0f, 0.0f, -0.0f, 0.95f, 18);

            Weapon w = Weapon.getWeaponFromTemplate("Warhammer");
            w.m_unitHeld = PLAYERCONTROLLER;
            a.m_weapon = w;

            #region createUnits
            Random ran = new Random();
            for (int i = 0; i < 5; i++)
            {
                Unit l = new Unit(ran.Next(600) - 300 * i + 10000, ran.Next(600) + 50 * i + 10000, 0,"Lieutenant");
                l.setStats(120, 80, 80, 80, 80, 80, 80, 80, 2, 0, 4000);
                l.setTexture(p_icon, Color.Blue);
                UnitController UCL = new UnitController(l);
                mm.addWatchUnit(UCL);
                BattleGroup BGX = new BattleGroup(UCL, 1);
                Weapon lw = Weapon.getWeaponFromTemplate("Warhammer");
                lw.m_unitHeld = UCL;
                l.m_weapon = lw;
                for (int j = 0; j < 100; j++)
                {
                    Unit f = new Unit(ran.Next(600) - 300 * i + 10000, ran.Next(600) + 50 * i + 10000, 0, "Private");
                    f.setStats(80, 50, 60, 60, 60, 60, 60, 60, 1, 0, 4000);
                    f.setTexture(p_icon, Color.LightBlue);
                    UnitController UCF = new UnitController(f);
                    BGX.addUnit(UCF);
                    Weapon fw = Weapon.getWeaponFromTemplate("Warhammer");
                    fw.m_unitHeld = UCF;
                    f.m_weapon = fw;
                }
                bb.addUnitGroup("FriendlyFodder:"+i,BGX);
            }

            for (int i = 0; i < 6; i++)
            {
                Unit l = new Unit(ran.Next(600) + 300 * i + 10000, ran.Next(600) + 50 * i + 10000, 3.0f, "Lieutenant");
                l.setStats(120, 80, 80, 80, 80, 80, 80, 80, 2, 0, 4000);
                l.setTexture(p_icon, Color.Red);
                UnitController UCL = new UnitController(l);
                mm.addWatchUnit(UCL);
                BattleGroup BGX = new BattleGroup(UCL, 2);
                Weapon lw = Weapon.getWeaponFromTemplate("Warhammer");
                lw.m_unitHeld = UCL;
                l.m_weapon = lw;
                for (int j = 0; j < 100; j++)
                {
                    Unit f = new Unit(ran.Next(600) + 600 * i + 10000, ran.Next(600) + 50 * i + 10000, 3.0f, "Private");
                    f.setStats(80, 50, 60, 60, 60, 60, 60, 60, 1, 0, 4000);
                    f.setTexture(p_icon, Color.LightPink);
                    UnitController UCF = new UnitController(f);
                    BGX.addUnit(UCF);
                    Weapon fw = Weapon.getWeaponFromTemplate("Warhammer");
                    fw.m_unitHeld = UCF;
                    f.m_weapon = fw;
                }
                bb.addUnitGroup("Fodder:" + i, BGX);
            }
            #endregion

            bb.addFaction("Player Army", 1);
            bb.addFaction("Enemy Army", 2);

            bb.addUnit(PLAYERCONTROLLER);

            barDisplayUnit = PLAYERCONTROLLER;
            bb.addUnitGroup("Player",bgA);

            bb.m_camera.setScreenSize(SCREEN_WIDTH, SCREEN_HEIGHT);
            bb.m_camera.setUnitFocus("Player");

            m_inputHandler = new UnitInputHandler(PlayerIndex.One, bb.getUnitController(a));
        }
 public UnitInputHandler(PlayerIndex index, UnitController controller)
 {
     m_index = index;
     m_controller = controller;
     m_heldButtons = new List<Buttons>();
 }
Example #14
0
 public UnitInputHandler(PlayerIndex index, UnitController controller)
 {
     m_index       = index;
     m_controller  = controller;
     m_heldButtons = new List <Buttons>();
 }