예제 #1
0
    //Used to set two rooms as neighbours
    void setNeighbour(int i, RoomComponent neighbour, Enums.Direction direction)
    {
        switch (direction)
        {
        case Enums.Direction.NORTH:
            rooms[i].topNeighbour     = neighbour;
            neighbour.bottomNeighbour = rooms[i];
            break;

        case Enums.Direction.EAST:
            rooms[i].rightNeighbour  = neighbour;
            neighbour.leftNeihghbour = rooms[i];
            break;

        case Enums.Direction.SOUTH:
            rooms[i].bottomNeighbour = neighbour;
            neighbour.topNeighbour   = rooms[i];
            break;

        case Enums.Direction.WEST:
            rooms[i].leftNeihghbour  = neighbour;
            neighbour.rightNeighbour = rooms[i];
            break;
        }
    }
예제 #2
0
 // Called when a warp is selected from the WarpEditor
 void OnWarpSelected(object sender, EventArgs args)
 {
     foreach (RoomComponent com in roomComponents)
     {
         Warp warp;
         if (com is WarpSourceRoomComponent)
         {
             warp = (com as WarpSourceRoomComponent).warp;
         }
         else if (com is WarpDestRoomComponent)
         {
             warp = (com as WarpDestRoomComponent).warp;
         }
         else
         {
             continue;
         }
         if (WarpEditor.SelectedWarp == warp)
         {
             selectedComponent = com;
             break;
         }
     }
     QueueDraw();
 }
예제 #3
0
    private void addExit(RoomComponent room)
    {
        DoorTile exit = DoorTile.CreateInstance <DoorTile>();

        exit.direction = Enums.Direction.DOWN;
        room.addDoor(exit);
    }
 public virtual void OnRoomExited(RoomComponent room)
 {
     if (room == _roomComponent)
     {
         _roomComponent = null;
     }
 }
예제 #5
0
    public void lockDoors(List <RoomComponent> rooms)
    {
        int numOfRooms = rooms.Count - 1;
        int roomToLock = (int)RNGenerator.Instance.getNextNumber(0, numOfRooms);

        while (roomToLock == 0 || rooms[roomToLock].getDirections().Count != 1)
        {
            roomToLock = (int)RNGenerator.Instance.getNextNumber(0, numOfRooms);
        }

        int direction = rooms[roomToLock].getDirections()[0];

        RoomComponent room = rooms[roomToLock];

        RoomComponent lockedOut = room.getNeighbour(direction);

        DoorTile lockedDoor = DoorTile.CreateInstance <DoorTile>();

        lockedDoor.direction = lockedOut.findDirection(room);

        lockedDoor.locked = true;

        lockedOut.addDoor(lockedDoor);

        placeKeys(1, numOfRooms, roomToLock, direction, rooms, room);

        addExit(room);
    }
예제 #6
0
    //Main method to build rooms
    //Gets called by the DungeonMaster
    public void buildRoom(RoomComponent roomData, Enums.Direction direction, List <GameObject> activeMonsters)
    {
        //Clear all tilemaps before drawing
        clearRoom();
        currentRoom = roomData;
        drawFloor();
        drawWalls();

        createDoorData(roomData.getDirections().Count);

        insertMissingDoors();

        buildDoors();

        if (!builtRooms.Contains(currentRoom.getRoomNumber()))
        {
            builtRooms.Add(currentRoom.getRoomNumber());
        }

        if (currentRoom.getKey())
        {
            currentRoom.getKey().SetActive(true);
        }

        spawnMonster(activeMonsters);

        minimap.drawRoom(currentRoom, direction);
    }
