Exemple #1
0
    //创建游戏物体工厂
    public GameObject BCGameObjFactory(int id, Vector3 po, Vector3 ro, Vector3 scale)
    {
        BCObj mObj = WGDataController.Instance.GetBCObj(id);

        switch (mObj.BCType)
        {
        case BCGameObjectType.Bear:
        {
            _Obj = Instantiate(mObj.goRes, po, Quaternion.Euler(ro)) as GameObject;
            _Obj.transform.localScale = Vector3.one * 0.8f;
        }
        break;

        case BCGameObjectType.ExpCoin:
        case BCGameObjectType.Item:
        case BCGameObjectType.Coin:
        {
            _Obj = Instantiate(mObj.goRes) as GameObject;

            _Obj.transform.parent = _BearCoinRoot.transform;

            _Obj.transform.position = po;
            _Obj.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 180));
            _Obj.SetActive(true);

            _Obj.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            _Obj.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;

            Vector3 ls = Vector3.one;
            if (Core.fc.dicCoinScale.ContainsKey(mObj.ID))
            {
                ls = Core.fc.dicCoinScale[mObj.ID];
            }
            else
            {
                switch (id)
                {
                case WGDefine.Value100Coin:
                    ls   = ls * 0.7f;
                    ls.y = 0.9f;
                    break;

                case WGDefine.Value10Coin:
                    ls   = ls * 0.55f;
                    ls.y = 0.75f;
                    break;

                case WGDefine.Value5Coin:
                case WGDefine.Value3Coin:
                case WGDefine.Value2Coin:
                    ls   = ls * 0.434f;
                    ls.y = 0.634f;
                    break;

                case WGDefine.CommonCoin:
                    ls   = ls * 0.4f;
                    ls.y = 0.6f;
                    break;

                default:
                    ls   = ls * 0.5f;
                    ls.y = 0.6f;
                    break;
                }
            }

            _Obj.transform.localScale = ls;

            _CoinProperty = _Obj.GetComponent <BCGameObj>();
            _CoinProperty.freshWithData(mObj);

            _szLiveCoin.Add(_Obj);
        }

        break;

        case BCGameObjectType.Jewel:        // 宝石

            break;

        case BCGameObjectType.Collection:
            _Obj = Instantiate(mObj.goRes, po, Quaternion.Euler(new Vector3(270, 0, 0))) as GameObject;
            _Obj.transform.parent = _BearCoinRoot.transform;
//			_Obj.transform.localScale = Vector3.one*0.6f;

            _CoinProperty = _Obj.GetComponent <BCGameObj>();
            _CoinProperty.freshWithData(mObj);
            _szDeskCollection[id - 3000]++;

            _szLiveCoin.Add(_Obj);

            break;
        }

        return(_Obj);
    }
Exemple #2
0
    void Throw()
    {
        if (!_ShareWorld.cs_BearManage.bHaiXiaoEffect)
        {
            _Weapon.FireEffect();
            int subNum = -10;
            if (_weaponData != null)
            {
                subNum = -_weaponData.cost;
            }
//			if(_weaponData.cost>dp.Coin)
//			{
//				if(mWeaponIndex>Consts.WEAPON_MIN)
//				{
//					mWeaponIndex = GetCanThrowIndex();
//					changeWeapon();
//					subNum = -_weaponData.cost;
//					return;
//				}
//
//			}
            if (!_ShareWorld.PlayerGetCoin(subNum))
            {
                if (!_ShareWorld.bNoCoinTip)
                {
//					_ShareWorld.bNoCoinTip = true;
                    _ShareWorld.NoCoinTipCan();

                    _ShareWorld.ShowCoinSupplementView();
                }
                return;
            }
        }
        BCSoundPlayer.Play(MusicEnum.Shot);
        if (bUseStaticWeapon)
        {
            Vector3 cur = Input.mousePosition - new Vector3(Screen.width / 2, 0, 0);

            float mm = Vector3.Angle(Vector3.up, cur);

            if (mm > 15)
            {
                mm = 15;
            }

            if (cur.x <= 0)
            {
                mm = -mm;
            }

            Ro = mm;



            _Weapon.trBullet.enabled = false;
            Vector3 temp = _Weapon.tRote.localEulerAngles;
            temp.y = Ro;
            _Weapon.tRote.localEulerAngles = temp;


            if (Ro > 300)
            {
                Ro = Ro - 360;
            }
            Ro /= 15;
        }
        else
        {
            Ro = _Weapon.tRote.localEulerAngles.y;
//			Debug.Log(Ro);
            if (Ro > 300)
            {
                Ro = Ro - 360;
            }
            Ro /= 15;
        }
        _Coin = WGGameWorld.Instance.cs_ObjManager.BCGameObjFactory(_weaponData.oid, _Weapon.tBullet.position, Vector3.zero, Vector3.one);
//		_Coin =  Instantiate(_Weapon.goBullet,_Weapon.tBullet.position,Quaternion.Euler(Vector3.zero)) as GameObject;
//		_Coin.transform.parent = WGBearManage.Instance.ThrowCoinRoot.transform;



        _Rig = _Coin.GetComponent <Rigidbody>();

        Vector3 v3force = new Vector3(Ro, Up, Forward);

        _Rig.AddForce(v3force, ForceMode.Impulse);

        _bullet = _Coin.AddComponent <WGBullet>();

        _bullet.mAct = _weaponData.hurt;
        if (dp.mR == 1)
        {
//			if(dp.r == 0)
//			{
//				_bullet.mAct = (int)(_weaponData.hurt *1.1f);
//			}
//			else if(dp.r == 1)
            {
                _bullet.mAct = (int)(_weaponData.hurt * 1.3f);
            }
        }

        BCObj bco = WGDataController.Instance.GetBCObj(_weaponData.oid);

        BCGameObj bcgo = _Coin.GetComponent <BCGameObj>();

        bcgo.freshWithData(bco);
    }