Beispiel #1
0
 public void LoadMap(Game game, List <Library.Character.Name> playerinfo) // playerData
 {
     //Process data
     foreach (var mapObject in Data.Objects)
     {
         if (mapObject is CrystalSpawnData)
         {
             crystalSpawnList.Add((CrystalSpawnData)mapObject);
             if (crystalSpawnList[crystalSpawnList.Count - 1].IsStart)
             {
                 CrystalStartIndex = crystalSpawnList.Count - 1;
             }
         }
         else if (mapObject is PlayerStartData)
         {
             playerStartData.Add((PlayerStartData)mapObject);
         }
         else if (mapObject is BorderData)
         {
             TexturePolygon tmp = (TexturePolygon)mapObject.GetComponent(game, World);
             tmp.SetCollisionCategory(Category.All);
             tmp.SetCollideWithCategory(Category.All);
             SyncedGameCollection.ComponentCollection.Add(tmp);
         }
         else
         {
             SyncedGameCollection.ComponentCollection.Add(mapObject.GetComponent(game, World));
         }
     }
     SetupPlayers(playerinfo);
     SetupCrystal();
 }
Beispiel #2
0
        public Goal(Texture2D goalTexture, Texture2D borderTexture, Vector2 position, GoalDirections direction, DrawingHelper.DrawingLevel drawingLevel, Game game, World world)
            : base(game)
        {
            InnerCircle = new DummyCircle(position, ((goalTexture.Width / 2) / 2) / 2, game, world);
            InnerCircle.setOnCollisionFunction(OnCollision);
            InnerCircle.SetCollisionCategory(Category.Cat10);
            OuterCircle = new Circle(goalTexture, position, goalTexture.Width / 2, game, world);
            OuterCircle.RigidBody.CollisionCategories = Category.Cat9;
            //OuterCircle.setOnCollisionFunction(OnCollision);

            float   borderRotation = 0;
            Vector2 borderPosition = Vector2.Zero;

            #region direction cases
            switch (direction) // TODO: Add all directions.
            {
            case GoalDirections.North:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;

            case GoalDirections.NorthEast:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;

            case GoalDirections.East:
                borderRotation = 0;
                borderPosition = new Vector2((position.X + borderTexture.Width / 2) + 5.30973f, (position.Y) - 0.63129f);     // TODO: hardcoded offset
                break;

            case GoalDirections.SouthEast:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;

            case GoalDirections.South:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;

            case GoalDirections.SouthWest:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;

            case GoalDirections.West:
                borderRotation = (float)Math.PI;
                borderPosition = new Vector2((position.X - borderTexture.Width / 2) - 5.30973f, (position.Y) + 0.63129f);     // TODO: other solution for very specific offset for texture/vertice position
                break;

            case GoalDirections.NorthWest:
                borderRotation = 0;
                borderPosition = new Vector2(position.X + borderTexture.Width / 2, position.Y);
                break;
            }
            #endregion

            Border = new TexturePolygon(borderTexture, borderPosition, borderRotation, DrawingHelper.DrawingLevel.High, game, world, false);
            Border.SetCollisionCategory(Category.Cat10);
            Border.SetCollideWithCategory(Category.All);

            SyncedGameCollection.ComponentCollection.Add(OuterCircle);
            SyncedGameCollection.ComponentCollection.Add(InnerCircle);
            SyncedGameCollection.ComponentCollection.Add(Border);
        }