Esempio n. 1
0
    //产生怪物
    private IEnumerator AttackOnMonster()
    {
        xml.Open(check_point_data);
        //先加载开始信息
        xml.BeginParentNode("start_setting");
        Gold_Text.text     = xml.GetValue("coin");
        HPNumber_Text.text = xml.GetValue("hp");
        xml.EndParentNode();

        LinkedList <string> cp = xml.GetChildren();
        float   small          = LocalMessage.grid.width > LocalMessage.grid.height ? LocalMessage.grid.height : LocalMessage.grid.width;
        Vector3 scale          = new Vector3(small, small, small);

        for (current_check_point = 1; current_check_point <= cp.Count - 1; current_check_point++)
        {
            ushort new_type = 0;
            //获取下一关的护甲
            if (xml.HasNode("number_" + (current_check_point + 1).ToString()))
            {
                xml.BeginParentNode("number_" + (current_check_point + 1).ToString());
                new_type = ushort.Parse(xml.GetValue(DEFENSE_TYPE));
                xml.EndParentNode();
            }
            //先加载准备时间
            xml.BeginParentNode("number_" + current_check_point.ToString());
            int ready_time = int.Parse(xml.GetValue(READY_TIME));
            for (; ready_time > 0; ready_time--)
            {
                Timer.text = ready_time.ToString();
                yield return(new WaitForSeconds(1));
            }
            Timer.text           = "0";
            CheckPoint_Text.text = current_check_point.ToString();
            //准备时间结束,产生怪物
            string          defense_type = Armor[byte.Parse(xml.GetValue(DEFENSE_TYPE))];
            int             amount       = int.Parse(xml.GetValue(AMOUNT));
            MonsterProperty temp_mp      = new MonsterProperty().ParseArmorType(xml.GetValue(DEFENSE_TYPE))
                                           .ParseBonus(xml.GetValue(BONUS)).ParseDefensePoint(xml.GetValue(DEFENSE_POINT))
                                           .ParseHipPoint(xml.GetValue(HIT_POINT)).ParseSpeed(xml.GetValue(MOVE_SPEED));
            MonsterInfoPanel.SendMessage("SetMonsterProperties", temp_mp);         //MonsterInfo.cs
            MonsterInfoPanel.SendMessage("SetNextArmorType", new_type);            //MonsterInfo.cs
            float interval_time = float.Parse(xml.GetValue(INTERVAL_TIME)) / 1000;
            for (; amount > 0; amount--)
            {
                CreateMonster("Monster/" + defense_type, temp_mp, scale);
                yield return(new WaitForSeconds(interval_time));
            }
            //如果是boss关卡,则产生一个BOSS
            if (byte.Parse(xml.GetValue(BOSS_CHECK_POINT)) == 1)
            {
                temp_mp = new MonsterProperty().ParseArmorType(xml.GetValue(BOSS_DEFENSE_TYPE))
                          .ParseBonus(xml.GetValue(BOSS_BONUS)).ParseDefensePoint(xml.GetValue(BOSS_DEFENSE_POINT))
                          .ParseHipPoint(xml.GetValue(BOSS_HIP_POINT)).ParseSpeed(xml.GetValue(BOSS_MOVE_SPEED));
                CreateMonster("BOSS/BOSS" + current_check_point.ToString(), temp_mp, scale);
            }
            xml.EndParentNode();
        }
        xml.Close();
    }
Esempio n. 2
0
    private const string VALUE            = "value";            //效果值
    // private const string MULTITARGET = "multitarget";//同时攻击的目标数量
    // private const string RANGE_ATTACK = "range_attack";//是否是范围攻击
    // private const string SPUTTER = "sputter";//攻击造成伤害时的溅射范围
    // private const string CATAPULT = "catapult";//攻击时子弹弹射的数量
    // private const string POISON = "poison";//每秒因中毒的真实伤害值
    // private const string SPEED_DOWN = "speeddown";//速度值减少的值
    // private const string DEFENSE_BREAK = "defense_break";//防御值减少的值
    // private const string STEAL = "steal";//杀死怪物时额外获得的金币数
    // private const string ATTACK_SPEED_UP = "attack_speedup";//己方塔增加的攻击速度
    // private const string ATTACK_DAMAGE_UP = "attack_damageup";//己方塔增加的攻击力

    // Use this for initialization
    void Start()
    {
        AllTower.Clear();
        XMLFileController xml = new XMLFileController();

        xml.Open(TowerDataFile);
        LinkedList <string> list = xml.GetChildren();

        foreach (string name in list)
        {
            xml.BeginParentNode(name);
            //获取塔的基本信息
            Tower temp_t = new Tower(xml.GetValue(NAME), xml.GetValue(DETAIL), int.Parse(xml.GetValue(BUILD_GOLD)),
                                     double.Parse(xml.GetValue(DAMAGE)), int.Parse(xml.GetValue(ATTACK_TYPE)),
                                     double.Parse(xml.GetValue(CRIT_RATE)), double.Parse(xml.GetValue(CRIT_DAMAGE)),
                                     double.Parse(xml.GetValue(ATTACK_RANGE)), long.Parse(xml.GetValue(ATTACK_INTERVAL)),
                                     int.Parse(xml.GetValue(DOMAIN_WITDH)), int.Parse(xml.GetValue(DOMAIN_HEIGHT)));
            //获取塔的效果信息
            long   last_time    = long.Parse(xml.GetValue(EFFECT_LAST_TIME));
            int    features_num = int.Parse(xml.GetValue(FEATURES));
            double value        = double.Parse(xml.GetValue(VALUE));
            temp_t.SetFeatures(features_num, last_time, value);
            AllTower.Add(name, temp_t);
            xml.EndParentNode();
        }
    }