/****************************************************************************
Copyright (c) 2011-2013,WebJet Business Division,CYOU
http://www.genesis-3d.com.cn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
using System;
using System.Runtime.CompilerServices;
using ScriptRuntime;
namespace ScriptRuntime
{
public enum SoundRollOffMode
{
Inverse = 0,
Linear = 1,
LinearSquare = 2,
}
///
/// 声音组件类,继承自组件类
/// 可以挂接到游戏对象上,控制对声音的操作
///
public partial class SoundSource : Component
{
///
/// 音源组件的组件类型
///
public static readonly System.Type thisType = typeof(SoundSource);
private SoundSource(DummyClass__ dummy)
{
}
///
/// 播放声音
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
actor.GetComponent().Play();
}
@endcode
*/
public void Play()
{
ICall_SoundSource_Play(this);
}
///
/// 停止播放声音
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
actor.GetComponent().Stop();
}
@endcode
*/
public void Stop()
{
ICall_SoundSource_Stop(this);
}
///
/// 暂停播放声音
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
actor.GetComponent().Pause();
}
@endcode
*/
public void Pause()
{
ICall_SoundSource_Pause(this);
}
///
/// 布尔值,声音否在播放中,播放中为true,否则为false
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
bool bIsPlaying = actor.GetComponent().IsPlaying;
actor.GetComponent().Play();
bIsPlaying = actor.GetComponent().IsPlaying;
}
@endcode
*/
public bool IsPlaying
{
get
{
return ICall_SoundSource_IsPlaying(this);
}
}
///
/// 布尔值,声音是否循环播放,若为循环播放为true,否则为false
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
actor.GetComponent().Play();
bool bLoop = actor.GetComponent().Loop;
}
@endcode
*/
public bool Loop
{
get
{
return ICall_SoundSource_GetLoop(this);
}
set
{
ICall_SoundSource_SetLoop(this, value);
}
}
///
/// 浮点型,音量
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
float fVolume = actor.GetComponent().Volume;
if (1.0f > fVolume)
{
actor.GetComponent().Volume = 1.0f;
}
}
@endcode
*/
public float Volume
{
get
{
return ICall_SoundSource_GetVolume(this);
}
set
{
ICall_SoundSource_SetVolume(this, value);
}
}
///
/// 枚举类型,声音衰减模式,可取:Inverse(0),Linear(1),LinearSquare(2)三种
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
SoundRollOffMode rollOffMode = actor.GetComponent().RollOffMode;
actor.GetComponent().RollOffMode = SoundRollOffMode.Linear;
}
@endcode
*/
public SoundRollOffMode RollOffMode
{
get
{
return (SoundRollOffMode)ICall_SoundSource_GetRolloffMode(this);
}
set
{
ICall_SoundSource_SetRolloffMode(this, (int)value);
}
}
///
///获得声音名字
///
/// 声音名字
public String GetSoundResID()
{
return ICall_SoundSource_GetName(this);
}
///
/// 重载函数,设置声音名字
///
/// 声音名字
/// 优先级
public void SetSoundResID(String name, int loadpriority)
{
ICall_SoundSource_SetName(this, name, loadpriority);
}
///
/// 重载函数,设置声音名字
///
/// 声音名字
public void SetSoundResID(String name)
{
int loadpriority = 0;
ICall_SoundSource_SetName(this, name, loadpriority);
}
///
/// 浮点值,音调
///
public float Pitch
{
get
{
return ICall_SoundSource_GetPitch(this);
}
set
{
ICall_SoundSource_SetPitch(this, value);
}
}
///
/// 布尔值,true为3D,false为2D
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
actor.GetComponent().Play();
bool bIs3D = actor.GetComponent().Is3D;
}
@endcode
*/
public bool Is3D
{
get
{
return ICall_SoundSource_Is3D(this);
}
set
{
ICall_SoundSource_Set3D(this, value);
}
}
///
/// 浮点值,声音最小距离
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
float fMinDistance = actor.GetComponent().MinDistance;
actor.GetComponent().MinDistance = 10;
}
@endcode
*/
public float MinDistance
{
get
{
return ICall_SoundSource_GetMinDistance(this);
}
set
{
ICall_SoundSource_SetMinDistance(this, value);
}
}
///
/// 浮点值,声音最大距离
///
/**@brief示例
*@code{.cpp}
Actor actor = ActorManager.FindActiveActor("sound");
if (null != actor)
{
float fMaxDistance = actor.GetComponent().MaxDistance;
actor.GetComponent().MaxDistance = 100;
}
@endcode
*/
public float MaxDistance
{
get
{
return ICall_SoundSource_GetMaxDistance(this);
}
set
{
ICall_SoundSource_SetMaxDistance(this, value);
}
}
///
/// 获得声音资源的优先级
///
/// 声音资源优先级,整型
public int GetLoadPriority()
{
return ICall_SoundSource_GetLoadPriority(this);
}
///
/// 判断声音资源是否被加载成功
///
/// 布尔值,true表示加载成功,false表示加载失败
public bool IsAllLoaded()
{
return ICall_SoundSource_IsAllLoaded(this);
}
}
}