Beispiel #1
0
 public void addEntity(model model)
 {
     if ((model is resource) && (resourceCount >= 3))
     {
         //for upgrading?
     }
     else if ((model is resource) && (resourceCount < 3))
     {
         resourceCount++;
         entities.Add(model);
     }
     else
     {
         entities.Add(model);
     }
 }
Beispiel #2
0
        public bool IsCollisionBox(model model2)
        {
            if (this is projectile)
            {
                for (int meshIndex1 = 0; meshIndex1 < ((projectile)this).collisionModel.Meshes.Count; meshIndex1++)
                {
                    BoundingBox box1 = UpdateBoundingBox(((projectile)this).collisionModel, this.getWorld());

                    for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                    {
                        BoundingBox box2 = UpdateBoundingBox(model2.getModel(), model2.getWorld());

                        if (box1.Intersects(box2))
                            return true;
                    }
                }
            }
            else
            {
                for (int meshIndex1 = 0; meshIndex1 < this.getModel().Meshes.Count; meshIndex1++)
                {

                    BoundingBox box1 = UpdateBoundingBox(this.getModel(), this.getWorld());

                    for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                    {
                        BoundingBox box2 = UpdateBoundingBox(model2.getModel(), model2.getWorld());

                        if (box1.Intersects(box2))
                            return true;
                    }
                }
            }
            return false;
        }
Beispiel #3
0
 public void removeEntity(model model)
 {
     entities.Remove(model);
 }
Beispiel #4
0
        public bool IsCollision(model model2)
        {
            for (int meshIndex1 = 0; meshIndex1 < this.getModel().Meshes.Count; meshIndex1++)
            {

                BoundingSphere sphere1 = this.getModel().Meshes[meshIndex1].BoundingSphere;
                sphere1 = sphere1.Transform(this.getWorld());

                for (int meshIndex2 = 0; meshIndex2 < model2.getModel().Meshes.Count; meshIndex2++)
                {
                    BoundingSphere sphere2 = model2.getModel().Meshes[meshIndex2].BoundingSphere;
                    sphere2 = sphere2.Transform(model2.getWorld());

                    if (sphere1.Intersects(sphere2))
                        return true;
                }
            }
            return false;
        }