Пример #1
0
    public void AddBuilding(string buildingName, Vector3 BuildPoint)
    {
        GameObject newBuilding = (GameObject)Instantiate(GameManager.GetGameObject(buildingName), BuildPoint, Quaternion.identity);

        newBuilding.name                 = buildingName;
        newBuilding.transform.parent     = buildings.transform;
        newBuilding.transform.localScale = GameManager.GetGameObject(buildingName).transform.localScale;
        Building building = newBuilding.GetComponent <Building> ();

        buildings.AddBuilding(building);
        building.SetPlayer(this);
        AddToWOsDick(building as WorldObject);
        foreach (ResourceType resource in BuildMenu.buildingCostDick[buildingName].Keys)
        {
            ChangeResource(resource, -BuildMenu.buildingCostDick[buildingName][resource]);
        }
    }
Пример #2
0
        public JsonResult AutoComplete(string searchTerm)
        {
            try
            {
                Buildings buildings    = new Buildings();
                var       buildingName = (from Buildings in buildings.GetBuildings()
                                          where Buildings.Name.StartsWith(searchTerm)
                                          select new
                {
                    label = Buildings.Name,
                    val = Buildings.id
                }).ToList();

                if (buildingName.Count > 0)
                {
                    return(Json(buildingName, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    building buildingterm = new building();
                    buildingterm.Name             = searchTerm;
                    buildingterm.managementid     = 3;
                    buildingterm.address          = "address";
                    buildingterm.ownershiptype    = "Post war";
                    buildingterm.unitaccess       = "unitaccess";
                    buildingterm.buildingfeatures = "features";
                    buildingterm.phonenumber      = "1231231234";
                    buildings.AddBuilding(buildingterm);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                //handling exception
                throw ex;
            }
        }