コード例 #1
0
 // Use this for initialization
 void Start()
 {
     createInventory();
     _instance     = this;
     player        = GameObject.Find("Player");
     selectedPanel = null;
 }
コード例 #2
0
    void Start()
    {
        if (craftController == null)
        {
            craftController = FindObjectOfType(typeof(CraftController)) as CraftController;
        }

        inventory = GameObject.Find("Player").GetComponent <Inventory>();
    }
コード例 #3
0
ファイル: CraftController.cs プロジェクト: Comts/git1
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #4
0
    void OnTriggerEnter(Collider other)
    {
        CraftController controller = this.GetComponent <CraftController>();

        if (controller != null)
        {
            controller.DamagedBy(other.gameObject);
        }
        else
        {
            Debug.Log("Cannot find 'CraftController' script");
        }
    }
コード例 #5
0
ファイル: TouchPanel.cs プロジェクト: Geatnium/ARCraft_Exp
 private void Awake()
 {
     craftController = GameObject.FindWithTag("GameController").GetComponent <CraftController> ();
 }
コード例 #6
0
ファイル: CraftController.cs プロジェクト: spock254/sza
    Controller controller;              /*   IsEmpty()   */

    void Awake()
    {
        instance      = this;
        itemCraftData = Resources.LoadAll <ItemCraftData>(Global.Path.RECEPT).ToList();
        controller    = Global.Component.GetController();
    }
