コード例 #1
0
ファイル: LevelGenerator.cs プロジェクト: svinot/LJSM
    RoomParam CreateRoom(RoomIndex coordonates)
    {
        (List <TileParam> groundTilesParam, List <TileParam> outerWallTilesParam) = CreateBoard();
        List <Vector3Int> gridPositions = new List <Vector3Int>();

        InitialiseList(gridPositions);
        List <TileParam> wallTilesParam = LayoutTileAtRandom(gridPositions, wallTiles, wallCount.minimum, wallCount.maximum);
        //List<ObjectParam> objectsParam = LayoutObjectAtRandom(gridPositions, enemyTiles, 0, 2);
        List <UnitParam> unitsParam = LayoutUnitAtRandom(gridPositions, zombie1, 0, 1, UnitNature.Zombie1);//entre 0 et 2 enemies, provisoirement

        unitsParam.AddRange(LayoutUnitAtRandom(gridPositions, zombie2, 0, 1, UnitNature.Zombie2));
        unitsParam.AddRange(LayoutUnitAtRandom(gridPositions, zombie3, 0, 1, UnitNature.Zombie3));

        RoomParam roomParam = new RoomParam
        {
            coordonates         = coordonates,
            wallTilesParam      = wallTilesParam,
            outerWallTilesParam = outerWallTilesParam,
            groundTilesParam    = groundTilesParam,
            //objectsParam = objectsParam,
            unitsParam = unitsParam
        };

        return(roomParam);
    }
コード例 #2
0
 public Room(RoomParam _room)
 {
     this.RoomNumber     = _room.RoomNumber;
     this.RoomFacilities = _room.RoomFacilities;
     this.CreateDate     = DateTimeOffset.Now.LocalDateTime;
     this.CreateBy       = "";//isi
 }
コード例 #3
0
 public bool Update(int?id, RoomParam roomParam)
 {
     if (_roomRepository.Get(id) == null)
     {
         Console.WriteLine("Sorry, your data is not found");
         Console.Read();
     }
     else if (id.ToString() == " ")
     {
         Console.WriteLine("Don't insert white space");
         Console.Read();
     }
     else
     {
         if (roomParam.Name.ToString() == " ")
         {
             Console.WriteLine("Don't insert white space");
             Console.Read();
         }
         else
         {
             status = _roomRepository.Update(id, roomParam);
         }
     }
     return(status);
 }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: svinot/LJSM
    void InitGame()
    {
        surface = Instantiate(surfacePrefab);
        (levelRooms, connectedRooms) = levelGenerator.GenerateLevel();
        statManager.InitiateStats(levelRooms);
        gearManager.InitiateGears(levelRooms);
        currentRoomIndex = new RoomIndex {
            abs = 0, ord = 0
        };
        currentRoom = levelRooms[currentRoomIndex];
        map         = mapController.CreateMap(levelRooms, connectedRooms);
        map.SetActive(false);

        playerParam = new UnitParam
        {
            id         = 0,
            unitNature = UnitNature.Player,
            stat       = statManager.GenerateStat(UnitNature.Player),
            gear       = new Gear {
            }
        };

        roomGenerator.SetupRoom(currentRoom, playerSpawn);
        surface.BuildNavMesh();
    }
コード例 #5
0
 public virtual void Update(RoomParam _room)
 {
     this.RoomNumber     = _room.RoomNumber;
     this.RoomFacilities = _room.RoomFacilities;
     this.UpdateDate     = DateTimeOffset.Now.LocalDateTime;
     this.UpdateBy       = "";//isi
 }
コード例 #6
0
        //public RoomProcessor(IRoomDao dao, IRoomParamConverter paramConverter,
        //    IRoomResultConverter resultConverter)
        //{
        //    this.Dao = dao;
        //    this.ParamConverter = paramConverter;
        //    this.ResultConverter = resultConverter;
        //}

        public RoomResult Create(RoomParam param)
        {
            Model.Room entity = ParamConverter.Convert(param, null);

            entity = Dao.Save(entity);

            return(ResultConverter.Convert(entity));
        }
コード例 #7
0
        public bool Update(string id, RoomParam roomParam)
        {
            var put = Get(id);

            put.Name       = roomParam.Name;
            put.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            return(saveChange.save());
        }
コード例 #8
0
 public bool Insert(RoomParam roomParam)
 {
     room.Id         = roomParam.Id;
     room.Name       = roomParam.Name;
     room.CreateDate = DateTimeOffset.Now.LocalDateTime;
     myContext.Rooms.Add(room);
     return(saveChange.save());
 }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: svinot/LJSM
 void InitRoom()
 {
     surface     = Instantiate(surfacePrefab);
     currentRoom = GetNextRoom();
     mapController.UpdateMap(currentRoom);
     map.SetActive(false);
     roomGenerator.SetupRoom(currentRoom, playerSpawn);
     surface.BuildNavMesh();
 }
