Ejemplo n.º 1
0
        private void savecomboboxroomproperty(HttpContext context)
        {
            string liststr = context.Request["list"];

            if (string.IsNullOrEmpty(liststr))
            {
                WebUtil.WriteJson(context, new { status = false, msg = "参数错误" });
                return;
            }
            List <Utility.BasicModel> list = JsonConvert.DeserializeObject <List <Utility.BasicModel> >(liststr);

            foreach (var item in list)
            {
                Foresight.DataAccess.RoomProperty roomproperty = null;
                if (item.id > 0)
                {
                    roomproperty = Foresight.DataAccess.RoomProperty.GetRoomProperty(item.id);
                }
                if (roomproperty == null)
                {
                    roomproperty = new RoomProperty();
                }
                roomproperty.Name = item.value;
                roomproperty.Save();
            }
            WebUtil.WriteJson(context, new { status = true });
        }
Ejemplo n.º 2
0
    public void Build(NewRoom room) // build lvl 1 from build panel
    {
        GameObject   gameObject  = GameObject.Find(roomHandler.id.ToString());
        RoomProperty currentRoom = gameObject.GetComponent <RoomProperty>();
        Animator     animator    = gameObject.GetComponent <Animator>();
        GameOver     over        = stat.GetComponent <GameOver>();

        if (score.money >= room.BuildCost[0])
        {
            // minus money and happiness
            score.MoneyOperation(-room.BuildCost[0]);
            score.HappinessOperation(room.Happiness[0]);
            animator.SetInteger("index", room.AnimationIndex[0]);
            // and pass param to corespond room
            // naming
            currentRoom.label        = room.Label;
            currentRoom.description  = room.Description[0];
            currentRoom.resourceType = room.ResourceType;
            // base param
            currentRoom.baseResorceGenerate = room.Resource[0];
            currentRoom.productConsume      = room.ProductConsume[0];
            currentRoom.baseTaxToPay        = room.Taxes[0];
            currentRoom.baseTimeGenerate    = room.ProductionTime[0];
            currentRoom.costBuild           = room.BuildCost[0];
            currentRoom.lvl       = 1;
            currentRoom.roomIndex = room.RoomIndex; // rename later in RoomProperty
            // multi
            // currentRoom.localResoureceMulti = room.LocalMoneyMulti[0];
            // currentRoom.localTaxMulti = room.TaxMulti[0];
            // currentRoom.localTimeMulti = room.TimeMulti[0];
            // currentRoom.eventMulti = room.EventMulti[0];
            // do smth with local support
            //////
            // bool managment
            currentRoom.isEmpty = false;
            // handle sprite update
            currentRoom.image = room.Image[0];
            currentRoom.UpdateSprite();
            // operations with global multi at Score
            score.globalResourceMulti *= room.MoneyMulti[0];
            score.globalTaxMulti      *= room.TaxMulti[0];
            score.globalTimeMulti     *= room.TimeMulti[0];
            score.globalEventChance   *= room.EventMulti[0];
            timeLine.eventChance      *= room.EventMulti[0];
            // update data in room
            currentRoom.UpdateMulti();
            currentRoom.NullTimer();
            currentRoom.Select();
            // and Handle UI panels
            upgradePanel.SetActive(true);
            buildPanel.SetActive(false);
            buildEvent.Raise();
            int id = int.Parse(roomHandler.id);
            over.roomLabels[id] = room.Label;
        }
    }
Ejemplo n.º 3
0
    public void Sell()
    {
        GameObject   gameObject  = GameObject.Find(roomHandler.id.ToString());
        RoomProperty currentRoom = gameObject.GetComponent <RoomProperty>();
        Animator     animator    = gameObject.GetComponent <Animator>();
        GameOver     over        = stat.GetComponent <GameOver>();

        // bool managment
        currentRoom.isEmpty = true;
        // refund calculations
        int   moneyRefund      = 0;
        int   happinessRefund  = 0;
        float moneyMultiRefund = 1;
        float timeMultiRefund  = 1;
        float eventMultiRefund = 1;
        float taxMultiRefund   = 1;

        for (int i = 0; i < currentRoom.lvl; i++)
        {
            moneyRefund      += roomList.Rooms[currentRoom.roomIndex].BuildCost[i];
            happinessRefund  += roomList.Rooms[currentRoom.roomIndex].Happiness[i];
            moneyMultiRefund *= roomList.Rooms[currentRoom.roomIndex].MoneyMulti[i];
            timeMultiRefund  *= roomList.Rooms[currentRoom.roomIndex].TimeMulti[i];
            eventMultiRefund *= roomList.Rooms[currentRoom.roomIndex].EventMulti[i];
            taxMultiRefund   *= roomList.Rooms[currentRoom.roomIndex].TaxMulti[i];
        }
        // and some local??
        //
        // actually the refund
        Debug.Log(moneyRefund + " refund");
        score.MoneyOperation(Mathf.RoundToInt(moneyRefund * 0.3f));
        score.HappinessOperation(-happinessRefund);
        score.globalResourceMulti /= moneyMultiRefund;
        score.globalTimeMulti     /= timeMultiRefund;
        score.globalEventChance   /= eventMultiRefund;
        score.globalTaxMulti      /= taxMultiRefund;
        timeLine.eventChance      /= eventMultiRefund;
        // multi managment
        currentRoom.baseTaxToPay = 0;
        currentRoom.NullTimer();
        currentRoom.UpdateMulti();
        currentRoom.UpdateSprite();
        // handle sprite update
        currentRoom.image = emptyImage;
        currentRoom.UpdateSprite();
        // ui change
        upgradePanel.SetActive(false);
        buildPanel.SetActive(true);
        currentRoom.Select();
        int id = int.Parse(roomHandler.id);

        over.roomLabels[id] = "";
        animator.SetInteger("index", 0);
        hintInfo.SetActive(false);
    }
