Example #1
0
    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);
    }
Example #2
0
    public override void use(CharacterOther player)
    {
        // 在角色当前位置放置一个地雷
        Vector3       curRot = player.getRotation();
        Vector3       dir    = MathUtility.getVectorFromAngle(curRot.y * Mathf.Deg2Rad);
        Vector3       pos    = player.getPosition() - dir * 2.0f;
        LandmineParam param  = new LandmineParam();

        param.mPosition = pos;
        SceneLandMine landmine = mItemManager.createItem <SceneLandMine>(SCENE_ITEM.SI_LAND_MINE, param);

        if (player.isType(CHARACTER_TYPE.CT_MYSELF))
        {
            GameTools.PLAY_AUDIO_OBJECT(landmine, SOUND_DEFINE.SD_PUT_LANDMINE);
        }
        // 使用后立即移除背包中的道具
        CommandCharacterRemoveItem cmdRemove = newCmd(out cmdRemove);

        cmdRemove.mItem = this;
        pushCommand(cmdRemove, player);
    }