コード例 #10
0
    public void UpdateMap(RoomParam currentRoom)
    {
        Destroy(mapPlayer);
        float x = currentRoom.coordonates.abs * mapSizeParam + (width - 1) / 2;
        float y = currentRoom.coordonates.ord * mapSizeParam + (height - 1) / 2;

        mapPlayer = Instantiate(mapPlayerPrefab, new Vector3(x, y, 0f), Quaternion.identity);
        mapPlayer.transform.SetParent(dragableMap.transform, false);
        mapPlayer.transform.SetAsLastSibling();
    }
コード例 #11
0
        // POST: api/Rooms
        public HttpResponseMessage InsertRoom(RoomParam RoomParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter");
            var result  = _iRoomService.Insert(RoomParam);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added");
            }
            return(message);
        }
コード例 #12
0
 public bool Insert(RoomParam roomParam)
 {
     if (roomParam == null)
     {
         throw new NullReferenceException();
     }
     else
     {
         status = _roomRepository.Insert(roomParam);
     }
     return(status);
 }
コード例 #13
0
ファイル: LevelGenerator.cs プロジェクト: svinot/LJSM
    public int numberOfRooms = 5;//Dans un premier temps on impose le nombre de salle


    public (Dictionary <RoomIndex, RoomParam>, List <List <RoomIndex> >) GenerateLevel()
    {
        width          = GameManager.instance.width;
        height         = GameManager.instance.height;
        unitIdIterator = 0;

        Dictionary <RoomIndex, RoomParam> rooms = new Dictionary <RoomIndex, RoomParam>();
        List <RoomIndex>         openList       = new List <RoomIndex>();
        List <RoomIndex>         closedList     = new List <RoomIndex>();
        List <List <RoomIndex> > connectedRooms = new List <List <RoomIndex> >();//on garde en memoire les salles connectees entre elles par une porte
        RoomIndex startRoomCoord = new RoomIndex {
            abs = 0, ord = 0
        };

        openList.Add(startRoomCoord);

        for (int i = 0; i < numberOfRooms; i++)
        {
            int       randomIndex = Random.Range(0, openList.Count - 1);
            RoomIndex coordonates = openList[randomIndex];
            openList.Remove(coordonates);
            closedList.Add(coordonates);
            RoomParam roomParam = CreateRoom(coordonates);
            rooms.Add(coordonates, roomParam);

            foreach (RoomIndex coord in GetNeighbouringRooms(coordonates))
            {
                if (closedList.Contains(coord))
                {
                    if (Math.Abs((coordonates.abs - coord.abs) + (coordonates.ord - coord.ord)) == 1) //ie salles voisines
                    {
                        rooms = ConnectRooms(rooms, coord, coordonates);                              //on ouvre les portes entre les 2 salles
                        List <RoomIndex> list1 = new List <RoomIndex>();
                        list1.Add(coord);
                        list1.Add(coordonates);
                        List <RoomIndex> list2 = new List <RoomIndex>();
                        list2.Add(coord);
                        list2.Add(coordonates);
                        connectedRooms.Add(list1);
                        connectedRooms.Add(list2);
                    }
                    continue;
                }
                if (openList.Contains(coord) || closedList.Contains(coord))
                {
                    continue;
                }
                openList.Add(coord);
            }
        }
        return(rooms, connectedRooms);
    }
コード例 #14
0
        public void Update(long id, RoomParam param)
        {
            Model.Room oldEntity = Dao.Find(id);

            if (oldEntity != null)
            {
                Dao.Delete(oldEntity);
                Dao.Update(ParamConverter.Convert(param, null));
            }
            else
            {
                Console.WriteLine($"No entity with Id = {id}  was found");
            }
        }
コード例 #15
0
 public bool Insert(RoomParam roomParam)
 {
     if (roomParam.Name.ToString() == null)
     {
         Console.WriteLine("Please insert data");
     }
     else if (roomParam.Name.ToString() == " ")
     {
         Console.WriteLine("Don't insert white space");
     }
     else
     {
         status = _roomRepository.Insert(roomParam);
     }
     return(status);
 }
コード例 #16
0
        public bool Update(int?Id, RoomParam roomParam)
        {
            var  result  = 0;
            Room getRoom = Get(Id);

            getRoom.Name       = roomParam.Name;
            getRoom.Seat       = roomParam.Seat;
            getRoom.Cinemas    = myContext.Cinemas.Find(roomParam.Cinemas_Id);
            getRoom.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result             = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #17
0
 public void SaveUnitGear(RoomParam currentRoom, UnitParam playerParam, int unitId, Gear gear)
 {
     if (unitId != 0)
     {
         foreach (UnitParam unitParam in currentRoom.unitsParam)
         {
             if (unitParam.id == unitId)
             {
                 unitParam.gear = gear;
             }
         }
     }
     else
     {
         playerParam.gear = gear;
     }
 }
コード例 #18
0
ファイル: StatManager.cs プロジェクト: svinot/LJSM
 public void SaveUnitStats(RoomParam currentRoom, UnitParam playerParam, int unitId, FightingUnitStat unitStat)
 {
     if (unitId != 0)
     {
         foreach (UnitParam unitParam in currentRoom.unitsParam)
         {
             if (unitParam.id == unitId)
             {
                 unitParam.stat = unitStat;
             }
         }
     }
     else
     {
         playerParam.stat = unitStat;
     }
 }
コード例 #19
0
        public bool Insert(RoomParam roomParam)
        {
            var result = 0;

            room.Name       = roomParam.Name;
            room.Capacity   = roomParam.Capacity;
            room.Location   = roomParam.Location;
            room.CreateDate = DateTimeOffset.Now.LocalDateTime;
            _context.Rooms.Add(room);
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Insert Successfully");
            }
            return(status);
        }
