public Game(GameWindow gameWindow, float frameRate) { this.camera = new FPVCamera(new Vector3(0, 0, 0), 1f); this.EntityManager = new EntityManager(); spider = ObjLoader.ObjLoader.LoadObj(@"C:\Users\majda\source\repos\SharpEngine-Core\SharpEngine-Core\TestModels\Spider\", "spider.obj", new Vector3(-100, 0, 0), this.EntityManager); spider.PhysicBody.RigidBody = new RigidBody(10f, spider.PhysicBody); var spider2 = ObjLoader.ObjLoader.LoadObj(@"C:\Users\majda\source\repos\SharpEngine-Core\SharpEngine-Core\TestModels\Spider\", "spider.obj", new Vector3(200, 0, 0), this.EntityManager); spider2.PhysicBody.RigidBody = new RigidBody(10f, spider.PhysicBody); spider.OnCollision += (o, e) => { e.Solid.Pos += new Vector3(200, 0, 0); }; EntityManager.Add(spider); EntityManager.Add(spider2); this.GW = gameWindow; this.FrameRate = frameRate; this.KeyboardProcessor = new KeyboardProcessor(this.GW); this.MouseProcessor = new MouseProcessor(this.GW); }
public ASolid CheckCollisionsFor(ASolid solid) { foreach (IEntity entity in this.Entities) { if (entity != solid && entity is ASolid) { if (solid.CheckCollide(entity as ASolid)) { return(entity as ASolid); } } } return(null); }
public RigidBody(float weight, PhysicBody physicBody) { this.PhysicBody = physicBody; this.Weight = weight; this.PhysicBody.Solid.OnCollision += (o, e) => { ASolid sender = o as ASolid; if (e.Solid.PhysicBody.RigidBody != null) { e.Force.IsActive = false; } }; }
public Hitbox(Face3[] faces, ASolid parent) : base(parent) { if (faces != null) { float left = faces[0].vertices[0].X; float right = faces[0].vertices[0].X; float top = faces[0].vertices[0].Y; float bottom = faces[0].vertices[0].Y; float close = faces[0].vertices[0].Z; float distant = faces[0].vertices[0].Z; foreach (Face3 face in faces) { foreach (Vector3 vertex in face.vertices) { if (vertex.X > left) { left = vertex.X; } if (vertex.X < right) { right = vertex.X; } if (vertex.Y > top) { top = vertex.Y; } if (vertex.Y < bottom) { bottom = vertex.Y; } if (vertex.Z < close) { close = vertex.Z; } if (vertex.Z > distant) { distant = vertex.Z; } } } this.First = new Vector3(left, bottom, close); this.Second = new Vector3(right, top, distant); } }
public CollisionEventArgs(ASolid solid) { this.solid = solid; }
public AHitbox(ASolid parent) { this.Parent = parent; }
public void Add(ASolid gameObject) { this.GameSolids.Add(gameObject); }
public PhysicBody(ASolid solid) { this.Forces = new List <IForce>(); this.Solid = solid; }
abstract public void Update(ASolid solid);
public CollisionEventArgs(ASolid solid, IForce force) { this.Solid = solid; this.Force = force; }