Example #1
0
        public async Task <OperationDetails> AddHookah(HookahDTO hookahDto)
        {
            try
            {
                Hookah hookah = new Hookah()
                {
                    ProductId   = Guid.NewGuid(),
                    Mark        = hookahDto.Mark.Trim(),
                    Model       = hookahDto.Model.Trim(),
                    Description = (hookahDto.Description == null || hookahDto.Description.Trim() == "") ? "Отсутствует" : hookahDto.Description.Trim(),
                    Country     = (hookahDto.Country == null || hookahDto.Country.Trim() == "") ? "Нет данных" : hookahDto.Country.Trim(),
                    Height      = hookahDto.Height,
                    Price       = hookahDto.Price,
                    //если файл не передан, то устанавливаем изображение по умолчанию
                    Image = (hookahDto.Image == null) ? "/Files/ProductImages/defaultImage.jpg" : hookahDto.Image
                };
                db.Hookahs.Add(hookah);
                await db.SaveAsync();

                return(new OperationDetails(true, "Товар успешно добавлен", ""));
            }
            catch
            {
                return(new OperationDetails(false, "При добавлении товара произошла ошибка", ""));
            }
        }
Example #2
0
        public async Task <OperationDetails> EditHookah(HookahDTO hookahDto)
        {
            try
            {
                Hookah hookah = await db.Products.FindByIdAsync(hookahDto.ProductId) as Hookah;

                hookah.Mark        = hookahDto.Mark.Trim();
                hookah.Model       = hookahDto.Model.Trim();
                hookah.Description = (hookahDto.Description == null || hookahDto.Description.Trim() == "") ? "Отсутствует" : hookahDto.Description.Trim();
                hookah.Country     = (hookahDto.Country == null || hookahDto.Country.Trim() == "") ? "Нет данных" : hookahDto.Country.Trim();
                hookah.Height      = hookahDto.Height;
                hookah.Price       = hookahDto.Price;
                //если новое изображение не передано, то оставляем старое
                hookah.Image = (hookahDto.Image == null) ? hookah.Image : hookahDto.Image;

                db.Hookahs.Update(hookah);
                await db.SaveAsync();

                return(new OperationDetails(true, "Товар успешно обновлен", ""));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(new OperationDetails(false, "Данный товар ранее уже был изменен", ""));
            }
            catch
            {
                return(new OperationDetails(false, "При изменении товара произошла ошибка", ""));
            }
        }
 public void AddChooseTobaccoAction(Hookah hookah)
 {
     if (!carryingHookah)
     {
         actions.Enqueue(new ChooseTobaccoAction(hookah));
     }
 }
 public void CancelChoosingTobacco()
 {
     choosingTobacco = false;
     currentAction   = null;
     DisplayTobaccoPanel(false);
     servedHookah = null;
 }
Example #5
0
    void Update()
    {
        if (Status == ClientStatus.Entered && NotMoving())
        {
            LookForFreeTable();
        }

        if (Status == ClientStatus.Approaching && NotMoving())
        {
            Sit();
        }

        if (Status == ClientStatus.Waiting)
        {
            waitingTime += PlayTimer.Instance.TimePerFrame();

            if (occupiedTable.Hookah != null)
            {
                smokedHookah = occupiedTable.Hookah;
                Status       = ClientStatus.Smoking;
                smokedHookah.SetActive();
                prefsSatisfied = PrefsSatisfied();
                DisplayText(prefsSatisfied ? onHookahBrought[0] : onHookahBrought[1], 3f);
            }
        }

        if (Status == ClientStatus.Smoking)
        {
            if (smokedHookah.Active)
            {
                // TODO: Add smoking animation there
            }
            else
            {
                Status = ClientStatus.Leaving;
                agent.SetDestination(player.entry.position);
            }
        }

        if (Status == ClientStatus.Leaving && NotMoving())
        {
            player.RemoveClient(this);
            if (waitingTime > 0f)
            {
                CommentOnLounge();
                player.Money += smokedHookah.ContainedTobacco.brand.price;
            }
            Leave();
        }

        // NOTE: Updating chat bubble so that it does not rotate with a parent object
        bubble.transform.localRotation = Quaternion.Euler(0, bubble.initialRotation + -transform.localRotation.eulerAngles.y, 0);
    }
