コード例 #1
0
ファイル: Player.cs プロジェクト: BigDogsGames/XNA-TrabM2
 public bool CheckForCollisions(Booster modelo)
 {
     for (int i = 0; i < model.Meshes.Count; i++)
     {
         BoundingSphere boundingSphere;
         boundingSphere.Radius = 0.6f;
         boundingSphere.Center = _position;
         for (int j = 0; j < modelo.model.Meshes.Count; j++)
         {
             BoundingSphere otherBoundingSphere = modelo.model.Meshes[j].BoundingSphere;
             otherBoundingSphere.Radius = 0.6f;
             otherBoundingSphere.Center = modelo.position;
             if (boundingSphere.Intersects(otherBoundingSphere))
                 return true;
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Game1.cs プロジェクト: BigDogsGames/XNA-TrabM2
        public void loadMap(char[][] map)
        {
            int rows = map.Length;
            int cols = map.Max(subArray => subArray.Length);

            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    if (map[i][j] == 'P')
                    {
                        Cube c = new Cube(new Vector3(j, 0.5f, i));
                        c.LoadContent(Content);
                        cubeMap.Add(c);
                    }
                    if (map[i][j] == 'I')
                    {
                        player.position = new Vector3(j, 0.5f, i);
                    }
                    if (map[i][j] == 'T')
                    {
                        Booster b = new Booster(new Vector3(j, 0.5f, i));
                        b.LoadContent(Content);
                        timeBoosters.Add(b);
                    }
                    if (map[i][j] == 'F')
                    {
                        finalBlock = new FinalBlock(new Vector3(j, 0.5f, i));
                        finalBlock.LoadContent(Content);
                    }
                }
            }
        }