コード例 #1
0
        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");
            }
        }
コード例 #2
0
        private void handleInnerCommand(List <String> commands, float percentSecond)
        {
            foreach (String command in commands)
            {
                if (command.Equals("UNIT-TURN-RIGHT"))
                {
                    m_unit.turnDirection(true, percentSecond * m_turnMoveModifier);
                }

                if (command.Equals("UNIT-TURN-LEFT"))
                {
                    m_unit.turnDirection(false, percentSecond * m_turnMoveModifier);
                }

                if (command.Equals("UNIT-MOVE-FORWARD"))
                {
                    m_unit.moveDirection(true, percentSecond * m_movementModifier);
                }

                if (command.Equals("UNIT-MOVE-BACKWARD"))
                {
                    m_unit.moveDirection(false, percentSecond * m_movementModifier);
                }

                if (command.Equals("UNIT-DODGE"))
                {
                    m_unit.moveDirection(false, percentSecond);
                    m_unit.moveDirection(false, percentSecond);
                }

                if (command.Equals("UNIT-COMMAND-START-DODGE"))
                {
                    if (tryDodge(false))
                    {
                        action = CommandTimer.getCommandFromTemplate("UNIT-DODGE");
                    }
                }

                if (command.Equals("UNIT-COMMAND-START-DODGE-FOCUS"))
                {
                    if (tryDodge(true))
                    {
                        action = CommandTimer.getCommandFromTemplate("UNIT-DODGE");
                        Animation a = Animation.getAnimation("UNIT-CHARGE-EXPLODE");
                        a.m_color = Color.Yellow;
                        a.setSlide(0);
                        m_unit.m_animations.Add(a);
                    }
                }

                if (command.Equals("UNIT-COMMAND-START-ATTACK"))
                {
                    if (m_swinging)
                    {
                        m_swingAgain = true;
                    }

                    if (!m_swinging && tryAttack(false))
                    {
                        swingWeapon();
                        m_swingAgain = false;
                    }
                }
            }
        }