예제 #7
0
파일: Minimap.cs 프로젝트: schreibd/PPDG
    //Used to paint a rectangle representing a room on UI Panel
    public void drawRoom(RoomComponent roomData, Enums.Direction fromDirection)
    {
        float localX = 0.0f;
        float localY = 0.0f;

        Rect roomPosition;

        if (visitedRooms.Count == 0)
        {
            localX              = minimap.transform.position.x - width / 2;
            localY              = Screen.height - minimap.transform.position.y - height / 2;
            roomPosition        = new Rect(localX, localY, width, height);
            roomPosition.width  = width;
            roomPosition.height = height;
            roomData.setMinimapPosition(roomPosition);
            visitedRooms.Add(roomData);
        }
        else if (!visitedRooms.Contains(roomData))
        {
            localX += currentRoom.getMinimapPosition().x;
            localY += currentRoom.getMinimapPosition().y;

            switch (fromDirection)
            {
            case Enums.Direction.NORTH:
                roomPosition        = new Rect(localX, localY - height - 5, width, height);
                roomPosition.width  = width;
                roomPosition.height = height;
                roomData.setMinimapPosition(roomPosition);
                break;

            case Enums.Direction.EAST:
                roomPosition        = new Rect(localX + width + 5, localY, width, height);
                roomPosition.width  = width;
                roomPosition.height = height;
                roomData.setMinimapPosition(roomPosition);
                break;

            case Enums.Direction.SOUTH:
                roomPosition        = new Rect(localX, localY + height + 5, width, height);
                roomPosition.width  = width;
                roomPosition.height = height;
                roomData.setMinimapPosition(roomPosition);
                break;

            case Enums.Direction.WEST:
                roomPosition        = new Rect(localX - width - 5, localY, width, height);
                roomPosition.width  = width;
                roomPosition.height = height;
                roomData.setMinimapPosition(roomPosition);
                break;
            }
            visitedRooms.Add(roomData);
            currentRoom = roomData;
        }

        currentRoom = roomData;
    }
예제 #8
0
    public void AddComponent(RoomComponent component)
    {
        components.Add(component);

        if (component.isRoomPart)
        {
            PlaceComponent(component);
        }
    }
        private void Awake()
        {
            Assert.IsNotNull(overlay);
            Assert.IsNotNull(deletionTarget);
            Assert.IsNotNull(tileType);

            roomComp = GetComponent <RoomComponent>();
            Assert.IsNotNull(roomComp);
        }
예제 #10
0
        // Methods

        public void SetRoom(Room r, int season, bool changedFromWarpFollow = false)
        {
            if (r == Room && this.season == season)
            {
                return;
            }

            if (room != null)
            {
                RoomLayout.LayoutModifiedEvent -= OnLayoutModified;
                room.GetObjectGroup().RemoveModifiedHandler(OnObjectModified);
                room.GetWarpGroup().RemoveModifiedHandler(OnWarpModified);
            }

            room = r;
            if (season != -1)
            {
                this.season = season;
            }

            if (room != null)
            {
                RoomLayout.LayoutModifiedEvent += OnLayoutModified;
                room.GetObjectGroup().AddModifiedHandler(OnObjectModified);
                room.GetWarpGroup().AddModifiedHandler(OnWarpModified);

                Width  = room.Width;
                Height = room.Height;

                ObjectGroupEditor.SetObjectGroup(room.GetObjectGroup());
            }

            if (r == null)
            {
                EditingWarpDestination = null;
            }

            GenerateRoomComponents();
            selectedComponent = null;

            if (EditingWarpDestination != null)
            {
                EditingWarpDestination.DestRoom = r;
            }

            roomEventWrapper.ReplaceEventSource(room);
            UpdateChestEvents();

            RoomChangedEvent?.Invoke(this,
                                     new RoomChangedEventArgs {
                room = r, fromFollowWarp = changedFromWarpFollow
            });

            QueueDraw();
        }
예제 #11
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            base.DrawBackground(cr);

            cr.Save();

            cr.Translate(XOffset, YOffset);
            cr.Scale(Scale, Scale);

            hoveringComponent = null;

            foreach (RoomComponent com in roomComponents)
            {
                cr.SetSourceColor(com.BoxColor);
                cr.Rectangle(com.BoxRectangle);
                cr.Fill();
                com.Draw(cr);

                if (DrawRoomComponentHover)
                {
                    if (CairoHelper.PointInRect(mouseX, mouseY, com.BoxRectangle))
                    {
                        hoveringComponent = com;
                    }
                }
            }

            if (SelectRoomComponents)
            {
                // Object hovering over
                if (hoveringComponent != null)
                {
                    cr.SetSourceColor(ObjectHoverColor);
                    CairoHelper.DrawRectOutline(cr, 1, hoveringComponent.BoxRectangle);
                }
                // Object selected
                if (selectedComponent != null)
                {
                    cr.SetSourceColor(TileGridViewer.DefaultSelectionColor);
                    CairoHelper.DrawRectOutline(cr, 1, selectedComponent.BoxRectangle);
                }
            }

            cr.Restore();

            if (DrawTileHover)
            {
                base.DrawHoverAndSelection(cr);
            }

            return(true);
        }
