public override void OnCollision(CGameObject pObj) { if (pObj.ObjType == EGameObjectType.GotAsteroid) { _pObjMan.AddObject(new CExplo(_pObjMan, _pEngineCore, _stPos, _fSize)); _pObjMan.RemoveObject(this); } }
// collision with shot is fatal public override void OnCollision(CGameObject pObj) { if (pObj.ObjType != EGameObjectType.GotShot && pObj.ObjType != EGameObjectType.GotPlayer) return; // spawn little children asteroids if (_fSize > 25f) { uint count = (uint)(2 + Rand.Next(3)); for (int i = 0; i < count; i++) { _pObjMan.AddObject(new CAsteroid(_pObjMan, _pEngineCore, new TPoint2(_stPos.x - _fSize / 4f + Rand.Next((int)(_fSize / 2f)), _stPos.y - _fSize / 4f + Rand.Next((int)(_fSize / 2f))), _fSize * 0.5f)); } } _pObjMan.AddObject(new CExplo(_pObjMan, _pEngineCore, _stPos, _fSize)); _pObjMan.AddObject(new CScorePopup(_pObjMan, _pEngineCore, _stPos, _fSize, (uint)(_fSize * 5))); _pObjMan.RemoveObject(pObj); _pObjMan.RemoveObject(this); }
// collision with shot is fatal public override void OnCollision(CGameObject pObj) { if (pObj.ObjType != EGameObjectType.GotShot && pObj.ObjType != EGameObjectType.GotPlayer) { return; } // spawn little children asteroids if (_fSize > 25f) { uint count = (uint)(2 + Rand.Next(3)); for (int i = 0; i < count; i++) { _pObjMan.AddObject(new CAsteroid(_pObjMan, _pEngineCore, new TPoint2(_stPos.x - _fSize / 4f + Rand.Next((int)(_fSize / 2f)), _stPos.y - _fSize / 4f + Rand.Next((int)(_fSize / 2f))), _fSize * 0.5f)); } } _pObjMan.AddObject(new CExplo(_pObjMan, _pEngineCore, _stPos, _fSize)); _pObjMan.AddObject(new CScorePopup(_pObjMan, _pEngineCore, _stPos, _fSize, (uint)(_fSize * 5))); _pObjMan.RemoveObject(pObj); _pObjMan.RemoveObject(this); }
public void RemoveObject(CGameObject pObj) { _clRemovePendingList.Add(pObj); }
public void AddObject(CGameObject pObj) { _clObjects.Add(pObj); }
public virtual void OnCollision(CGameObject pObj) { }
public virtual bool CollisionCheck(CGameObject pObjWith) { return(_stPos.DistTo(pObjWith._stPos) < _fSize / 2f * _fColScale + pObjWith._fSize / 2f * pObjWith._fColScale); }
public virtual bool CollisionCheck(CGameObject pObjWith) { return _stPos.DistTo(pObjWith._stPos) < _fSize / 2f * _fColScale + pObjWith._fSize / 2f * pObjWith._fColScale; }