コード例 #7
0
    void Update()
    {
        if (IsInActionRadius() == true)
        {
            Vector3        mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2        mousePos2D = new Vector2(mousePos.x, mousePos.y);
            RaycastHit2D[] hits       = Physics2D.RaycastAll(mousePos2D, Vector2.zero);

            if (hits.Length == 0)
            {
                isdetected = false;
            }

            foreach (var hit in hits)
            {
                if (hit.collider.tag == "substitudeItem")
                {
                    BaseConection baseConection = hit.collider.GetComponent <BaseConection>();
                    NPC_Info      npcInfo       = hit.collider.GetComponent <NPC_Info>();
                    PCController  pcController  = baseConection.FindPcInRadius();

                    string interactionStr = Global.Tooltip.LM_INTERACT + " / " + Global.Tooltip.RM_TURN_OFF;

                    if (pcController != null)
                    {
                        bool isConnected = pcController.peripherals.Contains(hit.collider.gameObject);
                        interactionStr = ((isConnected == true) ? Global.Tooltip.LM_DISCONNECT : Global.Tooltip.LM_CONNECT) + " / " + Global.Tooltip.RM_TURN_OFF;
                    }

                    isdetected = true;
                    //tooltipPosition = Camera.main.WorldToScreenPoint(hit.transform.position);
                    ShowToolTip(npcInfo == null ? "obj" : npcInfo.npcName, interactionStr);
                    TooltipLocate(hit.collider.transform.position);
                    return;
                }
                else if (hit.collider.tag == "table")
                {
                    TableController tableController = hit.collider.GetComponent <TableController>();

                    isdetected = true;
                    //tooltipPosition = Camera.main.WorldToScreenPoint(hit.collider.transform.position);

                    if (IsCurrentHandEmpty() && IsObjectExist(hits, Global.DROPED_ITEM_PREFIX, false) == false)
                    {
                        ShowToolTip((tableController.tableName == string.Empty) ? "table" : tableController.tableName,
                                    PrintRed(Global.Tooltip.NO_ACTIONS));
                    }
                    else if (IsCurrentHandEmpty() && IsObjectExist(hits, Global.DROPED_ITEM_PREFIX, false) == true)
                    {
                        Item itemOnTable = FindRaycast(hits, Global.DROPED_ITEM_PREFIX, false)?.collider
                                           .GetComponent <ItemCell>().item;

                        ShowToolTip((tableController.tableName == string.Empty) ? "table" + " (" + itemOnTable.itemName + ")"
                                                              : tableController.tableName + " (" + itemOnTable.itemName + ")",
                                    Global.Tooltip.LM_PICK_UP);
                    }
                    else if (IsCurrentHandEmpty() == false && IsObjectExist(hits, Global.DROPED_ITEM_PREFIX, false) == true)
                    {
                        Item         tool           = controller.GetItemInHand(controller.currentHand);
                        RaycastHit2D?itemOnTableHit = FindRaycast(hits, Global.DROPED_ITEM_PREFIX, false);
                        Item         temOnTable     = itemOnTableHit.GetValueOrDefault().collider.GetComponent <ItemCell>().item;

                        ItemCraftData craftData = CraftController.FindRecept_Static(tool, temOnTable,
                                                                                    CraftType.Cooking, /* TODO */
                                                                                    CraftTable.Table);

                        ShowToolTip((tableController.tableName == string.Empty) ? "table" + " (" + temOnTable.itemName + ")"
                                                              : tableController.tableName + " (" + temOnTable.itemName + ")",
                                    Global.Tooltip.LM_PUT + ((tableController.isCraftTable) ? ((craftData != null) ?
                                                                                               " / " + Global.Tooltip.RM_CRAFT + " " + craftData.recept.craftResult.itemName : string.Empty)
                                : string.Empty));
                    }
                    else
                    {
                        ShowToolTip((tableController.tableName == string.Empty) ? "table" : tableController.tableName,
                                    Global.Tooltip.LM_PUT);
                    }

                    TooltipLocate(hit.collider.transform.position);

                    return;
                }
                else if (hit.collider.name.Contains(Global.DROPED_ITEM_PREFIX))
                {
                    bool onTable = false;

                    foreach (var hitTable in hits)
                    {
                        if (hitTable.collider.tag == "table")
                        {
                            onTable = true;
                        }
                    }

                    if (onTable == false)
                    {
                        Item item       = hit.collider.GetComponent <ItemCell>().item;
                        Item itemInHand = controller.currentHand.GetComponent <ItemCell>().item;

                        isdetected = true;

                        string useInteraction = (item.itemSubstitution.IsSubstituted() == true && item.itemSubstitution.IsItemToUseExist(itemInHand)) ? " / " + Global.Tooltip.RM_TURN_ON : string.Empty;

                        ShowToolTip(item.itemName, (controller.IsEmpty(controller.currentHand) == true) ?
                                    Global.Tooltip.LM_PICK_UP + useInteraction
                            : ((useInteraction == string.Empty) ? PrintRed(Global.Tooltip.NO_ACTIONS) : useInteraction.Substring(" / ".Length)));

                        TooltipLocate(hit.collider.transform.position);

                        return;
                    }
                }
                else if (hit.collider.tag == "case")
                {
                    CaseController caseController = hit.collider.GetComponent <CaseController>();

                    isdetected = true;

                    ShowToolTip((caseController.caseName == string.Empty) ? "case" : caseController.caseName, (caseController.isOpen == false)
                                ? Global.Tooltip.LM_OPEN : Global.Tooltip.LM_CLOSE);

                    TooltipLocate(hit.collider.transform.position);

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

                    isdetected = true;
                    //tooltipPosition = Camera.main.WorldToScreenPoint(hit.collider.transform.position);

                    ShowToolTip("tv", (tvController.IsTvOpen() == false)
                                ? Global.Tooltip.LM_TURN_ON : Global.Tooltip.LM_TURN_OFF + " / " + Global.Tooltip.RM_NEXT_CHANNEL);
                    TooltipLocate(hit.collider.transform.position);

                    return;
                }
                else if (hit.collider.tag == "envObj")
                {
                    VendingController vending = hit.collider.GetComponent <VendingController>();

                    isdetected = true;
                    //tooltipPosition = Camera.main.WorldToScreenPoint(hit.collider.transform.position +
                    //                                                Global.Tooltip.EnvObjOffset());

                    ShowToolTip((vending.headerTitle == string.Empty) ? "vending" : vending.headerTitle.ToLower(),
                                Global.Tooltip.LM_USE);
                    TooltipLocate(hit.collider.transform.position);

                    return;
                }
                else if (hit.collider.tag == "pc")
                {
                    Item         itemInHand   = controller.currentHand.GetComponent <ItemCell>().item;
                    PCController pcController = hit.collider.GetComponent <PCController>();
                    Item         disk         = pcController.disk;

                    isdetected = true;
                    //tooltipPosition = Camera.main.WorldToScreenPoint(hit.collider.transform.position);

                    if (disk != null && controller.IsEmpty(controller.currentHand))
                    {
                        ShowToolTip("pc", Global.Tooltip.LM_INTERACT + " / " + Global.Tooltip.RM_PULL_THE_DISK);
                    }
                    else
                    {
                        ShowToolTip("pc", (controller.IsEmpty(controller.currentHand) == false &&
                                           itemInHand.itemName.Contains("disk"))
                                ? Global.Tooltip.LM_INTERACT + " / " + Global.Tooltip.RM_INSERT : Global.Tooltip.LM_INTERACT);
                    }

                    TooltipLocate(hit.collider.transform.position);
                }
                else if (hit.collider.tag == "playerAction")
                {
                    if (controller.IsEmpty(controller.currentHand) == false &&
                        controller.GetItemInHand(controller.currentHand).itemBuff.buff != null)
                    {
                        playerTooltip.gameObject.SetActive(true);
                    }
                    else
                    {
                        playerTooltip.gameObject.SetActive(false);
                    }

                    return;
                }
                else if (hit.collider.gameObject.name.Contains(Global.ITEM_SWITCH_PREFIX))
                {
                    isdetected = true;
                    ISwitchItem switchItem = hit.collider.GetComponent <ISwitchItem>();
                    Item        itemInHand = controller.GetItemInHand(controller.currentHand);

                    ShowToolTip(switchItem.GetISwitchName(), (itemInHand.IsSameItems(switchItem.GetNeedItem()) ?
                                                              Global.Tooltip.RM_INSERT : PrintRed(Global.Tooltip.NO_ACTIONS)));
                    TooltipLocate(hit.collider.transform.position);
                }
                else
                {
                    isdetected = false;
                }

                //playerTooltip.gameObject.SetActive(hit.collider.tag == "player");
            }

            playerTooltip.gameObject.SetActive(false);

            if (isTooltipOpen == true && isdetected == false)
            {
                HideToolTip();
            }
        }
        else
        {
            if (isTooltipOpen == true)
            {
                HideToolTip();
            }
        }
    }