예제 #12
0
    private void UpdateRoomState(RoomComponent roomComponent)
    {
        roomComponent.User1NameText.text       = WaitingToJoinStr;
        roomComponent.User1TotalCountText.text = TotalCountStr + 0;
        roomComponent.User1WinCountText.text   = WinCountStr + 0;
        roomComponent.User2NameText.text       = WaitingToJoinStr;
        roomComponent.User2TotalCountText.text = TotalCountStr + 0;
        roomComponent.User2WinCountText.text   = WinCountStr + 0;

        foreach (var entity in UserComponents.Entities)
        {
            var userComponent = entity.GetComponent <UserComponent>();

            if (userComponent.IsRoomOwner.Value)
            {
                userComponent.UserName.DistinctUntilChanged().Where(_ => roomComponent.User1NameText).Subscribe(name =>
                {
                    roomComponent.User1NameText.text = name;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);

                userComponent.TotalCount.DistinctUntilChanged().Where(_ => roomComponent.User1TotalCountText).Subscribe(count =>
                {
                    roomComponent.User1TotalCountText.text = TotalCountStr + count;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);

                userComponent.WinCount.DistinctUntilChanged().Where(_ => roomComponent.User1WinCountText).Subscribe(count =>
                {
                    roomComponent.User1WinCountText.text = WinCountStr + count;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);
            }
            else if (UserComponents.Entities.Count > 1)
            {
                userComponent.UserName.DistinctUntilChanged().Where(_ => roomComponent.User2NameText).Subscribe(name =>
                {
                    roomComponent.User2NameText.text = name;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);

                userComponent.TotalCount.DistinctUntilChanged().Where(_ => roomComponent.User2TotalCountText).Subscribe(count =>
                {
                    roomComponent.User2TotalCountText.text = TotalCountStr + count;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);

                userComponent.WinCount.DistinctUntilChanged().Where(_ => roomComponent.User2WinCountText).Subscribe(count =>
                {
                    roomComponent.User2WinCountText.text = WinCountStr + count;
                }).AddTo(this.Disposer).AddTo(roomComponent.Disposer).AddTo(userComponent.Disposer);
            }
        }
    }
예제 #13
0
        private CorridorComponent CreateCorridor(RoomComponent room, BoardComponent board, ref Unity.Mathematics.Random random, int forceDirection)
        {
            var direction = (Direction)forceDirection;

            var corridorLength = random.NextInt(board.MinCorridorLength, board.MaxCorridorLength);
            var corridorX      = 0;
            var corridorY      = 0;

            var maxLength = board.MaxCorridorLength;

            switch (direction)
            {
            case Direction.Up:
                corridorX = random.NextInt(room.X, room.X + room.Size.x);
                corridorY = room.Y + room.Size.y - 2;
                maxLength = board.Size.y - 2 - corridorY;
                break;

            case Direction.Left:
                corridorX = room.X + room.Size.x - 2;
                corridorY = random.NextInt(room.Y, room.Y + room.Size.y);
                maxLength = board.Size.x - 2 - corridorX;
                break;

            case Direction.Down:
                corridorX = random.NextInt(room.X, room.X + room.Size.x + 1);
                corridorY = room.Y;
                maxLength = corridorY - 2;
                break;

            case Direction.Right:
                corridorX = room.X;
                corridorY = random.NextInt(room.Y, room.Y + room.Size.y + 1);
                maxLength = corridorX - 2;
                break;
            }

            corridorLength = math.clamp(corridorLength, 0, maxLength);

            return(new CorridorComponent
            {
                StartX = corridorX,
                StartY = corridorY,
                Length = corridorLength,
                Direction = direction
            });
        }
예제 #14
0
        void OnDragged(int x, int y, Gdk.Event triggerEvent)
        {
            if (EnableTileEditing && draggingTile)
            {
                if (IsInBounds(x, y, scale: false, offset: false))
                {
                    Cairo.Point p = GetGridPosition(x, y, scale: false, offset: false);
                    RoomLayout.SetTile(p.X, p.Y, TilesetViewer.SelectedIndex);
                }
            }
            if (DrawRoomComponents && draggingObject)
            {
                RoomComponent com = selectedComponent;
                if (com != null && com.HasXY)
                {
                    int newX, newY;
                    if (gdkState.HasFlag(Gdk.ModifierType.ControlMask) || com.HasShortenedXY)
                    {
                        newX = x;
                        newY = y;
                    }
                    else
                    {
                        // Move comects in increments of 8 pixels
                        int unit    = 8;
                        int unitLog = (int)Math.Log(unit, 2);

                        int dataX  = com.X + unit / 2;
                        int dataY  = com.Y + unit / 2;
                        int alignX = (dataX) % unit;
                        int alignY = (dataY) % unit;
                        newX = (x - alignX) >> unitLog;
                        newY = (y - alignY) >> unitLog;
                        newX = newX * unit + alignX + unit / 2;
                        newY = newY * unit + alignY + unit / 2;
                    }

                    if (newX >= 0 && newX < 256 && newY >= 0 && newY < 256)
                    {
                        com.X = (byte)newX;
                        com.Y = (byte)newY;
                    }

                    QueueDraw();
                }
            }
        }
예제 #15
0
 public void delete(UpdateRoomRequest request)
 {
     try
     {
         var response = new UpdateRoomResponse();
         var bc       = new RoomComponent();
         bc.Update(request.Room);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
예제 #16
0
 public GetRoomResponse getById(GetRoomRequest request)
 {
     try
     {
         var response = new GetRoomResponse();
         var bc       = new RoomComponent();
         response.Result = bc.Find(request.Room.Id);
         return(response);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
예제 #17
0
        public AllRoomsResponse getAll()
        {
            try
            {
                var response = new AllRoomsResponse();
                var bc       = new RoomComponent();
                response.Result = bc.ToList();

                return(response);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };
                throw new HttpResponseException(httpError);
            }
        }
예제 #18
0
 // Called when an object is selected in the ObjectGroupEditor
 public void OnObjectSelected()
 {
     if ((selectedComponent as ObjectRoomComponent)?.obj != ObjectGroupEditor.SelectedObject)
     {
         selectedComponent = null;
         foreach (RoomComponent com in roomComponents)
         {
             if (!(com is ObjectRoomComponent))
             {
                 continue;
             }
             var objCom = com as ObjectRoomComponent;
             if (objCom.obj.ObjectGroup == ObjectGroupEditor.SelectedObjectGroup &&
                 objCom.obj.Index == ObjectGroupEditor.SelectedIndex)
             {
                 selectedComponent = objCom;
                 break;
             }
         }
         QueueDraw();
     }
 }
예제 #19
0
    //Finds the direction from which the neighbour of the actual room is reachable
    public Enums.Direction findDirection(RoomComponent neighbour)
    {
        Enums.Direction result = Enums.Direction.DEADEND;

        if (neighbour == topNeighbour)
        {
            result = Enums.Direction.NORTH;
        }
        else if (neighbour == rightNeighbour)
        {
            result = Enums.Direction.EAST;
        }
        else if (neighbour == bottomNeighbour)
        {
            result = Enums.Direction.SOUTH;
        }
        else if (neighbour == leftNeihghbour)
        {
            result = Enums.Direction.WEST;
        }

        return(result);
    }
예제 #20
0
    //Gets the neighbour in parameterized direction
    public RoomComponent getNeighbour(int direction)
    {
        RoomComponent neighbour = null;

        switch ((Enums.Direction)direction)
        {
        case Enums.Direction.NORTH:
            neighbour = topNeighbour;
            break;

        case Enums.Direction.EAST:
            neighbour = rightNeighbour;
            break;

        case Enums.Direction.SOUTH:
            neighbour = bottomNeighbour;
            break;

        case Enums.Direction.WEST:
            neighbour = leftNeihghbour;
            break;
        }
        return(neighbour);
    }
예제 #21
0
파일: Minimap.cs 프로젝트: schreibd/PPDG
    public int calcYPos(RoomComponent room, Enums.Direction direction)
    {
        int yPos = 999;

        switch (direction)
        {
        case Enums.Direction.NORTH:
            yPos = room.getYPos() + 1;
            break;

        case Enums.Direction.EAST:
            yPos = room.getYPos();
            break;

        case Enums.Direction.SOUTH:
            yPos = room.getYPos() - 1;
            break;

        case Enums.Direction.WEST:
            yPos = room.getYPos();
            break;
        }
        return(yPos);
    }
예제 #22
0
파일: Minimap.cs 프로젝트: schreibd/PPDG
    public int calcXPos(RoomComponent room, Enums.Direction direction)
    {
        int xPos = 0;

        switch (direction)
        {
        case Enums.Direction.NORTH:
            xPos = room.getXPos();
            break;

        case Enums.Direction.EAST:
            xPos = room.getXPos() + 1;
            break;

        case Enums.Direction.SOUTH:
            xPos = room.getXPos();
            break;

        case Enums.Direction.WEST:
            xPos = room.getXPos() - 1;
            break;
        }
        return(xPos);
    }
예제 #23
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();

            CharacterSelectionScreen = new CharacterSelectionScreen(graphics, this);

            LevelManager = new LevelManager(this);

            base.Initialize();
        }
예제 #24
0
    private void placeKeys(int keys, int numOfRooms, int roomToLock, int direction, List <RoomComponent> rooms, RoomComponent room)
    {
        int keyRoom = (int)RNGenerator.Instance.getNextNumber(0, numOfRooms);

        while (keyRoom == roomToLock || keyRoom == 0 || keyRoom == room.getNeighbour(direction).getRoomNumber())
        {
            keyRoom = (int)RNGenerator.Instance.getNextNumber(0, numOfRooms);
        }

        GameObject key = Instantiate(Resources.Load("Key", typeof(GameObject))) as GameObject;

        key.SetActive(false);
        rooms[keyRoom].addKey(key);
    }
예제 #25
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
예제 #26
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();

            //TurretComponent = new TurretComponent();
            //TrapComponent = new TrapComponent();
            //PortableShopComponent = new PortableShopComponent();
            //PortableShieldComponent = new PortableShieldComponent();
            //MotivateComponent =  new MotivateComponent();
            //FallbackComponent = new FallbackComponent();
            //ChargeComponent = new ChargeComponent();
            //HealingStationComponent = new HealingStationComponent();
            //ExplodingDroidComponent = new ExplodingDroidComponent();

            base.Initialize();
        }
예제 #27
0
 public override bool Compare(RoomComponent com)
 {
     return(obj == (com as ObjectRoomComponent)?.obj);
 }
예제 #28
0
 public override bool Compare(RoomComponent com)
 {
     return(warp == (com as WarpSourceRoomComponent)?.warp);
 }
예제 #29
0
 public abstract bool Compare(RoomComponent com); // Returns true if the underlying data is the same
예제 #30
0
        void GenerateRoomComponents()
        {
            if (Room == null)
            {
                return;
            }

            roomComponents    = new List <RoomComponent>();
            hoveringComponent = null;

            // We only draw the 1 component if we're editing a warp destination
            if (EditingWarpDestination != null)
            {
                WarpDestRoomComponent com = new WarpDestRoomComponent(this, EditingWarpDestination);
                com.SelectedEvent += (sender, args) => {
                    WarpEditor.SetSelectedWarp(com.warp);
                };
                roomComponents.Add(com);
                goto addedAllComponents; // I love being evil
            }

            if (ViewObjects && ObjectGroupEditor.TopObjectGroup != null)
            {
                foreach (ObjectGroup group in ObjectGroupEditor.TopObjectGroup.GetAllGroups())
                {
                    for (int i = 0; i < group.GetNumObjects(); i++)
                    {
                        ObjectDefinition obj = group.GetObject(i);
                        if (!obj.HasXY())
                        {
                            continue;
                        }
                        ObjectRoomComponent com = new ObjectRoomComponent(obj);
                        com.SelectedEvent += (sender, args) => {
                            ObjectGroupEditor.SelectObject(obj.ObjectGroup, obj.Index);
                        };
                        roomComponents.Add(com);
                    }
                }
            }

            if (ViewWarps)
            {
                int       index = 0;
                WarpGroup group = room.GetWarpGroup();

                foreach (Warp warp in group.GetWarps())
                {
                    Action <int, int, int, int> addWarpComponent = (x, y, width, height) => {
                        var rect = new Cairo.Rectangle(x, y, width, height);
                        var com  = new WarpSourceRoomComponent(this, warp, index, rect);
                        com.SelectedEvent += (sender, args) => {
                            WarpEditor.SetWarpIndex(com.index);
                        };
                        roomComponents.Add(com);
                    };

                    if (warp.WarpSourceType == WarpSourceType.Standard)
                    {
                        int middle;
                        if (Room.Width == 15) // Large room
                        {
                            middle = ((Room.Width + 1) / 2) * 16;
                        }
                        else // Small room
                        {
                            middle = ((Room.Width + 1) / 2) * 16 + 8;
                        }
                        int right  = Room.Width * 16;
                        int bottom = Room.Height * 16 - 8;

                        if (warp.TopLeft)
                        {
                            addWarpComponent(0, -8, middle, 16);
                        }
                        if (warp.TopRight)
                        {
                            addWarpComponent(middle, -8, right - middle, 16);
                        }
                        if (warp.BottomLeft)
                        {
                            addWarpComponent(0, bottom, middle, 16);
                        }
                        if (warp.BottomRight)
                        {
                            addWarpComponent(middle, bottom, right - middle, 16);
                        }

                        if (!warp.TopLeft && !warp.TopRight && !warp.BottomLeft && !warp.BottomRight)
                        {
                            addWarpComponent(0, 16 * 13, Room.Width * 16, 32);
                        }
                    }
                    else if (warp.WarpSourceType == WarpSourceType.Pointed)
                    {
                        addWarpComponent(warp.SourceX * TileWidth, warp.SourceY * TileHeight, TileWidth, TileHeight);
                    }
                    index++;
                }
            }

            if (ViewChests)
            {
                if (Room.Chest != null)
                {
                    ChestRoomComponent com = new ChestRoomComponent(Room.Chest);
                    roomComponents.Add(com);
                }
            }


addedAllComponents:
            // The "selectedComponent" now refers to an old object. Look for the corresponding new
            // object.
            RoomComponent newSelectedComponent = null;

            foreach (RoomComponent com in roomComponents)
            {
                if (com.Compare(selectedComponent))
                {
                    newSelectedComponent = com;
                    break;
                }
            }

            selectedComponent = newSelectedComponent;

            QueueDraw();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
예제 #32
0
 public override bool Compare(RoomComponent com)
 {
     return(chest == (com as ChestRoomComponent)?.chest);
 }
예제 #33
0
        void OnClicked(int posX, int posY, Gdk.Event triggerEvent, uint button)
        {
            Cairo.Point p = GetGridPosition(posX, posY, scale: false, offset: false);
            if (EnableTileEditing && hoveringComponent == null)
            {
                if (!IsInBounds(posX, posY, scale: false, offset: false))
                {
                    return;
                }
                if (button == 1)   // Left-click
                {
                    RoomLayout.SetTile(p.X, p.Y, TilesetViewer.SelectedIndex);
                    draggingTile = true;
                }
                else if (button == 3)   // Right-click
                {
                    TilesetViewer.SelectedIndex = RoomLayout.GetTile(p.X, p.Y);
                }
            }
            if (DrawRoomComponents)
            {
                if (hoveringComponent != null)
                {
                    selectedComponent = hoveringComponent;
                    hoveringComponent.Select();

                    if (button == 1)   // Left click
                    {
                        draggingObject = true;
                    }
                    else if (button == 3)   // Right click
                    {
                        Gtk.Menu menu = new Gtk.Menu();

                        foreach (Gtk.MenuItem item in selectedComponent.GetRightClickMenuItems())
                        {
                            menu.Add(item);
                        }

                        RoomComponent comp = selectedComponent;

                        if (comp.Deletable)
                        {
                            if (menu.Children.Length != 0)
                            {
                                menu.Add(new Gtk.SeparatorMenuItem());
                            }

                            var deleteButton = new Gtk.MenuItem("Delete");
                            deleteButton.Activated += (sender, args) => {
                                comp.Delete();
                            };
                            menu.Add(deleteButton);
                        }

                        menu.AttachToWidget(this, null);
                        menu.ShowAll();
                        menu.PopupAtPointer(triggerEvent);
                    }
                }
            }
            QueueDraw();
        }