Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
                }
            };
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public CollisionEventArgs(ASolid solid)
 {
     this.solid = solid;
 }
Ejemplo n.º 6
0
 public AHitbox(ASolid parent)
 {
     this.Parent = parent;
 }
Ejemplo n.º 7
0
 public void Add(ASolid gameObject)
 {
     this.GameSolids.Add(gameObject);
 }
Ejemplo n.º 8
0
 public PhysicBody(ASolid solid)
 {
     this.Forces = new List <IForce>();
     this.Solid  = solid;
 }
Ejemplo n.º 9
0
 abstract public void Update(ASolid solid);
Ejemplo n.º 10
0
 public CollisionEventArgs(ASolid solid, IForce force)
 {
     this.Solid = solid;
     this.Force = force;
 }