Beispiel #1
0
    public void Init(WeapenCfg weapenCfg)
    {
        switch (weapenCfg.weapenType)
        {
        case "Rifle":
            weapenType = WeapenType.Rifle;
            break;

        case "Sniper":
            weapenType = WeapenType.Sniper;
            break;
        }
        weapenShootRate   = weapenCfg.weapenShootRate;
        weapenReload      = weapenCfg.weapenReload;
        weapenFrontBullet = weapenCfg.weapenFrontBullet;
        weapenBackBullet  = weapenCfg.weapenBackBullet;
        weapenDamage      = weapenCfg.weapenDamage;
        weapenRocoil      = weapenCfg.weapenRocoil;
        weapenRocoilTime  = weapenCfg.weapenRocoilTime;
        BulletPrefab      = weapenCfg.BulletPrefab;
        FireEffect        = weapenCfg.FireEffect;
        ShellEffect       = weapenCfg.ShellEffect;

        CurrentFrontBullet = weapenFrontBullet;
        isFirst            = false;
        CurrentBackBullet  = weapenBackBullet;


        netSvc = NetSvc.Instance;

        Init();
    }
Beispiel #2
0
    /// <summary>
    /// 进入战斗
    /// </summary>
    /// <param name="battleProp">自己的战场参数</param>
    public void EnterBattle(Dictionary <int, BattleProp> battlePropDic)
    {
        GameObject battleGO = new GameObject("Battle");

        battleGO.transform.SetParent(gameObject.transform);
        battleMgr = battleGO.AddComponent <BattleMgr>();
        battleMgr.Init(battlePropDic);

        audioSvc.PlayBGMusic(Constants.BGBattle);
        foreach (var item in battlePropDic)
        {
            //玩家血量字典集合
            playerHPDic.Add(item.Value.roleType, item.Value.playerHp);
        }
        playerControlPanel = (PlayerControlPanel)UIManager.Instance.PushPanel(UIPanelType.PlayerControl);
        //SetFireButton();
        CreateAllPlayerHPUI(playerHPDic);

        WeapenCfg weapenCfg = resSvc.GetWeapenCfgData(battlePropDic.TryGet((int)GetCurrentRoleType()).weapenCfgID);

        SetTxtBullet(weapenCfg.weapenFrontBullet, weapenCfg.weapenBackBullet);

        //小于一定范围自动瞄准。
        GameObject[] Players = GameObject.FindGameObjectsWithTag("Player");
        for (int i = 0; i < Players.Length; i++)
        {
            if (Players[i].GetComponent <PlayerController>() == null)
            {
                playerControlPanel.AddEnemyToDic(Players[i].name, Players[i]);
                PECommon.Log("添加敌方角色进自动瞄准List:" + Players[i].name);
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 根据武器ID获得一个武器的资料
    /// </summary>
    public WeapenCfg GetWeapenCfgData(int weapenID)
    {
        WeapenCfg weapenCfg = null;

        if (weapenDicCfg.TryGetValue(weapenID, out weapenCfg))
        {
            return(weapenCfg);
        }
        else
        {
            return(null);
        }
    }
Beispiel #4
0
    public void SetPlayerWeapen()
    {
        WeapenCfg weapenCfg = ResSvc.Instance.GetWeapenCfgData(battleProp.weapenCfgID);

        controller.gameObject.AddComponent <ObjectPool>();
        switch (weapenCfg.id)
        {
        case (int)WeapenType.Rifle:
            RifleView rifleView = controller.gameObject.AddComponent <RifleView>();
            gunControllerBase = controller.gameObject.AddComponent <Rifle>();
            gunControllerBase.M_GunViewBase = rifleView;
            break;

        case (int)WeapenType.Sniper:
            SniperView sniperView = controller.gameObject.AddComponent <SniperView>();
            gunControllerBase = controller.gameObject.AddComponent <Sniper>();
            gunControllerBase.M_GunViewBase = sniperView;
            break;
        }

        gunControllerBase.Init(weapenCfg);
    }
Beispiel #5
0
 /// <summary>
 /// 设置武器属性
 /// </summary>
 public virtual void SetWeapenInfo(WeapenType weapenType, WeapenCfg weapenCfg)
 {
 }
Beispiel #6
0
    private void InitWeapenCfg()
    {
        TextAsset xml = Resources.Load <TextAsset>(PathDefine.WeapenCfg);

        if (!xml)
        {
            Debug.LogError("xml file:" + PathDefine.WeapenCfg + " not exist");
        }
        else
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml.text);

            XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes;

            for (int i = 0; i < nodLst.Count; i++)
            {
                XmlElement ele = nodLst[i] as XmlElement;

                if (ele.GetAttributeNode("ID") == null)
                {
                    continue;
                }
                int       ID        = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);
                WeapenCfg weapenCfg = new WeapenCfg
                {
                    id = ID,
                };
                foreach (XmlElement e in nodLst[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "weapenType":
                        weapenCfg.weapenType = e.InnerText;
                        break;

                    case "weapenDamage":
                        weapenCfg.weapenDamage = int.Parse(e.InnerText);
                        break;

                    case "weapenShootRate":
                        weapenCfg.weapenShootRate = int.Parse(e.InnerText);
                        break;

                    case "weapenFrontBullet":
                        weapenCfg.weapenFrontBullet = int.Parse(e.InnerText);
                        break;

                    case "weapenBackBullet":
                        weapenCfg.weapenBackBullet = int.Parse(e.InnerText);
                        break;

                    case "weapenReload":
                        weapenCfg.weapenReload = int.Parse(e.InnerText);
                        break;

                    case "weapenRocoil":
                        weapenCfg.weapenRocoil = int.Parse(e.InnerText);
                        break;

                    case "weapenRocoilTime":
                        weapenCfg.weapenRocoilTime = int.Parse(e.InnerText);
                        break;

                    case "BulletPrefab":
                        weapenCfg.BulletPrefab = e.InnerText;
                        break;

                    case "FireEffect":
                        weapenCfg.FireEffect = e.InnerText;
                        break;

                    case "ShellEffect":
                        weapenCfg.ShellEffect = e.InnerText;
                        break;
                    }
                }
                weapenDicCfg.Add(weapenCfg.id, weapenCfg);
            }
        }
    }