예제 #1
0
        public async Task <ActionResult <Furnitures> > PostFurnitures(Furnitures furnitures)
        {
            _context.Furnitures.Add(furnitures);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFurnitures", new { id = furnitures.FurnitureId }, furnitures));
        }
예제 #2
0
        public void Update(RawMasterInfo rpInfo)
        {
            Ships.UpdateRawData(rpInfo.Ships, r => new ShipInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            ShipTypes.UpdateRawData(rpInfo.ShipTypes, r => new ShipTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Equipment.UpdateRawData(rpInfo.Equipment, r => new EquipmentInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            EquipmentTypes.UpdateRawData(rpInfo.EquipmentTypes, r => new EquipmentTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Furnitures.UpdateRawData(rpInfo.Furnitures, r => new FurnitureInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            Items.UpdateRawData(rpInfo.Items, r => new ItemInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            MapAreas.UpdateRawData(rpInfo.MapAreas, r => new MapAreaInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));
            Maps.UpdateRawData(rpInfo.Maps, r => new MapMasterInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            Expeditions.UpdateRawData(rpInfo.Expeditions, r => new ExpeditionInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData));

            EventMapCount = (from rArea in MapAreas.Values
                             where rArea.IsEventArea
                             join rMap in Maps.Values on rArea.ID equals rMap.AreaID
                             select rMap).Count();

            if (r_InitializationLock != null)
            {
                r_InitializationLock.Set();
                r_InitializationLock.Dispose();
                r_InitializationLock = null;
            }
        }
예제 #3
0
        public async Task <IActionResult> PutFurnitures(int id, Furnitures furnitures)
        {
            if (id != furnitures.FurnitureId)
            {
                return(BadRequest());
            }

            _context.Entry(furnitures).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FurnituresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #4
0
    static public Furnitures PlaceInstance(Furnitures proto, Tile tile)
    {
        Debug.Log(tile.X + "_" + tile.Y);
        if (proto.isValidPosition(tile) == false)
        {
            Debug.LogError("PlaceInstance -- Position validity function returned False");
            return(null);
        }

        Furnitures furn = new Furnitures();

        furn.FurnitureType    = proto.FurnitureType;
        furn.movementCost     = proto.movementCost;
        furn.width            = proto.width;
        furn.height           = proto.height;
        furn.linksToNeighbour = proto.linksToNeighbour;

        furn.tile = tile;

        if (tile.PlaceFurniture(furn) == false)
        {
            return(null);
        }

        if (furn.linksToNeighbour)
        {
            Tile t;
            int  x = tile.X;
            int  y = tile.Y;

            t = tile.world.GetTileAt(x, y + 1);
            if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
            {
                t.furniture.cbOnChanged(t.furniture);
            }
            t = tile.world.GetTileAt(x + 1, y);
            if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
            {
                t.furniture.cbOnChanged(t.furniture);
            }
            t = tile.world.GetTileAt(x, y - 1);
            if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
            {
                t.furniture.cbOnChanged(t.furniture);
            }
            t = tile.world.GetTileAt(x - 1, y);
            if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
            {
                t.furniture.cbOnChanged(t.furniture);
            }
        }

        return(furn);
    }
    void OnFurnitureChanged(Furnitures furn)
    {
        if (FurnitureGameObjectMap.ContainsKey(furn) == false)
        {
            Debug.LogError("OnFurnitureChanged -- trying to change visuals for furniture not in our map");
            return;
        }
        GameObject furn_go = FurnitureGameObjectMap[furn];

        furn_go.GetComponent <SpriteRenderer>().sprite = GetSpriteForFurniture(furn);
    }
예제 #6
0
    static public Furnitures CreatePrototype(string FurnitureType, float movementCost = 1f, int width = 1, int height = 1, bool linksToNeighbour = false)
    {
        Furnitures furn = new Furnitures();

        furn.FurnitureType    = FurnitureType;
        furn.movementCost     = movementCost;
        furn.width            = width;
        furn.height           = height;
        furn.linksToNeighbour = linksToNeighbour;

        return(furn);
    }
    public void OnFurnitureCreated(Furnitures furn)
    {
        GameObject furn_go = new GameObject();

        FurnitureGameObjectMap.Add(furn, furn_go);

        furn_go.name = furn.FurnitureType + "_" + furn.tile.X + "_" + furn.tile.Y;
        furn_go.transform.position = new Vector3(furn.tile.X, furn.tile.Y, -1);
        furn_go.transform.SetParent(this.transform, true);

        furn_go.AddComponent <SpriteRenderer>().sprite = GetSpriteForFurniture(furn);

        //Register the callback so the gameobject is updated when the tile type's change
        furn.RegisterOnChangedCallback(OnFurnitureChanged);
    }
예제 #8
0
 public bool PlaceFurniture(Furnitures furnInstance)
 {
     if (furnInstance == null)
     {
         furniture = null;
         return(true);
     }
     if (furniture != null)
     {
         Debug.LogError("Try to assign a Furniture to a tile that already has one");
         return(false);
     }
     furniture = furnInstance;
     return(true);
 }
    public void OnFurnitureCreated(Furnitures furn)
    {
        if (soundCooldown > 0)
        {
            return;
        }

        AudioClip ac = Resources.Load <AudioClip>("Sounds/" + furn.FurnitureType + "_OnCreated");

        if (ac == null)
        {
            ac = Resources.Load <AudioClip>("Sounds/WoodWall_OnCreated");
        }
        AudioSource.PlayClipAtPoint(ac, Camera.main.transform.position);
        soundCooldown = 0.1f;
    }
    Sprite GetSpriteForFurniture(Furnitures furn)
    {
        if (furn.linksToNeighbour == false)
        {
            return(FurnitureSprites[furn.FurnitureType]);
        }

        string spriteName = furn.FurnitureType + "_";

        int x = furn.tile.X;
        int y = furn.tile.Y;

        //Check for neighbours

        Tile t;

        t = World.GetTileAt(x, y + 1);
        if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
        {
            spriteName += "N";
        }
        t = World.GetTileAt(x + 1, y);
        if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
        {
            spriteName += "E";
        }
        t = World.GetTileAt(x, y - 1);
        if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
        {
            spriteName += "S";
        }
        t = World.GetTileAt(x - 1, y);
        if (t != null && t.furniture != null && t.furniture.FurnitureType == furn.FurnitureType)
        {
            spriteName += "W";
        }

        if (FurnitureSprites.ContainsKey(spriteName) == false)
        {
            Debug.LogError("GetSpriteForFurniture -- No sprites with name: " + spriteName);
            return(null);
        }

        return(FurnitureSprites[spriteName]);
    }
예제 #11
0
    /// <summary>
    /// 解析物品信息
    /// </summary>
    void ParseItemJson()
    {
        itemList = new List <Item>();
        //文本为在Unity里面是 TextAsset类型
        TextAsset itemText  = Resources.Load <TextAsset>("Items");
        string    itemsJson = itemText.text;//物品信息的Json格式
        //Debug.Log(itemsJson);
        JSONObject j = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            string        typeStr = temp["type"].str;
            Item.ItemType type    = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeStr);//

            //下面的事解析这个对象里面的公有属性
            int    id          = (int)(temp["id"].n);
            string name        = temp["name"].str;
            string description = temp["description"].str;
            int    capacity    = (int)(temp["capacity"].n);
            int    buyPrice    = (int)(temp["buyPrice"].n);
            int    sellPrice   = (int)(temp["sellPrice"].n);
            string sprite      = temp["sprite"].str;

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int tvChange = (int)(temp["tvChange"].n);
                int hvChange = (int)(temp["hvChange"].n);
                item = new Consumable(id, name, type, description, capacity, buyPrice, sellPrice, sprite, tvChange, hvChange);
                break;

            case Item.ItemType.Furnitures:
                //
                int tvAdjust = (int)(temp["tvAdjust"].n);
                int hvAdjust = (int)(temp["hvAdjust"].n);
                item = new Furnitures(id, name, type, description, capacity, buyPrice, sellPrice, sprite, tvAdjust, hvAdjust);
                break;;
            }
            itemList.Add(item);
            //Debug.Log(item);
        }
    }
예제 #12
0
    public void PlaceFurniture(string FurnitureType, Tile t)
    {
        //Debug.Log("PlaceFurniture");
        if (FurniturePrototypes.ContainsKey(FurnitureType) == false)
        {
            Debug.LogError("FurniturePrototypes doesn't contain a proto for key : " + FurnitureType);
            return;
        }

        Furnitures furn = Furnitures.PlaceInstance(FurniturePrototypes[FurnitureType], t);

        if (furn == null)
        {
            return;
        }

        if (cbFurnitureCreated != null)
        {
            cbFurnitureCreated(furn);
        }
    }
예제 #13
0
        public HouseInfoViewModel(House house, HouseRights rights)
        {
            HouseRights = rights;

            var region = house.Region;

            HouseID     = house.ID;
            RegionName  = region.Name;
            RegionID    = region.ID;
            OwnerName   = house.Citizen.Entity.Name;
            CountryName = Persistent.Countries.GetById(region.CountryID.Value).Entity.Name;
            CountryID   = region.CountryID.Value;
            Avatar      = Images.HousePlaceholder.VM;

            foreach (var f in house.HouseFurnitures.ToList())
            {
                Furnitures.Add(new HouseFurnitureInfoViewModel(f));
            }

            ConditionPercent = (int)house.Condition;
            Condition        = (double)house.Condition;

            ConditionColor = ColorInterpolator
                             .Lerp(
                Condition / 100.0,
                Color.Red,
                Color.Orange,
                Color.Green).ToHex();

            if (house.SellHouse != null)
            {
                SellPrice   = house.SellHouse.Price;
                PriceSymbol = Persistent.Countries.GetCountryCurrency(house.Region.CountryID.Value).Symbol;
            }

            prepareMenu();
        }
예제 #14
0
    void CreateFurniturePrototypes()
    {
        FurniturePrototypes = new Dictionary <string, Furnitures>();

        FurniturePrototypes.Add("Woodwall", Furnitures.CreatePrototype("Woodwall", 0, 1, 1, true));
    }