Exemplo n.º 1
0
    /// <summary>
    /// 选择武器变化
    /// </summary>
    /// <param name="b"></param>
    /// <param name="item"></param>
    public void OnWeaponSelected(bool b, WeaponShopItem item)
    {
        if (!b || item == null)
        {
            this.selectWeaponId = -1;
        }
        else
        {
            selectWeaponItem = item;
            if (weaponDisplay != null)
            {
                WeaponItem wi = WeaponManager.Instance.GetWeaponItemById(item.weaponId);
                if (wi == null)
                {
                    selectWeaponId = -1;
                }
                else
                {
                    selectWeaponId = wi.Id;
                    CommonUtils.SetChildText(weaponDisplay, "WeaponName", wi.Name);
                    CommonUtils.SetChildRawImage(weaponDisplay, "WeaponIcon", item.weaponIcon);
                    CommonUtils.SetChildText(weaponInfo, "WeaponName", wi.Name);
                    var weaponUnlockInfo = Player.CurrentPlayer.GetWeaponInfoById(wi.Id);

                    if (weaponUnlockInfo != null && weaponUnlockInfo.IsUnlocked)
                    {
                        CommonUtils.SetChildActive(weaponDisplay, "Locked", false);
                        DisplayWeaponLevelInfo(wi.GetLevelProperty(weaponUnlockInfo.Level), true);
                    }
                    else
                    {
                        CommonUtils.SetChildActive(weaponDisplay, "Locked", true);
                        CommonUtils.SetChildText(weaponDisplay, "Locked/Price", wi.Prices.ToString());
                        DisplayWeaponLevelInfo(wi.GetCurrentProperty(), false);
                    }

                    //显示按钮
                    if (Player.CurrentPlayer.EquipedWeaponId == wi.Id)
                    {
                        //CommonUtils.SetChildActive(buttons, "BtnEquiped",true);
                        SetButtonActive("BtnEquiped");
                    }
                    else
                    {
                        if (weaponUnlockInfo != null && weaponUnlockInfo.IsUnlocked)
                        {
                            SetButtonActive("BtnEquip");
                        }
                        else
                        {
                            SetButtonActive("BtnBuy");
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    void OnSelectWeaponChanged(bool isOn, LevelMapWeaponObject weaponObject)
    {
        if (isOn && weaponObject)
        {
            //Weapon weapon = weaponObject.GetWeapon();
            // WeaponProperty wp = WeaponManager.Instance.GetCurrentPropertyById(weaponObject.weaponId);
            WeaponItem wi = WeaponManager.Instance.GetWeaponItemById(weaponObject.weaponId);
            if (wi != null)
            {
                selectWeaponId = wi.Id;
                //设置名字
                SetChildText(weaponSelect.GetComponent <RectTransform>(), "SelectedWeaponName", wi.Name);
                WeaponProperty wp = wi.GetCurrentProperty();
                if (wp != null)
                {
                    //设置武器攻击值
                    SetChildSliderValue(weaponInfo, "Pwoer", wp.Power / GameGlobalValue.s_MaxWeaponAttack);
                    //设置攻击次数
                    SetChildSliderValue(weaponInfo, "FireRate", (wp.FireRate) / GameGlobalValue.s_MaxFireRatePerSeconds);

                    //准确度
                    //float stab = 1.0f;
                    //if (weapon.randomShooting)
                    //{
                    //    stab -= weapon.randomShootingSize.x / GameGlobalValue.s_MaxShakeDistance;
                    //}

                    //SetChildSliderValue(weaponInfo, "Stability", stab);

                    //弹夹
                    SetChildSliderValue(weaponInfo, "Magazine", (float)wp.ClipSize / GameGlobalValue.s_MaxMagazineSize);

                    //移动速度
                    // SetChildSliderValue(weaponInfo, "Mobility", weapon.moveSpeed / GameGlobalValue.s_MaxMobility);
                    //得分能力
                    SetChildSliderValue(weaponInfo, "ScoreBouns", wp.ScoreBonus / GameGlobalValue.s_MaxSocreBonus);
                }
            }
        }
        else
        {
            selectWeaponId = -1;
        }
    }
Exemplo n.º 3
0
    public void Awake()
    {
        //Debug.Log("wepon init");
        weaponItem = WeaponManager.Instance.GetWeaponItemById(ID);
        if (weaponItem == null)
        {
            Debug.LogError("Miss weapon info.");
            return;
        }

        WeaponProperty wp = weaponItem.GetCurrentProperty();

        attack          = wp.Power;
        shootInterval   = 1f / wp.FireRate;
        this.scoreBonus = wp.ScoreBonus;
        curBulltCount   = BulletCount = wp.BulletCount;

        magSize = wp.ClipSize;
    }
Exemplo n.º 4
0
    public void Awake()
    {

        //Debug.Log("wepon init");
        weaponItem = WeaponManager.Instance.GetWeaponItemById(ID);
        if (weaponItem == null)
        {
            Debug.LogError("Miss weapon info.");
            return;
        }

        WeaponProperty wp = weaponItem.GetCurrentProperty();
        attack = wp.Power;
        shootInterval = 1f / wp.FireRate;
        this.scoreBonus = wp.ScoreBonus;
        curBulltCount = BulletCount = wp.BulletCount;

        magSize = wp.ClipSize;

    }