Ejemplo n.º 4
0
 private static CellState[,] generateCells(RoomProperty roomProperties)
 {
     CellState[,] cells = new CellState[roomProperties.basicDim.x, roomProperties.basicDim.y];
     for (int x = 0; x < roomProperties.basicDim.x; x++)
     {
         for (int y = 0; y < roomProperties.basicDim.y; y++)
         {
             if (x == 0 || y == 0 || x == roomProperties.basicDim.x - 1 || y == roomProperties.basicDim.y - 1)
             {
                 cells[x, y] = CellState.emptyCell;
             }
             else
             {
                 cells[x, y] = CellState.groundCell;
             }
         }
     }
     if (roomProperties.removedGround.Count != 0)
     {
         foreach (RectInt rect in roomProperties.removedGround)
         {
             for (int x = rect.x; x < rect.x + rect.width; x++)
             {
                 for (int y = rect.y; y < rect.y + rect.height; y++)
                 {
                     cells[x, y] = CellState.emptyCell;
                 }
             }
         }
     }
     foreach (Vector2Int doorPos in roomProperties.doorsPosition)
     {
         if (isValidPosition(roomProperties, new Vector2Int(doorPos.x, doorPos.y)))
         {
             cells[doorPos.x, doorPos.y] = CellState.groundCell;
         }
         if (isValidPosition(roomProperties, new Vector2Int(doorPos.x - 1, doorPos.y)))
         {
             cells[doorPos.x - 1, doorPos.y] = CellState.groundCell;
         }
         if (isValidPosition(roomProperties, new Vector2Int(doorPos.x, doorPos.y - 1)))
         {
             cells[doorPos.x, doorPos.y - 1] = CellState.groundCell;
         }
         if (isValidPosition(roomProperties, new Vector2Int(doorPos.x - 1, doorPos.y - 1)))
         {
             cells[doorPos.x - 1, doorPos.y - 1] = CellState.groundCell;
         }
     }
     return(cells);
 }
Ejemplo n.º 5
0
 private void LoadRoomProperty(HttpContext context)
 {
     try
     {
         RoomProperty[] property = RoomProperty.GetRoomProperties().ToArray();
         string         result   = JsonConvert.SerializeObject(property);
         context.Response.Write("{\"status\":true,\"list\":" + result + "}");
     }
     catch (Exception ex)
     {
         Utility.LogHelper.WriteError("RoomResourceHandler", "命令:LoadRoomProperty", ex);
         context.Response.Write("{\"status\":false,\"list\":[]}");
     }
 }
Ejemplo n.º 6
0
    public static bool drawRoom(DungeonAssetModule dungeonAsset, Vector2Int origin, RoomProperty property, Utils.GlobalDirection direction)
    {
        //TODO add logic for room rotation
        DungeonDrawer.dungeonAsset = dungeonAsset;
        CellState[,] cells         = generateCells(property);
        //Ground and Collider draw
        try {
            for (int x = 0; x < property.basicDim.x; x++)
            {
                for (int y = 0; y < property.basicDim.y; y++)
                {
                    switch (cells[x, y])
                    {
                    case CellState.emptyCell:
                        placeTileCollider(new Vector3Int(origin.x + x, origin.y + y, 0),
                                          dungeonAsset.dungeonTiles.groundBase);
                        break;

                    case CellState.groundCell:
                        placeTileGround(new Vector3Int(origin.x + x, origin.y + y, 0),
                                        dungeonAsset.dungeonTiles.groundBase);
                        break;
                    }
                }
            }
            //Wall draw
            for (int x = 0; x < property.basicDim.x; x++)
            {
                for (int y = 0; y < property.basicDim.y; y++)
                {
                    // switch (cells[x, y])
                    // {

                    // }
                }
            }
        } catch (NullReferenceException ex) {
        }
        return(true);
    }
Ejemplo n.º 7
0
    private void generateWalls(
        Transform wallFolder,
        RoomByIndex nextRoom,
        RoomProperty roomHasDoor,
        PositionByIndex wallPosition,
        WallInitializer wallInit)
    {
        for (int i = -1; i < width; ++i)
        {
            for (int j = -1; j < height; ++j)
            {
                Room cur  = inBounds(i, j) ? rooms[i, j] : null;
                Room next = nextRoom(i, j);

                bool shouldSpawnWall = (cur != null) || (next != null);
                if (shouldSpawnWall)
                {
                    bool       wallHasDoor = (cur != null) && roomHasDoor(cur);
                    GameObject wall        = Instantiate(wallPrefab);
                    wall.transform.position = wallPosition(i, j);
                    wall.transform.parent   = wallFolder;

                    RandomlySizedDoor door = wall.GetComponent <RandomlySizedDoor>();
                    wallInit(door, wallHasDoor);

                    if (cur != null)
                    {
                        cur.associatedWalls.Add(wall);
                    }
                    if (next != null)
                    {
                        next.associatedWalls.Add(wall);
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
 private static bool isValidPosition(RoomProperty roomProperties, Vector2Int position)
 {
     return(position.x >= 0 && position.y >= 0 &&
            position.x <= roomProperties.basicDim.x - 1 && position.y <= roomProperties.basicDim.y - 1);
 }
Ejemplo n.º 9
0
 set => SetValue(RoomProperty, value);