Exemplo n.º 1
0
    // 建立武器
    public override IWeapon CreateWeapon(ENUM_Weapon emWeapon)
    {
        IWeapon pWeapon   = null;
        string  AssetName = "";
        int     AttrID    = 0;

        //根据武器类型建立
        switch (emWeapon)
        {
        case ENUM_Weapon.Knife:
            pWeapon   = new WeaponKnife();
            AssetName = "5";
            AttrID    = 1;
            break;

        default:
            Debug.LogWarning("创建[" + emWeapon + "]失败!!!");
            return(null);
        }

        // 加载武器资源
        IAssetFactory AssetFactory    = GameFactory.GetAssetFactory();
        Sprite        WeaponGameObjet = AssetFactory.LoadWeapon(AssetName);

        pWeapon.SetIWeapon(WeaponGameObjet);

        // 设置武器的威力
        IAttrFactory theAttrFactory = GameFactory.GetAttrFactory();
        WeaponAttr   theWeaponAttr  = theAttrFactory.GetWeaponAttr(AttrID);

        pWeapon.SetWeaponAttr(theWeaponAttr);

        return(pWeapon);
    }
Exemplo n.º 2
0
    //获取武器属性
    public void GetWeaponAttr()
    {
        _colL = _lweapontrans.GetComponentInChildren <Collider>();
        _colR = _rweapontrans.GetComponentInChildren <Collider>();

        if (_lweapontrans.childCount != 0)
        {
            _lweaponAttr = _lweapontrans.transform.GetChild(0).GetChild(0).GetComponent <WeaponAttr>();
        }

        if (_rweapontrans.childCount != 0)
        {
            _rweaponAttr = _rweapontrans.transform.GetChild(0).GetChild(0).GetComponent <WeaponAttr>();
        }
    }
Exemplo n.º 3
0
    // 建立武器
    public override IWeapon CreateWeapon(ENUM_Weapon emWeapon)
    {
        IWeapon pWeapon   = null;
        string  AssetName = "";         // Unity模型名称
        int     AttrID    = 0;          // 武器的能力值

        // 依武器
        switch (emWeapon)
        {
        case ENUM_Weapon.Gun:
            pWeapon   = new WeaponGun();
            AssetName = "WeaponGun";
            AttrID    = 1;
            break;

        case ENUM_Weapon.Rifle:
            pWeapon   = new WeaponRifle();
            AssetName = "WeaponRifle";
            AttrID    = 2;
            break;

        case ENUM_Weapon.Rocket:
            pWeapon   = new WeaponRocket();
            AssetName = "WeaponRocket";
            AttrID    = 3;
            break;

        default:
            Debug.LogWarning("CreateWeapon:无法建立[" + emWeapon + "]");
            return(null);
        }

        // 产生Asset
        IAssetFactory AssetFactory    = PBDFactory.GetAssetFactory();
        GameObject    WeaponGameObjet = AssetFactory.LoadWeapon(AssetName);

        pWeapon.SetGameObject(WeaponGameObjet);

        // 取得武器的威力
        IAttrFactory theAttrFactory = PBDFactory.GetAttrFactory();
        WeaponAttr   theWeaponAttr  = theAttrFactory.GetWeaponAttr(AttrID);

        // 设定武器的威力
        pWeapon.SetWeaponAttr(theWeaponAttr);

        return(pWeapon);
    }
Exemplo n.º 4
0
        // 建立武器
        public override IWeapon CreateWeapon(ENUM_Weapon enumWeapon)
        {
            IWeapon weapon    = null;
            string  AssetName = ""; // Unity模型名称
            int     AttrID    = 0;  // 武器能力值

            switch (enumWeapon)
            {
            case ENUM_Weapon.Gun:
                weapon    = new WeaponGun();
                AssetName = "WeaponGun";
                AttrID    = 1;
                break;

            case ENUM_Weapon.Rifle:
                weapon    = new WeaponRifle();
                AssetName = "WeaponRifle";
                AttrID    = 2;
                break;

            case ENUM_Weapon.Rocket:
                weapon    = new WeaponRocket();
                AssetName = "WeaponRocket";
                AttrID    = 3;
                break;

            default:
                Debug.LogWarning("CreateWeapon无法建立[" + enumWeapon + "]");
                return(null);
            }

            // 产生Asset
            IAssetFactory AssetFactory     = RTSFactory.GetAssetFactory();
            GameObject    WeaponGameObject = AssetFactory.LoadWeapon(AssetName);

            weapon.SetGameObject(WeaponGameObject);

            // 获取武器威力
            IAttrFactory AttrFactory   = RTSFactory.GetAttrFactory();
            WeaponAttr   theWeaponAttr = AttrFactory.GetWeaponAttr(AttrID);

            // 设置属性
            weapon.SetWeaponAttr(theWeaponAttr);

            return(weapon);
        }
Exemplo n.º 5
0
 // 設定攻擊能力
 public void SetWeaponAttr(WeaponAttr theWeaponAttr)
 {
     m_WeaponAttr = theWeaponAttr;
 }
Exemplo n.º 6
0
	// 設定攻擊能力
	public void SetWeaponAttr(WeaponAttr theWeaponAttr)
	{
        m_WeaponAttr = theWeaponAttr;
	}
Exemplo n.º 7
0
 void Start()
 {
     _audioSource = GetComponent <AudioSource> ();
     attr         = GetComponent <WeaponAttr>();
 }
Exemplo n.º 8
0
 //设置武器属性
 public void setWeaponAttr(WeaponAttr weaponAttr)
 {
     m_weaponAttr = weaponAttr;
 }