public void DestroyPrimitive(IRenderPrimitive primitive) { //var wpfRenderPrimitive = primitive as WPFRenderPrimitive; //if (wpfRenderPrimitive != null) if (primitive is WPFRenderPrimitive wpfRenderPrimitive) { WpfCanvas.Children.Remove(wpfRenderPrimitive.WpfImage); primitives.Remove(wpfRenderPrimitive); } }
public void OnTick(float dt, IRenderPrimitive SourcePrimitive) { time += dt; if (time >= Speed) { SetImageByIndex((currentIndex + 1) % ImageCount, SourcePrimitive); time -= Speed; } }
public void DestroyPrimitive(IRenderPrimitive primitive) { // проверяет, что primitive типа WPFRenderPrimitive // и кастует сразу же к нему if (primitive is WPFRenderPrimitive wpfRenderPrimitive) { WpfCanvas.Children.Remove(wpfRenderPrimitive.WpfImage); primitives.Remove(wpfRenderPrimitive); } }
public override void OnAttachToWorld() { if (World.RenderManager != null) { RenderPrimitive = World.RenderManager.CreatePrimitive(); RenderPrimitive.Size = Size; RenderPrimitive.Position = Position; RenderPrimitive.ImageName = ImageName; } }
// тут просто захардкожено добавление физических моделей к определённым ячейкам public void AddPhysicsModel(IRenderPrimitive initPrimitive) { var cellWithPhysics = new MapObject { Position = initPrimitive.Position, Size = initPrimitive.Size }; var PhysicModel = new PhysicsSphere { IsSatatic = true, Radius = cellWithPhysics.Size.Length() / 2.0f, MapObject = cellWithPhysics }; World.PhysicsManager.Models.Add(PhysicModel); }
public void SetImageByIndex(int index, IRenderPrimitive SourcePrimitive) { currentIndex = index; SourcePrimitive.ImageName = string.Format(PathMask, index + 1); }