Beispiel #1
0
        void Start()
        {
            base.Initialise();

            connectedSwitch = gameObject.GetComponent <InteractiveItemSwitch>();

            isInventoryItem = gameObject.GetComponent <InventoryItem>() != null;
        }
Beispiel #2
0
        void Start()
        {
            base.Initialise();

            advCam        = PersistentEngine.advCamera;
            advCamCanMove = advCam.canMove;

            connectedSwitch = GetComponent <InteractiveItemSwitch>();
            if (colliderDisabled)
            {
                this.GetComponent <Collider2D>().enabled = false;
            }
        }
Beispiel #3
0
        // Use this for initialization
        void Awake()
        {
            if (isGlobal)
            {
                base.InitialiseGlobal();
            }
            else
            {
                base.Initialise();
            }

            connectedSwitch = gameObject.GetComponent <InteractiveItemSwitch>();
            if (connectedSwitch != null)
            {
                connectedSwitch.ProcessOnlyOnce(true);
            }
        }
Beispiel #4
0
        void LateUpdate()
        {
            if (isHidden)
            {
                return;
            }

            string text = "";

            cursorRotation = 0;
            CursorState newState  = CursorState.IDLE;
            Camera      cam       = PersistentEngine.activeCamera ? PersistentEngine.activeCamera : Camera.main;
            int         lastLayer = -10000;

            if (!cam || (player && player.inCutScene && !inPuzzle && !player.inConversation))
            {
                newState = CursorState.INVISIBLE;
            }
            else if (player && player.inConversation)
            {
                newState = CursorState.IDLE;
            }
            else
            {
                pos   = cam.ScreenToWorldPoint(Input.mousePosition);
                pos.z = 0;
                myTransform.position = pos;                                             //move to mouse pos

                float height = cam.orthographicSize * 2;

                sca   = Vector3.one * height / 25f;
                sca.z = 1;
                myTransform.localScale = sca;

                Collider2D[] col = Physics2D.OverlapPointAll(transform.position);       //get all colliders
                                                                                        //default state is idle
                if (inPuzzle)
                {
                    newState = CursorState.PUZZLE_EXIT;                                 //default state in puzzle is exit
                    if (!puzzleHasBackground)
                    {
                        newState = CursorState.IDLE;                                    //if puzzle has no background default is idle
                    }
                }
                if (inPuzzle && cursorState == CursorState.PUZZLE_HOLD_ITEM &&
                    Input.GetButton("Fire1"))                                           //if in puzzle and holding object do nothing
                {
                    return;
                }

                int lastColliderLayer = int.MinValue;


                foreach (Collider2D c in col)
                {
                    var ii = c.gameObject.GetComponent <InteractiveItem>();

                    if (ii && ii.itemLayer < lastColliderLayer)
                    {
                        continue;
                    }
                    else
                    {
                        if (ii)
                        {
                            lastColliderLayer = ii.itemLayer;
                        }
                    }

                    if (ii && ii.noClickBackground)
                    {
                        newState = CursorState.IDLE;

                        cursorRotation = 0;
                        text           = "";
                        continue;
                    }

                    if (inPuzzle)                                                       //if in puzzle
                    {
                        if (c.gameObject.layer == 13)                                   //if in puzzle and active object
                        {
                            newState = CursorState.PUZZLE_OVER_ITEM;
                            if (Input.GetButton("Fire1"))
                            {
                                newState = CursorState.PUZZLE_HOLD_ITEM;
                            }
                            text = "";
                            break;
                        }

                        if (c.gameObject.layer == 15)                                   //if in puzzle over background
                        {
                            newState       = CursorState.IDLE;
                            cursorRotation = 0;
                            text           = "";
                        }
                    }
                    else
                    {
                        if (c.gameObject.layer == 15)                                   //if in puzzle over background
                        {
                            newState       = CursorState.IDLE;
                            cursorRotation = 0;
                            text           = "";
                        }

                        if (c.gameObject.layer == 10)
                        {
                            var d = c.gameObject.GetComponent <DoorBetweenLevels>();
                            if (d == null || !d.enabled)     //if over item
                            {
                                newState = CursorState.ACTIVE;
                            }
                            else
                            {
                                DoorBetweenLevels     door1      = c.gameObject.GetComponent <DoorBetweenLevels>();
                                InteractiveItemSwitch switchItem = c.gameObject.GetComponent <InteractiveItemSwitch>();
                                if (switchItem != null)         //if over door with swithc on
                                {
                                    if (door1.enableOnlyForSwitchState != InteractiveItemSwitch.State.ANY && door1.enableOnlyForSwitchState != switchItem.state)
                                    {
                                        //newState = CursorState.ACTIVE;
                                        newState = CursorState.DOOR;
                                    }
                                    else
                                    {
                                        newState = CursorState.DOOR;
                                    }
                                }
                                else
                                {
                                    newState = CursorState.DOOR;
                                }
                            }
                            InteractiveItem item = c.gameObject.GetComponent <InteractiveItem>();
                            if (item && item.enabled && item.itemLayer > lastLayer)                       //set text from interactive item
                            {
                                lastLayer = item.itemLayer;
                                if (!string.IsNullOrEmpty(item.objectName))
                                {
                                    text = item.objectName;
                                }
                                else
                                {
                                    text = item.name;
                                }

                                cursorRotation = item.cursorRotation * -1;
                                rot.z          = item.cursorRotation;  //rotate pointer to rotation set on interactive item
                                if (pointer)
                                {
                                    pointer.localEulerAngles = rot;
                                }
                            }
                        }
                        if (c.gameObject.layer == 11)           //added to disable highlightning over Inventory
                        {
                            newState = CursorState.IDLE;
                            text     = "";
                            //break;
                        }
                    }
                }
            }

            if (PersistentEngine.inventory != null)
            {
                var invItem = PersistentEngine.inventory.ItemHoveringOver();
                if (invItem != null)
                {
                    newState = CursorState.PUZZLE_OVER_ITEM;
                    text     = invItem.interactiveItem.GetObjectName();
                }
            }

            cursorState = newState;
            animator.SetInteger("state", (int)cursorState);
            if (text != lines[0].text)
            {
                foreach (TextMeshPro line in lines)
                {
                    line.text = text;
                }
            }
            if (newState == CursorState.PUZZLE_EXIT && Input.GetButtonDown("Fire1"))
            {
                foreach (GameObject g in puzzles)
                {
                    g.SendMessage("CloseClickedGUI", SendMessageOptions.DontRequireReceiver);
                }
            }
        }
 void Start()
 {
     base.Initialise();
     sw = GetComponent <InteractiveItemSwitch>();
 }
Beispiel #6
0
 public void Start()
 {
     base.Initialise();
     connectedSwitch = gameObject.GetComponent <InteractiveItemSwitch>();
     dialogControl   = GameObject.Find("DialogControl") ? GameObject.Find("DialogControl").GetComponent <DialogControl>() : null;
 }
Beispiel #7
0
        void HighlightIfOverInteractiveItem()
        {
            if (true)
            {
                bool enable = false;

                Collider2D[] col = Physics2D.OverlapPointAll(transform.position);

                var hoveredItem = inventory.ItemHoveringOver();
                if (hoveredItem != null && hoveredItem != this)
                {
                    enable = true;
                    SetHighlight(enable);
                }

                if (col.Length > 0)
                {
                    foreach (Collider2D c in col)
                    {
                        if (c.gameObject.layer == 10)
                        {
                            if (c.gameObject.GetComponent <DoorBetweenLevels>() == null)
                            {
                                enable = true;
                            }
                            else
                            {
                                DoorBetweenLevels     door       = c.gameObject.GetComponent <DoorBetweenLevels>();
                                InteractiveItemSwitch switchItem = c.gameObject.GetComponent <InteractiveItemSwitch>();
                                if (switchItem != null)
                                {
                                    if (door.enableOnlyForSwitchState != InteractiveItemSwitch.State.ANY && door.enableOnlyForSwitchState != switchItem.state)
                                    {
                                        enable = true;
                                    }
                                }
                            }
                            if (c.gameObject.GetComponent <InventoryItem>() != null)
                            {
                                InteractiveItem intItem = c.gameObject.GetComponent <InteractiveItem>();
                                bool            doBreak = false;
                                foreach (InventoryItem invItem1 in intItem.CanBeCombinedWith)
                                {
                                    if (invItem1 == this)
                                    {
                                        enable  = true;
                                        doBreak = true;
                                        break;
                                    }
                                }
                                if (doBreak)
                                {
                                    break;
                                }
                            }
                        }
                        if (c.gameObject.layer == 11)
                        {  //added to disable highlightning over Inventory
                            enable = false;
                            break;
                        }
                    }
                }

                SetHighlight(enable);
            }
        }