public virtual void init(ItemParamBase param) { base.init(); if (param.mType != mType) { UnityUtility.logError("item param error!"); } }
// 延迟创建一个道具 public void createItemDelay(SCENE_ITEM type, float time, ItemParamBase param) { CommandSceneItemManagerCreateItem cmd = newCmd(out cmd, true, true); cmd.mParam = param; cmd.mItemType = type; pushDelayCommand(cmd, this, time); cmd.addStartCommandCallback(onCreateItemCmd, null); mDelayCreateList.Add(cmd.mAssignID); }
public override void init(ItemParamBase param) { base.init(param); LandmineParam landmineParam = param as LandmineParam; // 创建地雷模型并添加地雷脚本 createObject(GameDefine.R_SCENE_ITEM_PREFAB_PATH + GameDefine.LANDMINE, landmineParam.mPosition); UnityUtility.getGameObject(mObject, mExplodeParticleName, true).SetActive(false); UnityUtility.getGameObject(mObject, mLandmineModelName, true).SetActive(true); mLandMineComponent = mObject.GetComponent <LandmineObject>(); if (mLandMineComponent == null) { mLandMineComponent = mObject.AddComponent <LandmineObject>(); } mLandMineComponent.setItem(this); }
public override void init(ItemParamBase param) { base.init(param); MissileParam missileParam = param as MissileParam; // 创建导弹模型并添加导弹脚本 createObject(GameDefine.R_SCENE_ITEM_PREFAB_PATH + GameDefine.MISSILE, missileParam.mPosition); UnityUtility.getGameObject(mObject, mExplodeParticleName, true).SetActive(false); UnityUtility.getGameObject(mObject, mExplodeParticleName1, true).SetActive(false); UnityUtility.getGameObject(mObject, mMissileModelName, true).SetActive(true); mMissileComponent = mObject.GetComponent <MissileObject>(); if (mMissileComponent == null) { mMissileComponent = mObject.AddComponent <MissileObject>(); } mMissileComponent.setItem(this); ObjectTools.TRACK_TARGET(this, GameDefine.MISSILE_SPEED, missileParam.mTarget, Vector3.up); mTarget = missileParam.mTarget; }
// 创建一个道具 public SceneItemBase createItem(SCENE_ITEM type, ItemParamBase param) { if (!mItemRegisteList.ContainsKey(type)) { return(null); } SceneItemBase item = UnityUtility.createInstance <SceneItemBase>(mItemRegisteList[type], type); item.init(param); if (mItemList.ContainsKey(type)) { mItemList[type].Add(item); } else { List <SceneItemBase> itemList = new List <SceneItemBase>(); itemList.Add(item); mItemList.Add(type, itemList); } return(item); }
public override void init(ItemParamBase param) { base.init(param); ItemBoxParam boxParam = param as ItemBoxParam; // 创建道具箱子模型并添加脚本 createObject(GameDefine.R_SCENE_ITEM_PREFAB_PATH + GameDefine.ITEM_BOX, boxParam.mPosition); UnityUtility.getGameObject(mObject, mExplodeParticleName, true).SetActive(false); UnityUtility.getGameObject(mObject, mBoxModelNodeName, true).SetActive(true); mBoxObjectComponent = mObject.GetComponent <ItemBoxObject>(); if (mBoxObjectComponent == null) { mBoxObjectComponent = mObject.AddComponent <ItemBoxObject>(); } mBoxObjectComponent.setItem(this); // 播放箱子动画(并且设置播放的速度为0.5f) GameObject diXiangzi = UnityUtility.getGameObject(mObject, mBoxModelNodeName, true); Animation animation = diXiangzi.GetComponent <Animation>(); string animName = "idle"; animation.Play(animName); animation[animName].speed = 0.5f; }
public T createItem <T>(SCENE_ITEM type, ItemParamBase param) where T : SceneItemBase { return(createItem(type, param) as T); }
public override void init() { base.init(); mParam = null; mItemType = SCENE_ITEM.SI_MAX; }