Example #6
0
        protected override void Seed(ApplicationContext db)
        {
            HookahTobacco p1 = new HookahTobacco(Guid.NewGuid(), "Al Fakher", "Apple", 70, "Табак1", "Египет", 45, "/Files/ProductImages/defaultImage.jpg");
            HookahTobacco p2 = new HookahTobacco(Guid.NewGuid(), "Al Fakher", "Cherry", 45, "Табак2", "Пакистан", 45, "/Files/ProductImages/defaultImage.jpg");
            HookahTobacco p3 = new HookahTobacco(Guid.NewGuid(), "Al Fakher", "Mint", 100, "Табак3", "Камыши", 45, "/Files/ProductImages/defaultImage.jpg");
            HookahTobacco p4 = new HookahTobacco(Guid.NewGuid(), "Al Fakher", "Orange", 100, "Табак4", "Египет", 45, "/Files/ProductImages/defaultImage.jpg");

            db.HookahTobacco.AddRange(new List <HookahTobacco> {
                p1, p2, p3, p4
            });

            Hookah p5 = new Hookah(Guid.NewGuid(), "KM", "BOER GL Bronze", 9000, "Описание", "Германия", 45, "/Files/ProductImages/defaultImage.jpg");
            Hookah p6 = new Hookah(Guid.NewGuid(), "Khalil", "Mamoon Halazone Trimetal", 6800, "Описание", "Азербайджан", 85, "/Files/ProductImages/defaultImage.jpg");

            db.Hookahs.AddRange(new List <Hookah> {
                p5, p6
            });

            db.SaveChanges();
        }
    void HandleBringHookahAction(BringHookahAction bringAction)
    {
        Table table = bringAction.table;
        float range = 7f;

        if (Vector3.Distance(transform.position, table.HookahPos) > range)
        {
            currentAction = null;
            Vector3 closestPoint = Utils.ClosestPointOnSphere(transform.position, table.HookahPos, range * 0.9f);
            AddMoveAction(closestPoint);
            AddBringHookahAction(table);
        }
        else
        {
            carryingHookah = false;
            table.Hookah   = servedHookah;
            table.Hookah.transform.SetParent(table.transform);
            table.Hookah.transform.position = table.HookahPos;
            servedHookah = null;
            servedTable  = table;
        }
    }
    void HandleChooseTobaccoAction(ChooseTobaccoAction chooseAction)
    {
        if (!carryingHookah)
        {
            Hookah hookah = chooseAction.hookah;

            float range = 5f;
            if (Vector3.Distance(transform.position, hookah.transform.position) > range)
            {
                currentAction = null;

                Vector3 closestPoint = Utils.ClosestPointOnSphere(transform.position, hookah.transform.position, range * 0.96f);
                AddMoveAction(closestPoint);
                AddChooseTobaccoAction(hookah);
            }
            else
            {
                choosingTobacco = true;
                servedHookah    = hookah;
                DisplayTobaccoPanel(true);
            }
        }
    }
Example #9
0
    void HandleWorkerActions()
    {
        HookahMaker hookahMaker = GetSelectedWorker();

        if (hookahMaker == null)
        {
            return;
        }

        Ray inputRay = mainCamera.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(inputRay, out RaycastHit hit))
        {
            LayerMask colliderMask = 1 << hit.collider.gameObject.layer;

            if (!shiftPressed)
            {
                hookahMaker.ClearActions();
            }

            if (colliderMask == hookahMask)
            {
                Hookah hookah = hit.collider.gameObject.GetComponent <Hookah>();
                hookahMaker.AddChooseTobaccoAction(hookah);
            }
            else if (colliderMask == tableMask)
            {
                Table table = hit.collider.gameObject.GetComponent <Table>();
                hookahMaker.AddBringHookahAction(table);
            }
            else
            {
                hookahMaker.AddMoveAction(hit.point);
            }
        }
    }
    public void Load(BinaryFormatter formatter, FileStream stream)
    {
        // NOTE: Loading clients
        foreach (Client client in player.clients)
        {
            Destroy(client.gameObject);
        }
        player.clients.Clear();
        int             clientsCount = (int)formatter.Deserialize(stream);
        ClientGenerator generator    = FindObjectOfType <ClientGenerator>();

        for (int i = 0; i < clientsCount; i++)
        {
            string prefabName   = (string)formatter.Deserialize(stream);
            Client clientPrefab = PrefabStorage.Instance.GetClientByName(prefabName);

            Client client = Instantiate(clientPrefab);
            client.Load(formatter, stream);
            client.prefabName = prefabName;
            player.AddClient(client);

            ClientData clientData = (ClientData)formatter.Deserialize(stream);

            client.clientData = clientData;
        }

        // NOTE: Loading tables
        foreach (Table table in player.tables)
        {
            Destroy(table.gameObject);
        }
        int tablesCount = (int)formatter.Deserialize(stream);

        player.tables.Clear();
        for (int i = 0; i < tablesCount; i++)
        {
            string prefabName  = (string)formatter.Deserialize(stream);
            Table  tablePrefab = PrefabStorage.Instance.GetTableByName(prefabName);

            Table table = Instantiate(tablePrefab);
            table.Load(formatter, stream);
            table.prefabName = prefabName;
            player.tables.Add(table);

            TableData tableData = (TableData)formatter.Deserialize(stream);

            table.tableData = tableData;
        }

        // NOTE: Loading hookahs
        foreach (Hookah hookah in player.hookahs)
        {
            Destroy(hookah.gameObject);
        }
        int hookahsCount = (int)formatter.Deserialize(stream);

        player.hookahs.Clear();
        for (int i = 0; i < hookahsCount; i++)
        {
            string prefabName   = (string)formatter.Deserialize(stream);
            Hookah hookahPrefab = PrefabStorage.Instance.GetHookahByName(prefabName);

            Hookah hookah = Instantiate(hookahPrefab);
            hookah.Load(formatter, stream);
            hookah.prefabName = prefabName;
            player.hookahs.Add(hookah);
        }

        // NOTE: Loading hookah makers
        foreach (HookahMaker worker in player.workers)
        {
            Destroy(worker.gameObject);
        }
        int workersCount = (int)formatter.Deserialize(stream);

        player.workers.Clear();
        for (int i = 0; i < workersCount; i++)
        {
            string      prefabName        = (string)formatter.Deserialize(stream);
            HookahMaker hookahMakerPrefab = PrefabStorage.Instance.GetHookahMakerByName(prefabName);

            HookahMaker worker = Instantiate(hookahMakerPrefab);
            worker.Load(formatter, stream);
            worker.prefabName = prefabName;
            player.workers.Add(worker);

            HookahMakerData hookahMakerData = (HookahMakerData)formatter.Deserialize(stream);

            worker.hookahMakerData = hookahMakerData;
        }


        RecreateClientLinks(formatter, stream);
        RecreateTableLinks(formatter, stream);
        RecreateHookahMakerLinks(formatter, stream);
    }
 public ChooseTobaccoAction(Hookah hookah)
 {
     this.hookah = hookah;
 }