コード例 #20
0
        public bool Insert(RoomParam roomParam)
        {
            var result = 0;

            room.Name       = roomParam.Name;
            room.Seat       = roomParam.Seat;
            room.Cinemas    = myContext.Cinemas.Find(roomParam.Cinemas_Id);
            room.CreateDate = DateTimeOffset.Now.LocalDateTime;
            room.IsDelete   = false;
            myContext.Rooms.Add(room);
            result = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #21
0
        public bool Update(string id, RoomParam roomParam)
        {
            if (id == null)
            {
                throw new NullReferenceException();
            }
            var get = Get(id);

            if (roomParam == null)
            {
                throw new NullReferenceException();
            }
            else
            {
                status = _roomRepository.Update(id, roomParam);
            }
            return(status);
        }
コード例 #22
0
        // PUT: api/Rooms/5
        public HttpResponseMessage UpdateRoom(int id, RoomParam RoomParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request");

            if (string.IsNullOrWhiteSpace(id.ToString()))
            {
                message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
            }
            else
            {
                var get = _iRoomService.Update(id.ToString(), RoomParam);
                if (get)
                {
                    message = Request.CreateResponse(HttpStatusCode.OK, get);
                    return(message);
                }
            }
            return(message);
        }
コード例 #23
0
        /// <summary>
        /// Function to update information about a entity .
        /// </summary>
        /// <param name="id">entity's id</param>
        /// <param name="param">entity</param>
        /// <returns>response and update entity</returns>
        public ApiResponse Update(long id, RoomParam param)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                Processor.Update(id, param);
                response.Text   = "The entity updated successfully . \n";
                response.Result = true;

                return(response);
            }
            catch (Exception ex)
            {
                response.Result = false;
                response.Text   = ex.Message;

                return(response);
            }
        }
コード例 #24
0
        //public RoomService(IRoomProcessor processor)
        //{
        //    this.Processor = processor;
        //}

        /// <summary>
        /// Function to create new a entity .
        /// </summary>
        /// <param name="param">a entity</param>
        /// <returns>response and new entity</returns>
        public ApiResponse Create(RoomParam param)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                response.Text = $"The entity successfully added .\n" +
                                $" {Serialization.Serizlize(Processor.Create(param))}";
                response.Result = true;

                return(response);
            }
            catch (Exception ex)
            {
                response.Result = false;
                response.Text   = ex.Message;

                return(response);
            }
        }
コード例 #25
0
        public bool Update(int?id, RoomParam roomParam)
        {
            var result = 0;
            var room   = Get(id);

            room.Name       = roomParam.Name;
            room.Capacity   = roomParam.Capacity;
            room.Location   = roomParam.Location;
            room.UpdateDate = DateTimeOffset.UtcNow.LocalDateTime;
            result          = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            else
            {
                MessageBox.Show("Update Error");
            }
            return(status);
        }
コード例 #26
0
    public void SetupRoom(RoomParam param, SpecificSpot playerSpawn)
    {
        roomObjects = new GameObject("RoomObjects").transform;
        roomUnits   = new GameObject("RoomUnits").transform;
        roomUnits.SetParent(roomObjects);

        ground    = GameObject.Find("Ground").GetComponent <Tilemap>();
        wall      = GameObject.Find("Wall").GetComponent <Tilemap>();
        outerWall = GameObject.Find("OuterWall").GetComponent <Tilemap>();

        width  = GameManager.instance.width;
        height = GameManager.instance.height;

        Vector3 playerSpawnPosition = getPositionPlayer(playerSpawn);

        BoardSetup(param.groundTilesParam, param.outerWallTilesParam);
        LayoutTiles(param.wallTilesParam, wall);
        LayoutUnits(param.unitsParam);
        GameObject instance = Instantiate(player, playerSpawnPosition, Quaternion.identity);

        instance.transform.SendMessage("SetParam", GameManager.instance.playerParam, SendMessageOptions.DontRequireReceiver);
        instance.transform.SetParent(roomUnits);
    }
コード例 #27
0
 public bool Insert(RoomParam roomParam)
 {
     _roomRepository.Insert(roomParam);
     return(status = true);
 }
コード例 #28
0
 public bool Update(int?Id, RoomParam roomParam)
 {
     _roomRepository.Update(Id, roomParam);
     return(status = true);
 }
コード例 #29
0
 // PUT: api/Rooms/5
 public void Put(int id, RoomParam roomParam)
 {
     _roomService.Update(id, roomParam);
 }
コード例 #30
0
 // POST: api/Rooms
 public void Post(RoomParam roomParam)
 {
     _roomService.Insert(roomParam);
 }