/// <summary> /// 根据id 获得某个物品数据 /// </summary> /// <returns>The BC object.</returns> /// <param name="id">Identifier.</param> public BCObj GetBCObj(int id) { BCObj o = null; dicGameObj.TryGetValue(id, out o); return(o); }
void processAchievementDescription(MDAchievement ach) { string objName = ""; if (ach.type == DTAchievementType.TIGER_ID) { MDTigerInfo ti = GetTigerInfo(ach.goals[0]); objName = ti.name; } else { BCObj mObj = GetBCObj(ach.goals[0]); objName = mObj.Name; } string desstr = ""; string[] des = ach.des.Split('#'); for (int i = 0, max = des.Length; i < max; i++) { desstr += des[i]; if (i < ach.pramater.Count) { if (ach.pramater[i] == 1) { desstr += objName; } else if (ach.pramater[i] == 2) { desstr += ach.goal_num.ToString(); } } } ach.des = desstr; }
public void freshWithCollectionID(int id, Color color) { WGDataController _dataCtrl = WGDataController.Instance; mItemColID = id; labNum.text = _dataCtrl.GetCollectionOwnNum(id).ToString(); BCObj obj = _dataCtrl.GetBCObj(id); if (obj != null) { GameObject go = Instantiate(obj.goRes, Vector3.zero, Quaternion.Euler(270, 0, 0)) as GameObject; Vector3 scale = go.transform.localScale; go.transform.parent = this.transform; go.transform.localScale = Vector3.one * 14.6f; go.transform.localPosition = goCollectionPanel.transform.localPosition; go.transform.parent = goCollectionPanel.transform; Destroy(go.GetComponent <Rigidbody>()); Destroy(go.GetComponent <BoxCollider>()); goCollectionPanel.GetComponent <TweenRotation>().delay = Random.Range(0, 1); } spBackground.color = color; spBottom.color = color; }
int GetRandomCollectionID() { int idx = Random.Range(0, WGDataController.Instance.szCollectionObj.Count); BCObj obj = WGDataController.Instance.szCollectionObj[idx]; return(obj.ID); }
public int State; // public void freshWithData(BCObj obj, int st = 0) { this.ID = obj.ID; this.Type = obj.Type; this.Exp = obj.Exp; this.Value = obj.Value; this.State = st; }
void freshUIWithBearID(int id) { BCObj obj = _dataCtrl.GetBCObj(id); WGBearParam bear = _dataCtrl.GetBearParam(id); DataPlayer _dp = DataPlayerController.getInstance().data; int curLv = _dp.Level; bool isGray = false; if (bear.unlock >= 0) { gemLockView.ESetActive(false); if (curLv >= bear.unlock) //解锁 { isGray = false; unLockView.ESetActive(true); levelLockView.ESetActive(false); WGShowBearController.Instance.ShowMode(0); } else //需要到达等级解锁 { isGray = true; unLockView.ESetActive(false); levelLockView.ESetActive(true); WGShowBearController.Instance.ShowMode(2); } } else { levelLockView.ESetActive(false); if (_dp.szPayObjID.Contains(id)) //解锁 { unLockView.ESetActive(true); gemLockView.ESetActive(false); isGray = false; WGShowBearController.Instance.ShowMode(0); } else //需要花钻石解锁,没有解锁 { isGray = true; unLockView.ESetActive(false); gemLockView.ESetActive(true); WGShowBearController.Instance.ShowMode(1); } } unLockView.freshWithBearID(obj.Name, bear.des); gemLockView.freshWithBearID(obj.Name, bear.des); levelLockView.freshWithBearID(obj.Name, bear.des); WGShowBearController.Instance.ShowMonsterWithID(id, isGray); }
public void freshCellView(MDReward tr) { labNum.text = tr.num.ToString(); BCObj obj = WGDataController.Instance.GetBCObj(tr.id); if (obj != null) { // spIcon.spriteName = obj.Icon; } }
public void freshUIWithData(MDAchievement ach) { preAchievementData = ach; WGDataController _dataCtrl = WGDataController.Instance; DataPlayerController dpc = DataPlayerController.getInstance(); BCObj rwObj = _dataCtrl.GetBCObj(ach.reward[0]); labName.text = ach.name + ":" + ach.des; spGoalIcon.spriteName = ach.icon; switch (rwObj.BCType) { case BCGameObjectType.Coin: spRewardIcon.spriteName = "coin_105"; break; case BCGameObjectType.Jewel: spRewardIcon.spriteName = "gem_104"; break; } spRewardIcon.MakePixelPerfect(); labRewardNum.text = WGStrings.getFormate(1066, ach.reward[1]); int got = 0; dpc.data.dicGotAchReward.TryGetValue(ach.id, out got); if (got == 1) //到达了 { btnGetReward.gameObject.SetActive(true); sdProgress.gameObject.SetActive(false); goHaveGot.SetActive(false); } else if (got == 0) //还没有到达 { goHaveGot.SetActive(false); btnGetReward.gameObject.SetActive(false); sdProgress.gameObject.SetActive(true); int reachNum = WGAchievementManager.Self.getAchievementProgress(ach); labProgress.text = reachNum.ToString() + "/" + ach.goal_num.ToString(); sdProgress.value = reachNum * 1f / ach.goal_num; } else if (got == -1) //已经领取 { goHaveGot.SetActive(true); btnGetReward.gameObject.SetActive(false); sdProgress.gameObject.SetActive(false); } }
void GetReward(bool bDouble) { DataPlayerController dpc = DataPlayerController.getInstance(); DataPlayer _dp = dpc.data; BCGameObjectType type = WGDataController.Instance.GetBCObjType(curReward.reward); BCObj obj = WGDataController.Instance.GetBCObj(curReward.reward); switch (type) { case BCGameObjectType.Coin: _dp.Coin = _dp.Coin + curReward.got_num; if (bDouble) { _dp.Coin = _dp.Coin + curReward.got_num; } break; case BCGameObjectType.Collection: dpc.addCollectionNum(curReward.reward, curReward.got_num); if (bDouble) { dpc.addCollectionNum(curReward.reward, curReward.got_num); } break; case BCGameObjectType.Item: dpc.AddSkillNum(curReward.reward, curReward.got_num); if (bDouble) { dpc.AddSkillNum(curReward.reward, curReward.got_num); } break; case BCGameObjectType.Jewel: _dp.Jewel += curReward.got_num; if (bDouble) { _dp.Jewel += curReward.got_num; } #if TalkingData TDGAVirtualCurrency.OnReward(curReward.got_num, "DailyReward"); #endif #if Umeng Umeng.GA.Bonus(curReward.got_num, Umeng.GA.BonusSource.Source2); #endif break; } _dp.lastDailyRewardTime = Core.now; dpc.saveDataPlayer(); WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN | UI_FRESH.COIN); }
public void FreshUnlockBearView(int id) { WGDataController _dtCtl = WGDataController.Instance; mBearObj = _dtCtl.GetBCObj(id); // WGBearParam bp = _dtCtl.GetBearParam(id); labName.text = mBearObj.Name; ShowOneBear.getInstance(); }
public void ShowMonsterWithID(int id, bool isGray = false) { if (goBear != null) { goBear.SetActive(false); dicCacheBears.Add(mCurBearID, goBear); } GameObject go = null; if (dicCacheBears.TryGetValue(id, out go)) { go.SetActive(true); dicCacheBears.Remove(id); } else { BCObj mObj = WGDataController.Instance.GetBCObj(id); go = Instantiate(mObj.goRes) as GameObject; go.transform.parent = goBearParent.transform; go.transform.localPosition = Vector3.zero; go.transform.localEulerAngles = Vector3.zero; go.transform.localScale = Vector3.one; if (mObj.ID == WGDefine.BossID) { go.transform.localScale = Vector3.one * 0.6832443f; } else if (mObj.ID == WGDefine.PayBear1 || mObj.ID == WGDefine.PayBear2) { go.transform.localScale = Vector3.one * 0.8f; } else { go.transform.localScale = Vector3.one; } go.transform.localEulerAngles = Vector3.zero; } WGBear bear = go.GetComponent <WGBear>(); if (bear != null) { bear.IsGray(isGray); } goBear = go; mCurBearID = id; }
public void InitScrollView() { if (bInit) { return; } bInit = true; _dataCtrl = WGDataController.Instance; Dictionary <int, List <int> > dicCollections = new Dictionary <int, List <int> >(); for (int i = 0; i < _dataCtrl.szCollectionObj.Count; i++) { BCObj obj = _dataCtrl.szCollectionObj[i]; BCCollectionInfo col = _dataCtrl.GetCollectionInfo(obj.ID); List <int> szTemp; if (dicCollections.TryGetValue(col.groupID, out szTemp)) { szTemp.Add(obj.ID); } else { szTemp = new List <int>(); szTemp.Add(obj.ID); dicCollections.Add(col.groupID, szTemp); } } int index = 0; foreach (KeyValuePair <int, List <int> > kvp in dicCollections) { CItemCollectionCell cell = CItemCollectionCell.CreateCollectionCell(); cell.transform.parent = this.transform; cell.transform.localScale = Vector3.one; cell.transform.localPosition = new Vector3(0, 200 - index * 236, 0); szCollectionCell.Add(cell); Color color = Color.gray; if (index <= szColors.Length) { color = szColors[index]; } cell.freshWithCollections(kvp.Value.ToArray(), szColors[index]); cell.SetDragCamera(dragCamera); index++; } }
public void freshItem() { WGDataController _dataCtrl = WGDataController.Instance; Dictionary <int, List <int> > dicCollections = new Dictionary <int, List <int> >(); for (int i = 0; i < _dataCtrl.szCollectionObj.Count; i++) { BCObj obj = _dataCtrl.szCollectionObj[i]; BCCollectionInfo col = _dataCtrl.GetCollectionInfo(obj.ID); List <int> szTemp; if (dicCollections.TryGetValue(col.groupID, out szTemp)) { szTemp.Add(obj.ID); } else { szTemp = new List <int>(); szTemp.Add(obj.ID); dicCollections.Add(col.groupID, szTemp); } } int index = 0; bool showTips = false; foreach (KeyValuePair <int, List <int> > kvp in dicCollections) { int [] ids = kvp.Value.ToArray(); if (ids.Length >= 3) { int left = _dataCtrl.GetCollectionOwnNum(ids[0]); int center = _dataCtrl.GetCollectionOwnNum(ids[1]); int right = _dataCtrl.GetCollectionOwnNum(ids[2]); if (Mathf.Min(left, center, right) > 0) { showTips = true; break; } } } spItemComplet.ESetActive(showTips); }
public void ShowOneWithID(int id) { if (goBear != null) { Destroy(goBear); } BCObj obj = WGDataController.Instance.GetBCObj(id); goBear = Instantiate(obj.goRes) as GameObject; goBear.transform.parent = goBearParent; goBear.transform.localPosition = Vector3.zero; goBear.transform.localEulerAngles = Vector3.zero; goBear.transform.localScale = Vector3.one; if (id == WGDefine.BossID) { goBear.transform.localScale = Vector3.one * 0.6f; } }
void OnBtnGetReward() { WGDataController _dataCtrl = WGDataController.Instance; DataPlayerController dpc = DataPlayerController.getInstance(); if (dpc.data.dicGotAchReward[preAchievementData.id] != 1) { WGAlertViewController.Self.showAlertView(1016).alertViewBehavriour = (ab, view) => { switch (ab) { case MDAlertBehaviour.CLICK_OK: view.hiddenView(); break; case MDAlertBehaviour.DID_HIDDEN: WGAlertViewController.Self.hiddeAlertView(view.gameObject); break; } }; return; } int objID = preAchievementData.reward[0]; int gotNum = preAchievementData.reward[1]; BCObj obj = _dataCtrl.GetBCObj(objID); switch (obj.BCType) { case BCGameObjectType.Item: dpc.AddSkillNum(objID, gotNum); WGGameUIView.Instance.freshSkillNum(); break; case BCGameObjectType.Collection: dpc.addCollectionNum(objID, gotNum); break; case BCGameObjectType.Coin: dpc.data.Coin += gotNum; WGGameUIView.Instance.freshPlayerUI(UI_FRESH.COIN); break; case BCGameObjectType.Jewel: dpc.data.Jewel += gotNum; #if TalkingData TDGAVirtualCurrency.OnReward(gotNum, "AchievementReward"); #endif #if Umeng Umeng.GA.Bonus(gotNum, Umeng.GA.BonusSource.Source4); #endif WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN); break; } dpc.data.dicGotAchReward[preAchievementData.id] = -1; // WGAlertViewController.Self.showAlertView(1015).alertViewBehavriour =(ab,view)=>{ // switch(ab) // { // case MDAlertBehaviour.CLICK_OK: // view.hiddenView(); // if(curAchViewManager != null) // { // curAchViewManager.ReloadAchievement(); // } // break; // case MDAlertBehaviour.DID_HIDDEN: // WGAlertViewController.Self.hiddeAlertView(view.gameObject); // break; // } // }; if (curAchViewManager != null) { curAchViewManager.ReloadAchievement(); } }
void OnBtnUnLock() { BCSoundPlayer.Play(MusicEnum.button); WGBearParam bear = _dataCtrl.GetBearParam(mCurBearID); if (!_dataPlayer.szPayObjID.Contains(mCurBearID)) { if (_dataPlayer.Jewel > (-bear.unlock)) { _dataPlayer.Jewel += bear.unlock; //#if TalkingData BCObj ob = _dataCtrl.GetBCObj(mCurBearID); //TDGAItem.OnPurchase(ob.Name,1,Mathf.Abs(bear.unlock)); //#endif #if Umeng Umeng.GA.Buy(mCurBearID.ToString(), 1, bear.unlock); #endif _dataPlayer.szPayObjID.Add(mCurBearID); goGemLock.SetActive(false); // goCurBear.GetComponent<WGBear>().IsGray(false); ShowOneBear.getInstance().IsGray = false; WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN); // goCurBear.SetActive(false); ShowOneBear.getInstance().ShowCurBear = false; goGemLock.SetActive(false); WGAlertViewController.Self.showAlertView(1001).alertViewBehavriour = (ab, view) => { switch (ab) { case MDAlertBehaviour.CLICK_OK: view.hiddenView(); break; case MDAlertBehaviour.DID_HIDDEN: // goCurBear.SetActive(true); ShowOneBear.getInstance().ShowCurBear = true; WGAlertViewController.Self.hiddeAlertView(view.gameObject); break; } }; } else { // goCurBear.SetActive(false); ShowOneBear.getInstance().ShowCurBear = false; goGemLock.SetActive(false); WGAlertViewController.Self.showAlertView(1003, 1002, 1007).alertViewBehavriour = (ab, view) => { switch (ab) { case MDAlertBehaviour.CLICK_OK: view.hiddenView(); WGGameUIView.Instance.CloseCurrentView(); break; case MDAlertBehaviour.CLICK_CANCEL: view.hiddenView(); break; case MDAlertBehaviour.DID_HIDDEN: ShowOneBear.getInstance().ShowCurBear = true; WGAlertViewController.Self.hiddeAlertView(view.gameObject); if (view.clickIndex == MDBaseAlertView.CLICK_OK) { WGGameUIView.Instance.ViewControllerDoAct(BTN_ACT.SHOP); WGShopView.curShopView.InitWillShowWithTabView(SHOP_TAB_VIEW.JEWEL_SHOP); } else { goGemLock.SetActive(true); } break; } }; } } }
//创建游戏物体工厂 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); }
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); }
public void WhenBearKilled(int id, Transform tran, bool bMiao = false) { BCSoundPlayer.Play(MusicEnum.hitBear); WGAchievementManager.Self.processAchievement(id, DTAchievementType.KILL_ALL); WGAchievementManager.Self.processAchievement(id, DTAchievementType.KILL_ONE); WGBearParam mBear = dataCtrl.GetBearParam(id); BCObj mOjb = dataCtrl.GetBCObj(id); _ShareWorld.PlayGetExp(mOjb.Exp); if (WGHelpManager.Self != null) { if (WGHelpManager.Self.enabled) { if (!WGHelpManager.Self.StatesIsEnd(EMHelpStates.Kill_Energy)) { WGHelpManager.Self.ShowHelpView(EMHelpStates.Kill_Energy); } else if (!WGHelpManager.Self.StatesIsEnd(EMHelpStates.Kill_Tiger) && mBear.tiger == 1) { WGHelpManager.Self.ShowHelpView(EMHelpStates.Kill_Tiger); } else if (!WGHelpManager.Self.StatesIsEnd(EMHelpStates.Use_Item)) { WGHelpManager.Self.ShowHelpView(EMHelpStates.Use_Item); } else if (!WGHelpManager.Self.StatesIsEnd(EMHelpStates.RegetCoin)) { WGHelpManager.Self.ShowHelpView(EMHelpStates.RegetCoin); } } } BearDead(tran.parent); szLiveBearID.Remove(id); _curBearNum--; if (id == WGDefine.BossID) { _bearBoss = null; } if (!bHaiXiaoEffect) { _dataPlayer.mEnergy += mBear.energy; } if (_dataPlayer.mEnergy >= _EnergyFull) { if (!_bShowPowerTip) { if (_dataPlayer.a1 == 0) { if (YeHuoSDK.bShowPoweGift) { _bShowPowerTip = true; D04PowerTipView tip = D04PowerTipView.CreatePowerPayView(); Time.timeScale = 0; tip.alertViewBehavriour = (ab, view) => { if (ab == MDAlertBehaviour.CLICK_OK) { Destroy(view.gameObject); showBuyPowerView(); } }; } else { _dataPlayer.mEnergy -= _EnergyFull; bHaiXiaoEffect = true; //DonNotNeedCoin(10+2); // WGTsunamiView tv = WGTsunamiView.CreateTsunamiView(); // tv.alertViewBehavriour =(ab,view)=>{ // switch(ab) // { // case MDAlertBehaviour.DID_HIDDEN: // Destroy(view.gameObject); // break; // } // }; // SDK.AddChild(tv.gameObject,_ShareWorld.go2DUIBottom); // tv.showTsunamiView(10f); csThrow.showTsunamiEffect(true); pgHaiXiao.value = 1; pgHaiXiaoValue = 1; InvokeRepeating("HaiXiaoEffect", 2f, 10f / 100); } } else if (_dataPlayer.a1 == 1) { _dataPlayer.mEnergy -= _EnergyFull; bHaiXiaoEffect = true; DonNotNeedCoin(10 + 2); WGTsunamiView tv = WGTsunamiView.CreateTsunamiView(); tv.alertViewBehavriour = (ab, view) => { switch (ab) { case MDAlertBehaviour.DID_HIDDEN: Destroy(view.gameObject); break; } }; SDK.AddChild(tv.gameObject, _ShareWorld.go2DUIBottom); tv.showTsunamiView(10f); csThrow.showTsunamiEffect(true); pgHaiXiao.value = 1; pgHaiXiaoValue = 1; InvokeRepeating("HaiXiaoEffect", 2f, 10f / 100); } } } if (!bHaiXiaoEffect) { pgHaiXiao.value = _dataPlayer.mEnergy * 1.0f / _EnergyFull; } // //WG.SLog("WhenBearKilled======="+SDK.Serialize(mBear.death_reward)); for (int i = 0, max = mBear.death_reward.Count; i < max; i++) { _ShareWorld.AddReward(mBear.death_reward[i]); } if (bMiao && mBear.additional != null && mBear.additional.Count > 0) { for (int i = 0, max = mBear.additional.Count; i < max; i++) { _ShareWorld.AddReward(mBear.additional[i]); } } if (mBear.tiger == 1) { WGGameTiger.Instance.StartTiger(); } }