Exemplo n.º 1
0
        void NewMapHandling(object sender, EventArgs e)
        {
            actorManager.Reset();
            List <Vector2> playerLocations = tileMap.GetLocationOfCodeValue("player");

            if (playerLocations.Count > 0)
            {
                foreach (Vector2 playerLocation in playerLocations)
                {
                    player = new Actors.Player(actorManager, tileMap, camera, playerLocation + new Vector2(16, 16), content.Load <Texture2D>(@"Textures/player"), 25.0f, 16, 16, 15, 15);
                    actorManager.AddPlayer(player);
                }
            }
            else
            {
                player = new Actors.Player(actorManager, tileMap, camera, new Vector2(16, 16), content.Load <Texture2D>(@"Textures/player"), 25.0f, 16, 16, 15, 15);
                actorManager.AddPlayer(player);
            }

            this.player = actorManager.GetNextPlayer();

            Dictionary <Vector2, int> actors = tileMap.GetActorsLocationAndID();

            foreach (KeyValuePair <Vector2, int> actor in actors)
            {
                StaticObject obj;
                if (actor.Value <= gateMapper.LastGateID)
                {
                    obj = new Gate(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value), gateMapper.IsGateEnabled(actor.Value));
                }
                else if (actor.Value == gateMapper.CoinID)
                {
                    obj = new Coin(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else if (actor.Value == gateMapper.HiddenWallID)
                {
                    obj = new HiddenWall(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else if (actor.Value == gateMapper.CloneBoxID)
                {
                    obj = new CloneBox(this.actorManager, this.particleManager, this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), content, tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                else
                {
                    obj = new Button(this.tileMap, this.camera, actor.Key, gateMapper.GetTextureByID(actor.Value), tileMap.SourceTileWidth, tileMap.SourceTileHeight, gateMapper.GetTagByID(actor.Value));
                }
                obj.CollisionRectangle   = gateMapper.GetCollisionRectangleByID(actor.Value, actor.Key);
                obj.InteractionRectangle = gateMapper.GetInteractionRectangleByID(actor.Value, actor.Key);

                actorManager.AddStaticObject(obj);
            }
        }
Exemplo n.º 2
0
 public void InteractsWithHiddenWall(Rectangle otherRectangle, MapObject interactionActor)
 {
     for (int i = 0; i < staticObjects.Count; i++)
     {
         if (staticObjects[i] is HiddenWall)
         {
             if (staticObjects[i].InteractionRectangle.Intersects(otherRectangle))
             {
                 HiddenWall hWall = (HiddenWall)staticObjects[i];
                 hWall.AddInteractionActor(interactionActor);
             }
         }
     }
 }