public CaseItem SaveCaseItem(CaseItem item)
 {
     if (item == null) return item;
     if (item.CaseId <= 0) return item;
     SetDefaultTime(item);
     return CasesData.SaveCaseItems(new List<CaseItem>() { item }).First();
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.mouseScrollDelta.y != 0)
        {
            currentHand = SwapActiveHand();
            currentHand.GetComponentInChildren <Text>().text = "*";
        }

        if (Input.GetMouseButtonDown(1))
        {
            mousePosRight = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2        mousePos2D = new Vector2(mousePosRight.x, mousePosRight.y);
            RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

            eventController.OnRightButtonClickEvent.Invoke(hits, mousePos2D);
        }

        if (Input.GetMouseButtonDown(0))
        {
            mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2        mousePos2D = new Vector2(mousePos.x, mousePos.y);
            RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

            foreach (var hit in hits)
            {
                if (hit.collider != null && IsInActionRadius(mousePos, player.position, actioPlayerRadius))
                {
                    if (hit.collider.gameObject.tag == "player")
                    {
                        Item item = currentHand.GetComponent <ItemCell>().item;
                        item.itemUseData.use.Use_On_Player(statInit.stats, item);
                        SetDefaultItem(currentHand);
                    }

                    if (hit.collider.gameObject.tag == "door")
                    {
                        Item itemInHand = GetItemInHand(currentHand);
                        // использовать айтем как ключ
                        eventController.OnDoorEvent.Invoke(itemInHand, mousePos, hit.collider, hit.collider.GetComponent <DoorController>().isLocked);
                        itemInHand.itemUseData.use.Use_To_Open(statInit.stats, itemInHand);
                    }

                    if (hit.collider.gameObject.tag == "case")
                    {
                        CaseItem  caseItem     = hit.collider.GetComponent <CaseItem>();
                        Transform casePosition = hit.collider.transform;
                        eventController.OnStaticCaseItemEvent.Invoke(caseItem, casePosition);
                    }

                    // ели на полу айтем и в руках не чего нет
                    if (hit.collider.name.Contains(Global.DROPED_ITEM_PREFIX) &&
                        IsEmpty(currentHand))
                    {
                        GameObject itemGo = hit.collider.gameObject;
                        ItemPickUp(itemGo);
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
        public override void VisitCaseItem(CaseItem x)
        {
            ConsumeToken(Tokens.T_CASE, "case");
            VisitElement(x.CaseVal);
            ConsumeToken(Tokens.T_COLON, ":");

            base.VisitCaseItem(x);
        }
Exemplo n.º 4
0
 override public void VisitCaseItem(CaseItem x)
 {
     _serializer.StartSerialize(typeof(CaseItem).Name, SerializeSpan(x.Span));
     _serializer.StartSerialize("CaseVal");
     VisitElement(x.CaseVal);
     _serializer.EndSerialize();
     _serializer.StartSerialize("Statements");
     VisitSwitchItem(x);
     _serializer.EndSerialize();
     _serializer.EndSerialize();
 }
Exemplo n.º 5
0
    public void ActivateStaticItemPanel(CaseItem caseItem, Transform casePosition)
    {
        this.caseItem     = caseItem;
        this.casePosition = casePosition;

        if (caseItem.isLocked && !OpenWithKey())
        {
            Debug.Log("No item to unlock case");
            return;
        }

        controller.CloseOpenContainer(staticItemPanel, ref caseIsOpen);
        controller.ContainerContentInit(caseItem.items, staticItemPanel);
    }
Exemplo n.º 6
0
        /// <summary>
        /// 获取保险组的保险项
        /// </summary>
        /// <param name="caseUid">保险套</param>
        /// <returns></returns>
        public IEnumerable <CaseItem> GetInsItems(string caseUid)
        {
            CaseItem pi       = new CaseItem();
            var      insItems = _dbContext.Columns(INSCENTER).Where(c => c.IsDefaultCol != 1 && !c.ColProperty.Trim().EqualsWithIgnoreCase("3"))
                                .Select(c => new CaseItem {
                Fid = c.Fid, ColComment = c.ColComment, ColName = c.ColName, IsSelected = false
            }).ToList();
            var caseItems = _dbContext.QueryWhere <InsItem>("CaseUid=@CaseUid", new Dapper.DynamicParameters(new { CaseUid = caseUid }))
                            .Select(c => c.ColumnUid);

            if (caseItems.Any())
            {
                foreach (var item in insItems)
                {
                    if (caseItems.Contains(item.Fid))
                    {
                        item.IsSelected = true;
                    }
                }
            }
            return(insItems);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Visit switch-case item.
 /// Case expression and case body.
 /// </summary>
 /// <param name="x"></param>
 virtual public void VisitCaseItem(CaseItem x)
 {
     VisitElement(x.CaseVal);
     VisitSwitchItem(x);
 }
Exemplo n.º 8
0
            internal override void Emit(SwitchStmt node, CodeGenerator codeGenerator)
            {
                Statistics.AST.AddNode("SwitchStmt");
                ILEmitter il = codeGenerator.IL;

                // Note:
                //  SwitchStmt is now implemented in the most general (and unefficient) way. The whole switch
                //  is understood as a series of if-elseif-else statements.

                Label        exit_label            = il.DefineLabel();
                bool         fall_through          = false;
                Label        fall_through_label    = il.DefineLabel();
                Label        last_default_label    = il.DefineLabel();
                DefaultItem  last_default          = GetLastDefaultItem(node);
                LocalBuilder branch_to_lastdefault = null;

                if (last_default != null)
                {
                    branch_to_lastdefault = il.DeclareLocal(Types.Bool[0]);
                    il.LdcI4(0);
                    il.Stloc(branch_to_lastdefault);
                }

                codeGenerator.BranchingStack.BeginLoop(exit_label, exit_label,
                                                       codeGenerator.ExceptionBlockNestingLevel);

                // marks a sequence point containing the discriminator evaluation:
                codeGenerator.MarkSequencePoint(node.SwitchValue.Span);

                // Evaluate condition value and store the result into local variable
                codeGenerator.EmitBoxing(node.SwitchValue.Emit(codeGenerator));
                LocalBuilder condition_value = il.DeclareLocal(Types.Object[0]);

                il.Stloc(condition_value);

                foreach (SwitchItem item in node.SwitchItems)
                {
                    item.MarkSequencePoint(codeGenerator);

                    // switch item is either CaseItem ("case xxx:") or DefaultItem ("default") item:
                    CaseItem case_item = item as CaseItem;
                    if (case_item != null)
                    {
                        Label false_label = il.DefineLabel();

                        // PhpComparer.Default.CompareEq(<switch expr. value>,<case value>);
                        /*changed to static method*/
                        //il.Emit(OpCodes.Ldsfld, Fields.PhpComparer_Default);
                        codeGenerator.EmitCompareEq(
                            cg => { cg.IL.Ldloc(condition_value); return(PhpTypeCode.Object); },
                            cg => case_item.CaseVal.Emit(cg));

                        // IF (!STACK) GOTO false_label;
                        il.Emit(OpCodes.Brfalse, false_label);
                        if (fall_through == true)
                        {
                            il.MarkLabel(fall_through_label, true);
                            fall_through = false;
                        }

                        case_item.EmitStatements(codeGenerator);

                        if (fall_through == false)
                        {
                            fall_through_label = il.DefineLabel();
                            fall_through       = true;
                        }

                        il.Emit(OpCodes.Br, fall_through_label);

                        il.MarkLabel(false_label, true);
                    }
                    else
                    {
                        DefaultItem default_item = (DefaultItem)item;

                        // Only the last default branch defined in source code is used.
                        // So skip default while testing "case" items at runtime.
                        Label false_label = il.DefineLabel();
                        il.Emit(OpCodes.Br, false_label);

                        if (default_item == last_default)
                        {
                            il.MarkLabel(last_default_label, false);
                        }

                        if (fall_through == true)
                        {
                            il.MarkLabel(fall_through_label, true);
                            fall_through = false;
                        }

                        default_item.EmitStatements(codeGenerator);

                        if (fall_through == false)
                        {
                            fall_through_label = il.DefineLabel();
                            fall_through       = true;
                        }

                        il.Emit(OpCodes.Br, fall_through_label);
                        il.MarkLabel(false_label, true);
                    }
                }

                // If no case branch matched, branch to last default case if any is defined
                if (last_default != null)
                {
                    // marks a sequence point containing the condition evaluation or skip of the default case:
                    codeGenerator.MarkSequencePoint(last_default.Span);

                    Debug.Assert(branch_to_lastdefault != null);
                    Label temp = il.DefineLabel();

                    // IF (!branch_to_lastdefault) THEN
                    il.Ldloc(branch_to_lastdefault);
                    il.LdcI4(0);
                    il.Emit(OpCodes.Bne_Un, temp);
                    if (true)
                    {
                        // branch_to_lastdefault = TRUE;
                        il.LdcI4(1);
                        il.Stloc(branch_to_lastdefault);

                        // GOTO last_default_label;
                        il.Emit(OpCodes.Br, last_default_label);
                    }
                    il.MarkLabel(temp, true);
                    // END IF;

                    il.ForgetLabel(last_default_label);
                }

                if (fall_through == true)
                {
                    il.MarkLabel(fall_through_label, true);
                }

                il.MarkLabel(exit_label);
                codeGenerator.BranchingStack.EndLoop();
                il.ForgetLabel(exit_label);
            }
Exemplo n.º 9
0
    void Update()
    {
        if (!actionWindow.isOpen && !dialogWindow.isOpen)
        {
            if (Input.mouseScrollDelta.y != 0)
            {
                currentHand = SwapActiveHand();
                SetHandColor();
                //currentHand.GetComponentInChildren<Text>().text = "*";
            }

            if (Input.GetMouseButtonDown(1))
            {
                eventController.OnMouseClickEvent.Invoke();

                mousePosRight = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector2        mousePos2D = new Vector2(mousePosRight.x, mousePosRight.y);
                RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

                foreach (var hit in hits)
                {
                    if (hit.collider.gameObject.tag == "table" && hit.collider.GetComponent <TableController>().isCraftTable)
                    {
                        bool removeTool = craftController.Craft_Table(hits, GetItemInHand(currentHand),
                                                                      CraftType.Cooking,
                                                                      CraftTable.Table);

                        if (removeTool)
                        {
                            SetDefaultItem(currentHand);
                        }

                        return;
                    }

                    if (hit.collider.gameObject.tag == "microwave")
                    {
                        MicrowaveController microwave = hit.collider.GetComponent <MicrowaveController>();

                        craftController.Craft_Microwave(microwave, GetItemInHand(currentHand),
                                                        CraftType.Cooking,
                                                        CraftTable.Microwave);

                        eventController.OnEnvChangeShapeEvent.Invoke();

                        return;
                    }

                    if (hit.collider.gameObject.tag == "oven")
                    {
                        MicrowaveController microwave = hit.collider.GetComponent <MicrowaveController>();

                        craftController.Craft_Microwave(microwave, GetItemInHand(currentHand),
                                                        CraftType.Cooking,
                                                        CraftTable.Oven);

                        eventController.OnEnvChangeShapeEvent.Invoke();

                        return;
                    }

                    if (hit.collider.gameObject.tag == "printer")
                    {
                        PrinterController printerController = hit.collider.GetComponent <PrinterController>();

                        printerController.OnPrinterClick();
                    }

                    if (hit.collider.gameObject.tag == "pc")
                    {
                        PCController pcController = hit.collider.GetComponent <PCController>();

                        pcController.OnPc_Disck(currentHand);
                    }

                    if (hit.collider.gameObject.tag == "tv")
                    {
                        TVController tvController = hit.collider.GetComponent <TVController>();

                        tvController.NextChanel();
                    }

                    if (hit.collider.gameObject.name.Contains(Global.ITEM_SWITCH_PREFIX))
                    {
                        ItemSwitchController itemSwitchController = hit.collider.GetComponent <ItemSwitchController>();

                        itemSwitchController.SwitchItem(GetItemInHand(currentHand), currentHand);
                    }

                    /*                  */
                    /*      QUESTS      */
                    /*                  */

                    if (hit.collider.gameObject.name.Contains("bus_spawn"))
                    {
                        Debug.Log("bus");
                        BusController bus = hit.collider.GetComponent <BusController>();
                        bus.GiveTicket(currentHand);
                        return;
                    }
                }

                eventController.OnRightButtonClickEvent.Invoke(hits, mousePos2D);
            }

            if (Input.GetMouseButtonDown(0))
            {
                eventController.OnMouseClickEvent.Invoke();

                mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector2        mousePos2D = new Vector2(mousePos.x, mousePos.y);
                RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

                if (IsInActionRadius(mousePos, player.position, actioPlayerRadius))
                {
                    Item itemInHand = GetItemInHand(currentHand);
                    itemInHand.itemUseData.use.Use_On_Env(hits, mousePos, currentHand, GetAnotherHand());
                }

                foreach (var hit in hits)
                {
                    if (hit.collider != null && IsInActionRadius(mousePos, player.position, actioPlayerRadius))
                    {
                        // ели на полу айтем и в руках не чего нет
                        if (hit.collider.name.Contains(Global.DROPED_ITEM_PREFIX) &&
                            IsEmpty(currentHand))
                        {
                            GameObject itemGo = hit.collider.gameObject;
                            ItemPickUp(itemGo);
                            return; // приоритет что бы не взять айтем и не положить его потом на стол если он был уже на столе
                        }

                        if (hit.collider.gameObject.tag == "player")
                        {
                            Item item = currentHand.GetComponent <ItemCell>().item;
                            item.itemUseData.use.Use_On_Player(statInit.stats, item);

                            if (item.isDestroyOnPlayerUse)
                            {
                                SetDefaultItem(currentHand);
                            }
                            else
                            {
                                if (item.afterOnPlayerUseItem != null)
                                {
                                    Item afterUseItemClone = Instantiate(item.afterOnPlayerUseItem);
                                    DressCell(currentHand, afterUseItemClone);
                                }
                            }
                        }

                        if (hit.collider.gameObject.tag == "tapWater")
                        {
                            TabWaterController tabWaterController = hit.collider.GetComponent <TabWaterController>();
                            Button             btn_itemInHand     = IsEmpty(currentHand) ? null : currentHand;
                            tabWaterController.OnWaterTap_Click(btn_itemInHand);
                        }

                        if (hit.collider.gameObject.tag == "envObj")
                        {
                            BaseActionWindowConntroller baseAction = hit.collider.GetComponent <BaseActionWindowConntroller>();
                            baseAction.Open(hit.collider.gameObject);
                        }

                        if (hit.collider.gameObject.tag == "pc")
                        {
                            PCController pcController = hit.collider.GetComponent <PCController>();
                            Item         itemInHand   = IsEmpty(currentHand) ? null : GetItemInHand(currentHand);
                            pcController.OnPc_ClicK(itemInHand, mousePos);
                        }

                        if (hit.collider.gameObject.tag == "tv")
                        {
                            TVController tVController = hit.collider.GetComponent <TVController>();
                            tVController.OnTvClick();
                        }

                        if (hit.collider.gameObject.tag == "microwave" || hit.collider.gameObject.tag == "oven")
                        {
                            Item itemInHand = IsEmpty(currentHand) ? null : GetItemInHand(currentHand);
                            MicrowaveController microwaveController = hit.collider.GetComponent <MicrowaveController>();

                            MicrowaveController.MicrowaveStatus status = microwaveController.OnMicrowaveClick(itemInHand, mousePos);

                            if (status == MicrowaveController.MicrowaveStatus.PutItem)
                            {
                                SetDefaultItem(currentHand);
                            }
                            else if (status == MicrowaveController.MicrowaveStatus.TakeItem)
                            {
                                DressCell(currentHand, microwaveController.itemInside);
                                microwaveController.itemInside = null;
                            }

                            eventController.OnEnvChangeShapeEvent.Invoke();
                        }

                        if (hit.collider.gameObject.tag == "door")
                        {
                            Item itemInHand = GetItemInHand(currentHand);
                            // использовать айтем как ключ
                            //eventController.OnDoorEvent.Invoke(itemInHand, mousePos, hit.collider, hit.collider.GetComponent<DoorController>().isLocked);
                            hit.collider.GetComponent <DoorController>().OnDoorClick(itemInHand, mousePos, hit.collider, hit.collider.GetComponent <DoorController>().isLocked);
                            itemInHand.itemUseData.use.Use_To_Open(statInit.stats, itemInHand);
                        }

                        if (hit.collider.gameObject.tag == "case" || hit.collider.gameObject.tag == "printer")
                        {
                            CaseItem  caseItem     = hit.collider.GetComponent <CaseItem>();
                            Transform casePosition = hit.collider.transform;

                            // важно соблюдать очередность, сначало открывается сундук потом панэль
                            hit.collider.GetComponent <CaseController>().OnCaseCloseOpen(casePosition.position);
                            eventController.OnStaticCaseItemEvent.Invoke(caseItem, casePosition);

                            eventController.OnEnvChangeShapeEvent.Invoke();
                        }

                        if (hit.collider.gameObject.tag == "table")
                        {
                            hit.collider.GetComponent <TableController>().OnTableClick(hit.transform.position,
                                                                                       IsEmpty(currentHand) ? null : GetItemInHand(currentHand));
                        }

                        /*                  */
                        /*      QUESTS      */
                        /*                  */
                        if (hit.collider.gameObject.name.Contains("bus_spawn"))
                        {
                            Debug.Log("bus");
                            BusController bus = hit.collider.GetComponent <BusController>();
                            bus.Activate();
                            return;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
 public CaseItem SaveCaseItem(CaseItem item)
 {
     return CasesManager.SaveCaseItem(item);
 }
Exemplo n.º 11
0
 private void SetDefaultTime(CaseItem item)
 {
     if (item != null && item.CreateDate == DateTime.MinValue) item.CreateDate = DateTime.Now;
 }
Exemplo n.º 12
0
 public CaseItem SaveCaseItem(CaseItem item)
 {
     if (item == null) return item;
     if (item.CaseId <= 0) return item;
     SetDefaultTime(item);
     return CasesData.SaveCaseItems(new List<CaseItem>() { item }).First();
 }
Exemplo n.º 13
0
 public CaseItem SaveCaseItem(CaseItem item)
 {
     return(CasesManager.SaveCaseItem(item));
 }
Exemplo n.º 14
0
 private void SetDefaultTime(CaseItem item)
 {
     if (item != null && item.CreateDate == DateTime.MinValue) item.CreateDate = DateTime.Now;
 }
Exemplo n.º 15
0
    void Update()
    {
        if (dialogWindow.isOpen == false)
        {
            if (Input.mouseScrollDelta.y != 0 || Input.GetKeyDown(KeyCode.Space))      //switch hands
            {
                currentHand = SwapActiveHand();
                SetHandColor();
            }
            else if (Input.GetKeyDown(KeyCode.Q))
            {
                actionPanel.OnDropClick();
            }
            //else if (Input.GetKeyDown(KeyCode.Q))   //switch to left hand
            //{
            //    currentHand = left_hand_btn;
            //    SetHandColor();
            //}
            //else if (Input.GetKeyDown(KeyCode.E))   //switch to right hand
            //{
            //    currentHand = right_hand_btn;
            //    SetHandColor();
            //}
            else if (Input.GetKeyDown(KeyCode.Tab)) // open bag
            {
                if (isBagOpen == true)
                {
                    CloseOpenContainer(bag_panel, ref isBagOpen);
                    return;
                }

                if (IsEmpty(bag_btn) == true)
                {
                    return;
                }

                Item bag = bag_btn.GetComponent <ItemCell>().item;

                CloseOpenContainer(bag_panel, ref isBagOpen);

                if (isBagOpen == true)
                {
                    isBagOpenWithTab = true;
                    ContainerContentInit(bag.innerItems, bag_panel);
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                eventController.OnMouseClickEvent.Invoke();

                mousePosRight = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector2        mousePos2D = new Vector2(mousePosRight.x, mousePosRight.y);
                RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

                foreach (var hit in hits)
                {
                    if (hit.collider.name.Contains(Global.DROPED_ITEM_PREFIX) && IsInActionRadius(hit.transform.position, player.position, actioPlayerRadius))
                    {
                        Item itemInWorld = hit.collider.GetComponent <ItemCell>().item;
                        if (itemInWorld.itemSubstitution.IsUsable(GetItemInHand(currentHand)))
                        {
                            itemInWorld.itemSubstitution.Substitute(hit.collider.gameObject);

                            return;
                        }
                    }

                    if (hit.collider.tag == "substitudeItem")
                    {
                        Item itemToDrop = hit.collider.GetComponent <SubstitudeCell>().item;

                        actionPanel.SpawnItem(hit.transform.position, itemToDrop);
                        Destroy(hit.collider.gameObject);

                        return;
                    }

                    if (hit.collider.gameObject.tag == "table" && hit.collider.GetComponent <TableController>().isCraftTable)
                    {
                        bool removeTool = craftController.Craft_Table(hits, GetItemInHand(currentHand),
                                                                      CraftType.Cooking,
                                                                      CraftTable.Table);

                        if (removeTool)
                        {
                            SetDefaultItem(currentHand);
                        }

                        return;
                    }

                    if (hit.collider.gameObject.tag == "microwave")
                    {
                        MicrowaveController microwave = hit.collider.GetComponent <MicrowaveController>();

                        craftController.Craft_Microwave(microwave, GetItemInHand(currentHand),
                                                        CraftType.Cooking,
                                                        CraftTable.Microwave);

                        eventController.OnEnvChangeShapeEvent.Invoke();

                        return;
                    }

                    if (hit.collider.gameObject.tag == "oven")
                    {
                        MicrowaveController microwave = hit.collider.GetComponent <MicrowaveController>();

                        craftController.Craft_Microwave(microwave, GetItemInHand(currentHand),
                                                        CraftType.Cooking,
                                                        CraftTable.Oven);

                        eventController.OnEnvChangeShapeEvent.Invoke();

                        return;
                    }

                    if (hit.collider.gameObject.tag == "printer")
                    {
                        PrinterController printerController = hit.collider.GetComponent <PrinterController>();

                        printerController.OnPrinterClick();
                    }

                    if (hit.collider.gameObject.tag == "pc")
                    {
                        PCController pcController = hit.collider.GetComponent <PCController>();

                        pcController.OnPc_Disck(currentHand);
                    }

                    if (hit.collider.gameObject.tag == "tv")
                    {
                        TVController tvController = hit.collider.GetComponent <TVController>();

                        tvController.NextChanel();
                    }

                    if (hit.collider.gameObject.name.Contains(Global.ITEM_SWITCH_PREFIX))
                    {
                        ISwitchItem switchItem = hit.collider.GetComponent <ISwitchItem>();
                        switchItem.SwitchItem(GetItemInHand(currentHand), currentHand);
                        //ItemSwitchController itemSwitchController = hit.collider.GetComponent<ItemSwitchController>();

                        //itemSwitchController.SwitchItem(GetItemInHand(currentHand), currentHand);
                    }

                    /*                  */
                    /*      QUESTS      */
                    /*                  */

                    if (hit.collider.gameObject.name.Contains("bus_spawn"))
                    {
                        Debug.Log("bus");
                        BusController bus = hit.collider.GetComponent <BusController>();
                        bus.GiveTicket(currentHand);
                        return;
                    }
                }

                eventController.OnRightButtonClickEvent.Invoke(hits, mousePos2D);
            }

            if (Input.GetMouseButtonDown(0) || ((isOptMouseInput = Input.GetKeyDown(KeyCode.E)) &&
                                                terminalController.isOpen == false))
            {
                eventController.OnMouseClickEvent.Invoke();
                // не детектить нажатие пробела вовремя работы в терминале
                //isOptMouseInput = !terminalController.isOpen;

                if (isOptMouseInput == false)
                {
                    mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                }
                else
                {
                    mousePos = player.position + (playerMovement.GetTurnSide() / 2);
                }

                Vector2        mousePos2D = new Vector2(mousePos.x, mousePos.y);
                RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

                //isSpacePressed = false;

                if (IsInActionRadius(mousePos, player.position, actioPlayerRadius))
                {
                    Item itemInHand = GetItemInHand(currentHand);
                    itemInHand.itemUseData.use.Use_On_Env(hits, mousePos, currentHand, GetAnotherHand());
                }

                foreach (var hit in hits)
                {
                    if (hit.collider != null && IsInActionRadius(mousePos, player.position, actioPlayerRadius))
                    {
                        // ели на полу айтем и в руках не чего нет
                        if (hit.collider.name.Contains(Global.DROPED_ITEM_PREFIX) &&
                            IsEmpty(currentHand))
                        {
                            GameObject itemGo = hit.collider.gameObject;
                            ItemPickUp(itemGo);
                            return; // приоритет что бы не взять айтем и не положить его потом на стол если он был уже на столе
                        }

                        /*   клик по игроку   */
                        if (hit.collider.gameObject.tag == "playerAction")
                        {
                            Item item = currentHand.GetComponent <ItemCell>().item;
                            eventController.OnUseOnPlayerEvent.Invoke(item);
                            item.itemUseData.use.Use_On_Player(null, item);

                            if (item.isDestroyOnPlayerUse)
                            {
                                SetDefaultItem(currentHand);
                            }
                            else
                            {
                                if (item.afterOnPlayerUseItem != null)
                                {
                                    Item afterUseItemClone = Instantiate(item.afterOnPlayerUseItem);
                                    DressCell(currentHand, afterUseItemClone);
                                }
                            }
                        }

                        if (hit.collider.tag == "substitudeItem")
                        {
                            BaseConection baseConection = hit.collider.GetComponent <BaseConection>();

                            if (baseConection != null)
                            {
                                PCController pcController = baseConection.FindPcInRadius();

                                if (pcController != null)
                                {
                                    baseConection.ProcessConection(pcController);
                                }

                                return;
                            }
                        }

                        if (hit.collider.gameObject.tag == "tapWater")
                        {
                            TabWaterController tabWaterController = hit.collider.GetComponent <TabWaterController>();
                            Button             btn_itemInHand     = IsEmpty(currentHand) ? null : currentHand;
                            tabWaterController.OnWaterTap_Click(btn_itemInHand);
                        }

                        if (hit.collider.gameObject.tag == "envObj")
                        {
                            BaseActionWindowConntroller baseAction = hit.collider.GetComponent <BaseActionWindowConntroller>();
                            baseAction.Open(hit.collider.gameObject);
                        }

                        if (hit.collider.gameObject.tag == "pc")
                        {
                            PCController pcController = hit.collider.GetComponent <PCController>();
                            Item         itemInHand   = IsEmpty(currentHand) ? null : GetItemInHand(currentHand);
                            pcController.OnPc_ClicK(itemInHand);
                        }

                        if (hit.collider.gameObject.tag == "tv")
                        {
                            TVController tVController = hit.collider.GetComponent <TVController>();
                            tVController.OnTvClick();
                        }

                        if (hit.collider.gameObject.tag == "microwave" || hit.collider.gameObject.tag == "oven")
                        {
                            Item itemInHand = IsEmpty(currentHand) ? null : GetItemInHand(currentHand);
                            MicrowaveController microwaveController = hit.collider.GetComponent <MicrowaveController>();

                            MicrowaveController.MicrowaveStatus status = microwaveController.OnMicrowaveClick(itemInHand, mousePos);

                            if (status == MicrowaveController.MicrowaveStatus.PutItem)
                            {
                                SetDefaultItem(currentHand);
                            }
                            else if (status == MicrowaveController.MicrowaveStatus.TakeItem)
                            {
                                DressCell(currentHand, microwaveController.itemInside);
                                microwaveController.itemInside = null;
                            }

                            eventController.OnEnvChangeShapeEvent.Invoke();
                        }

                        if (hit.collider.gameObject.tag == "door")
                        {
                            Item itemInHand = GetItemInHand(currentHand);
                            // использовать айтем как ключ
                            //eventController.OnDoorEvent.Invoke(itemInHand, mousePos, hit.collider, hit.collider.GetComponent<DoorController>().isLocked);
                            hit.collider.GetComponent <DoorController>().OnDoorClick(itemInHand, mousePos, hit.collider, hit.collider.GetComponent <DoorController>().isLocked);
                            itemInHand.itemUseData.use.Use_To_Open(null, itemInHand);
                        }

                        if (hit.collider.gameObject.tag == "case" || hit.collider.gameObject.tag == "printer")
                        {
                            CaseItem  caseItem     = hit.collider.GetComponent <CaseItem>();
                            Transform casePosition = hit.collider.transform;

                            // важно соблюдать очередность, сначало открывается сундук потом панэль
                            hit.collider.GetComponent <CaseController>().OnCaseCloseOpen(casePosition.position);

                            eventController.OnStaticCaseItemEvent.Invoke(caseItem, casePosition);
                            eventController.OnEnvChangeShapeEvent.Invoke();
                        }

                        if (hit.collider.gameObject.tag == "table")
                        {
                            hit.collider.GetComponent <TableController>().OnTableClick(hit.transform.position,
                                                                                       IsEmpty(currentHand) ? null : GetItemInHand(currentHand));
                        }

                        /*                  */
                        /*      QUESTS      */
                        /*                  */
                        if (hit.collider.gameObject.name.Contains("bus_spawn"))
                        {
                            Debug.Log("bus");
                            BusController bus = hit.collider.GetComponent <BusController>();
                            bus.Activate();
                            return;
                        }
                    }
                }
            }
        }
    }
        public ActionResult SaveItem(CaseItem item)
        {
            bool result = CasesService.SaveCaseItem(item) != null;

            return(Json(result.ToString().ToLower()));
        }
Exemplo n.º 17
0
 void Start()
 {
     caseItem = GetComponent <CaseItem>();
 }
Exemplo n.º 18
0
 /// <summary>
 /// Visits CaseItem, and forwards visitor for all statements.
 /// </summary>
 /// <param name="x">CaseItem</param>
 public override void VisitCaseItem(CaseItem x)
 {
     VisitStatementList(x.Statements);
 }
Exemplo n.º 19
0
 public ActionResult SaveItem(CaseItem item)
 {
     bool result = CasesService.SaveCaseItem(item) != null;
     return Json(result.ToString().ToLower());
 }