📄 gameobject_blast1.cs
字号:
using System;
using System.Reflection;
using Microsoft.DirectX.DirectInput;
using DDGameHelper;
namespace ddt2
{
/// <summary>
/// GameObject_Blast1 的摘要说明。
/// </summary>
public class GameObject_Blast1 : GameObject
{
/// <summary>
/// 同类型的GameObj计数器(主要作用于资源管理。当 counter > 0 时,即便调用 dispose 也不释放 resource)
/// </summary>
private static int _counter = 0;
/// <summary>
/// 指向 BmpRectCombo Collection 的 索引
/// </summary>
private static int _indexOfBmpRectComboCollection = 0;
public override int IndexOfBmpRectComboCollection()
{
return _indexOfBmpRectComboCollection;
}
public override string Name()
{
return _type.ToString();
}
public override object Properties()
{
return null;
}
private static GameObject_Enum _type = GameObject_Enum.Blast1;
public override int Type()
{
return (int)_type;
}
public GameObject_Blast1(double x, double y, double velX, double velY, double velF, ref GameLoopHandler gameLoopHandler) : base(ref gameLoopHandler)
{
BmpRectCombo brc=((BmpRectCombo)_bmpRectComboCollection[_indexOfBmpRectComboCollection]);
_velF = velF;
_x=x; _y=y;
_velX=velX; _velY=velY;
_lastF = brc.RectangleArray.Rectangles.Length - 1;
_currF = 0;
_currT = 0.0;
BlastSound();
}
protected override void Init()
{
LoadResource();
}
protected override void LoadResource()
{
_counter++;
if(_counter==1)
{
BitmapObject bo = new BitmapObject(BitmapDisplayType.Transparent, GameSettings.GetResourceStream("ddt2.Resource.Picture.blast1.png"));
RectangleArray ra = new RectangleArray(bo.Size.Width, bo.Size.Height, 54, 54, 0);
DDHandler d=_glh.DDHandler;
_indexOfBmpRectComboCollection = _bmpRectComboCollection.Add(new BmpRectCombo(ref bo, ref ra, ref d));
}
}
protected override void UnloadResource()
{
_counter--;
if(_counter==0)
{
_bmpRectComboCollection[_indexOfBmpRectComboCollection] = null;
}
}
public override void Process()
{
//frame播放
_currT += _glh.LoopDuration;
if (_currT > _velF)
{
_currT -= _velF;
_currF += 1;
if (_currF > _lastF)
{
_currF = _lastF;
_isalive = false;
}
}
}
public override void Process(ref Microsoft.DirectX.DirectInput.KeyboardState ks)
{
}
public void BlastSound()
{
_glh.DSHandler.Stop();
_glh.DSHandler.LoadSoundFile(GameSettings.GetResourceStream("ddt2.Resource.Sound.blast1.wav"));
_glh.DSHandler.Play();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -