public ActionResult BuyPoint(vStorePointVM vStorePoint) { if (ModelState.IsValid) { int userId = (int)Session[CDictionary.SK_LOGINED_USER_ID]; var perchaseP = new StorePoint { cId = userId, point = vStorePoint.point }; db.StorePoint.Add(perchaseP); var user = db.Customer.FirstOrDefault(x => x.cId == userId); user.cPoint += vStorePoint.point; db.SaveChanges(); return(RedirectToAction("CCenterList", "Acc")); } return(View(vStorePoint)); }
public Store CreateNewStore(MapData NewMapData, StoreStack StoresStack, string Type, int StoreID, bool In_Radius) { if (Type == "Slaves") { int RandomCell = NewMapData.Tiles[Random.Range(0, NewMapData.GenerateIndexes.Columns * NewMapData.GenerateIndexes.Row - 1)].TileID; if (NewMapData.Tiles[RandomCell].Empty == true) { MapTileSample Tile = NewMapData.Tiles[RandomCell]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Slv = 0; Slv < AddStore.CountOfItem; Slv++) { AddStore.SlaveRandomize(); } StoresStack.storePoint.Add(AddStore); if (StoreID == 0) { NewMapData.GenerateIndexes.PlayerCoords = Tile.Coordinates + new Vector3(0, 0, -5); } Tile.Empty = false; return(newStore); } else { return(null); } } if (Type == "Guns") { CreateInCircle newCirc = new CreateInCircle(); if (In_Radius == true) { newCirc.TakeCell = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID; newCirc.MapColumn = NewMapData.GenerateIndexes.Columns; newCirc.MapRow = NewMapData.GenerateIndexes.Row; newCirc.Radius = 2; newCirc.GenerateCell(); //Debug.Log(newCirc.TargetCell); if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true) { MapTileSample Tile = NewMapData.Tiles[newCirc.TargetCell - 1]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Wpn = 0; Wpn < AddStore.CountOfItem; Wpn++) { AddStore.WeaponRandomize(); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } else { int RandCell = Random.Range(0, NewMapData.Tiles.Count); if (NewMapData.Tiles[RandCell].Empty == true) { MapTileSample Tile = NewMapData.Tiles[RandCell]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Wpn = 0; Wpn < AddStore.CountOfItem; Wpn++) { AddStore.WeaponRandomize(); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } } if (Type == "Bullets") { if (In_Radius == true) { CreateInCircle newCirc = new CreateInCircle(); newCirc.TakeCell = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID; newCirc.MapColumn = NewMapData.GenerateIndexes.Columns; newCirc.MapRow = NewMapData.GenerateIndexes.Row; newCirc.Radius = 2; newCirc.GenerateCell(); //Debug.Log(newCirc.TargetCell); if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true) { MapTileSample Tile = NewMapData.Tiles[newCirc.TargetCell - 1]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Bul = 0; Bul < AddStore.CountOfItem; Bul++) { AddStore.BulletRandomize(); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } else { int RandCell = Random.Range(0, NewMapData.Tiles.Count); if (NewMapData.Tiles[RandCell].Empty == true) { MapTileSample Tile = NewMapData.Tiles[RandCell]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Bul = 0; Bul < AddStore.CountOfItem; Bul++) { AddStore.BulletRandomize(); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } } if (Type == "Stuff") { if (In_Radius == true) { CreateInCircle newCirc = new CreateInCircle(); newCirc.TakeCell = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID; newCirc.MapColumn = NewMapData.GenerateIndexes.Columns; newCirc.MapRow = NewMapData.GenerateIndexes.Row; newCirc.Radius = 2; newCirc.GenerateCell(); if (NewMapData.Tiles[newCirc.TargetCell - 1].Empty == true) { MapTileSample Tile = NewMapData.Tiles[newCirc.TargetCell - 1]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Stf = 0; Stf < AddStore.CountOfItem; Stf++) { AddStore.StuffRandomize(Stf); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } else { int RandCell = Random.Range(0, NewMapData.Tiles.Count); if (NewMapData.Tiles[RandCell].Empty == true) { MapTileSample Tile = NewMapData.Tiles[RandCell]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; AddStore.CountOfItem = Random.Range(10, 15); for (int Stf = 0; Stf < AddStore.CountOfItem; Stf++) { AddStore.StuffRandomize(Stf); } StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } } if (Type == "Recycling") { //CreateInCircle newCirc = new CreateInCircle(); //newCirc.TakeCell = NewMapData.GenerateIndexes.Stores[StoreID - 1].TileID; //newCirc.MapColumn = NewMapData.GenerateIndexes.Columns; //newCirc.MapRow = NewMapData.GenerateIndexes.Row; //newCirc.Radius = 3; //newCirc.GenerateCell(); int RandomCell = NewMapData.Tiles[Random.Range(0, NewMapData.Tiles.Count)].TileID; Debug.Log(RandomCell); if (NewMapData.Tiles[RandomCell].Empty == true) { MapTileSample Tile = NewMapData.Tiles[RandomCell]; Store newStore = new Store(); StorePoint AddStore = new StorePoint(); newStore.TileID = Tile.TileID; newStore.StoreID = StoreID; newStore.Type = Type; AddStore.TypeOfStore = newStore.Type; AddStore.StoreID = newStore.StoreID; StoresStack.storePoint.Add(AddStore); Tile.Empty = false; return(newStore); } else { return(null); } } else { return(null); } }