Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, moveMask))
            {
                // Move Player to Target Location
                motor.moveTo(hit.point);
                Debug.Log("We hit" + hit.collider + "at " + hit.point);

                removeFocus();
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, moveMask))
            {
                // Move Player to Target Location
                Interactables interactable = hit.collider.GetComponent <Interactables>();
                if (interactable != null)
                {
                    setFocus(interactable);
                }
                motor.moveTo(hit.point);
                Debug.Log("We hit" + hit.collider + "at " + hit.point);
            }
        }
    }
Example #2
0
    // Start following a target
    public void FollowTarget(Interactables newTarget)
    {
        agent.stoppingDistance = newTarget.radius * radiusMult;
        agent.updateRotation   = false;

        target = newTarget.interationTransform;
    }
    private void CheckRaycast()
    {
        ray = new Ray(rayOrigin.transform.position, rayOrigin.transform.forward);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.distance < minInteractionDistance)
            {
                interact = hit.transform.gameObject.GetComponent <Interactables>();

                if (interact != null)
                {
                    // Debug.Log(interact.GetInteractionMessage());

                    isInteractable = true;
                }
                else
                {
                    isInteractable = false;
                }
            }
        }
    }
Example #4
0
        protected override void Awake()
        {
            base.Awake();

            Interactables = GetComponent <Interactables>();
            Interactables.InteractableAddedEvent += InteractableAddedEventHandler;
        }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, movementMask))
            {
                //Debug.Log("We hit "+ hit.collider.name + " " + hit.point );
                motor.MoveToPoint(hit.point);
                RemoveFocus();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                //Debug.Log("We hit "+ hit.collider.name + " " + hit.point );
                //motor.MoveToPoint(hit.point);
                Interactables interactable = hit.collider.GetComponent <Interactables>();
                if (interactable != null)
                {
                    SetFocus(interactable);
                }
                //This if is for interactibles
            }
        }
    }
Example #6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Interactable")
     {
         in_InteractRange    = true;
         currentInteractable = collision.GetComponent <Interactables>();
     }
 }
Example #7
0
        public async Task Save()
        {
            await Locations.Save();

            await CharacterBackups.Save();

            await Interactables.Save();
        }
 void RemoveFocus()
 {
     if (focus != null)
     {
         focus.OnDefocused();
     }
     focus = null;
 }
Example #9
0
        private void KeyboardSelection(KeyboardState keyboardState)
        {
            if (Interactables.Count > 0)
            {
                //If no interactable has been selected, select the first one:
                if (kb_selectedInteractable == null && keyboardState.GetPressedKeys().Length > 0)
                {
                    kb_selectedInteractable = Interactables[0];
                    kb_selectedInteractable.Select();

                    return;
                }

                if (keyboardState.IsKeyDown(Keys.Up) || keyboardState.IsKeyDown(Keys.Tab))
                {
                    int nextIndex = Interactables.IndexOf(kb_selectedInteractable) - 1;

                    if (nextIndex < 0)
                    {
                        nextIndex = Interactables.Count - 1;
                    }

                    //Only deselect the current interactable if it's not currently selected by the mouse.
                    if (kb_selectedInteractable != ms_selectedInteractable)
                    {
                        kb_selectedInteractable.Deselect();
                    }

                    kb_selectedInteractable = Interactables[nextIndex];
                    kb_selectedInteractable.Select();
                }
                else if (keyboardState.IsKeyDown(Keys.Down) || (keyboardState.IsKeyDown(Keys.Tab) && keyboardState.IsKeyDown(Keys.LeftShift)))
                {
                    int nextIndex = Interactables.IndexOf(kb_selectedInteractable) + 1;

                    if (nextIndex >= Interactables.Count)
                    {
                        nextIndex = 0;
                    }

                    //Only deselect the current interactable if it's not currently selected by the mouse.
                    if (kb_selectedInteractable != ms_selectedInteractable)
                    {
                        kb_selectedInteractable.Deselect();
                    }

                    kb_selectedInteractable = Interactables[nextIndex];
                    kb_selectedInteractable.Select();
                }

                //Keyboard selection callback:
                if (kb_selectCallbacks != null)
                {
                    kb_selectCallbacks.SetArguments(kb_selectedInteractable);
                    kb_selectCallbacks.Invoke();
                }
            }
        }
    public static void AddSceneAdditive() {
        if (CurrentTarget != null) {
			MetagameController.RecordPlayerPosition();
			MetagameController.SetNextSceneToLoad (CurrentTarget.MiniGameName);
			MetagameController.SetNextSplashScreenBackground (CurrentTarget.SplashBackground);
            CurrentTarget = null;
			SceneManager.LoadScene("SplashScreen");
        }
    }
Example #11
0
 void RemoveFocus()
 {
     if (focus != null)
     {
         focus.OnDefocused();
     }
     focus = null;
     motor.StopFollowingTarget();
 }
Example #12
0
        /// <summary>
        /// Tries to add the UI Element as an interactable. Returns true if it succeeded, false if it didn't.
        /// </summary>
        public bool AddInteractable(UIElement uiElement)
        {
            if (uiElement is IInteractable interactable)
            {
                Interactables.Add(interactable);

                return(true);
            }

            return(false);
        }
 void SetFocus(Interactables newFocus)
 {
     if (newFocus != focus)
     {
         if (focus != null)
         {
             focus.OnDefocused();
         }
         focus = newFocus;
     }
     newFocus.OnFocused(transform);
 }
Example #14
0
 public RoomWrapper(Room r)
 {
     RoomBase = r;
     foreach (var exit in r.Exits)
     {
         Exits.Add(new ExitWrapper(exit));
     }
     foreach (var interactable in r.DefaultInteractables)
     {
         Interactables.Add(new InteractableWrapper(interactable.LinkedInteractable));
     }
 }
Example #15
0
 void SetFocus(Interactables newFocus)
 {
     if (newFocus != focus)
     {
         if (focus != null)
         {
             focus.OnDefocused();
         }
         focus = newFocus;
         motor.FollowTarget(newFocus);
     }
     newFocus.OnFocused(transform);
 }
Example #16
0
    void Interact()
    {
        RaycastHit hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, 10))
        {
            Interactables interactable = hit.collider.GetComponent <Interactables>();

            if (interactable != null)
            {
                interactable.Interact();
            }
        }
    }
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                Interactables interactable1 = hit.collider.GetComponent <Interactables>();
                Debug.Log("Hit something.");
            }
        }
    }
        public void ParseOverworld(BinaryReader b)
        {
            uint fileSize = b.ReadUInt32();

            if (fileSize < 0x4)
            {
                b.Close();
                throw new Exception("Invalid overworld container.");
            }

            byte interactableCount = b.ReadByte();
            byte npcCount          = b.ReadByte();
            byte warpCount         = b.ReadByte();
            byte triggerCount      = b.ReadByte();

            for (int i = 0; i < interactableCount; ++i)
            {
                Interactables.Add(new Interactable(b));
            }

            for (int i = 0; i < npcCount; ++i)
            {
                NPCs.Add(new NPC(b));
            }

            for (int i = 0; i < warpCount; ++i)
            {
                Warps.Add(new Warp(b));
            }

            for (int i = 0; i < triggerCount; ++i)
            {
                Triggers.Add(new Trigger(b));
            }

            while (b.PeekChar() != 0)
            {
                LevelScripts.Add(new LevelScriptDeclaration(b));
            }

            b.BaseStream.Position += 0x2;

            int index = 0;

            while (b.PeekChar() != 0 && b.PeekChar() != -1 && index < LevelScripts.Count)
            {
                LevelScripts[index++].Data = new LevelScriptData(b);
            }
        }
	private void FireRayToInteractable ()
	{
		Transform cameraTransform = m_PlayerCamera.transform;
		Ray ray = new Ray (cameraTransform.position, cameraTransform.forward);
		RaycastHit hit;
		bool hitInteractable = Physics.Raycast (ray, out hit, 10.0f, collisionMask);

		if (hitInteractable) {
			CurrentTarget = hit.collider.GetComponentInParent<Interactables> ();
			if (!MetagameController.HasPlayedGame (CurrentTarget.MiniGameId)) {
				MetagameController.SetPlayedGame (CurrentTarget.MiniGameId);
                m_cachedFaderAnimator.SetBool("FadeOut", true);
            }
		}
	}
    IEnumerator MovingObject(Interactables obj, Vector3 position)
    {
        obj.isMoving = true;
        float timer = 0;

        while (timer < 1)
        {
            obj.transform.position = Vector3.Lerp(obj.transform.position, position, Time.deltaTime * 5);
            timer += Time.deltaTime;
            yield return(null);
        }

        obj.transform.position = position;
        obj.isMoving           = false;
    }
Example #21
0
    public override void TakeDamage(int dmg, Interactables tag)
    {
        base.TakeDamage(dmg, tag);
        critter.animator.SetTrigger("hit");

        if (currentHealth <= 0)
        {
            critter.Die();
            return;
        }
        else
        {
            critter.behaviourController.AddNewInteraction(tag, State.Threatened);
        }
        critter.critterStats.UpdateHP(currentHealth);
    }
Example #22
0
        /// <summary>
        /// Adds a UI Element and makes it interactable if it implements <see cref="IInteractable"/> and scrollable if it implements <see cref="IScrollable"/>.
        /// </summary>
        /// <typeparam name="T">UIElement descendant of type T.</typeparam>
        /// <param name="uiElement">The UI Element to add.</param>
        /// <returns>Returns the craeted UI Element.</returns>
        public T AddUIElement <T>(T uiElement) where T : UIElement
        {
            UIElements.Add(uiElement);

            if (uiElement is IInteractable interactable)
            {
                Interactables.Add(interactable);
            }

            if (uiElement is IScrollable scrollable)
            {
                Scrollables.Add(scrollable);
            }

            return(uiElement);
        }
Example #23
0
        private void Awake()
        {
            _interactables = GetComponent <Interactables>();

            GameManager.Instance.GameUnReadyEvent        += GameUnReadyEventHandler;
            GameManager.Instance.LevelTransitioningEvent += LevelTransitioningEventHandler;
            GameManager.Instance.LevelEnterEvent         += LevelEnterEventHandler;
            GameManager.Instance.GoalScoredEvent         += GoalScoredEventHandler;
            GameManager.Instance.RoundWonEvent           += RoundWonEventHandler;

            _teleportTimer = TimeManager.Instance.AddTimer();

            _launchAnimationEffectTriggerComponent.StartEvent    += LaunchAnimationStartHandler;
            _launchAnimationEffectTriggerComponent.CompleteEvent += LaunchAnimationCompleteHandler;

            InitDebugMenu();
        }
Example #24
0
        /// <summary>
        /// Removes the UI Element.
        /// </summary>
        public void RemoveUIElement(UIElement uiElement)
        {
            UIElements.Remove(uiElement);

            if (uiElement is IInteractable interactable)
            {
                Interactables.Remove(interactable);

                //Deactivate forced focus:
                if (ForceFocusedInteractable == interactable)
                {
                    ForceFocusOn             = false;
                    ForceFocusedInteractable = null;
                }

                //Unselect it from the "keyboard":
                if (kb_selectedInteractable == interactable)
                {
                    kb_selectedInteractable = null;
                }

                //Unselect it from the "mouse":
                if (ms_selectedInteractable == interactable)
                {
                    ms_selectedInteractable = null;
                }
            }

            if (uiElement is IScrollable scrollable)
            {
                Scrollables.Remove(scrollable);
            }

            if (uiElement is IContainer container)
            {
                foreach (UIElement child in container.Children)
                {
                    RemoveUIElement(child);
                }
            }

            uiElement.OnDestroy();
        }
Example #25
0
        // still_todo: perhaps change to message received? Or handle separately?
        private void Mh_TodoCreated(object sender, TodoCreatedEventArgs e)
        {
            Console.WriteLine("MESSAGE ACCEPTED IN VM!");
            // filter interatables, do logic
            var toDo = e.Todo;

            // still_todo: ask for this logic, why? Resolve in AM-2683
            // still_todo: implement backend helper or something like that
            //if (toDo.Assignee == null && Interactables.Any(x => x != toDo && x.Blocking && !x.InteractionPending))
            //{
            //    //await BackendHelper.DeclineTodoAsync(toDo, true, false);
            //    toDo.RabbitEventHeader = "DECLINED_BECAUSE_BLOCKED";
            //}


            //if we added a new interactable
            Interactables.Add(e.Todo);
            Settings.Interactables = Interactables;
        }
Example #26
0
    private void Awake()
    {
        defs     = this.GetComponent <Defenses>();
        inter    = this.GetComponent <Interactables>();
        wave     = this.GetComponent <WaveController>();
        santa    = FindObjectOfType <Santa>();
        cam      = FindObjectOfType <Camera>();
        building = GameObject.FindGameObjectWithTag("Building").GetComponent <Building>();
        if (instance != null && instance != this)
        {
            // Destroy(this.gameObject);
            //temp TODO REPLACE to enable quick restart
            Destroy(instance.gameObject);
        }

        instance = this;
        DontDestroyOnLoad(this.gameObject);

        wave.LoadNextWave();
    }
Example #27
0
    void checkInteractables()
    {
        RaycastHit hit; //essa variavel guarda as informaçoes do objeto que o raycast se colidiu
        Vector3    rayOrigin = myCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.5f));

        if (Physics.Raycast(rayOrigin, myCam.transform.forward, out hit, Raydistance))
        {
            // se o objeto tiver a o script Interactables vai colidir.
            Interactables interactable = hit.collider.GetComponent <Interactables>();
            if (interactable != null)
            {
                UIHudControl.instance.setHandCursor(true);
                //butao 0 seria o da esquerda .
                if (Input.GetMouseButtonDown(0))
                {
                    //o item atual da interaçao recebe do hit
                    currentInteractables = interactable;

                    //aqui no caso serve pra da play na animação ...
                    currentInteractables.OnInteract.Invoke();

                    if (currentInteractables.item.id == 1)
                    {
                        SceneManager.LoadScene("SwitchScenes");
                    }

                    //aqui poderia verificar se o item e possivel usar ... acessando currentInteractables.item

                    Debug.Log("Item Ativado :" + currentInteractables.name);
                }
            }
            else
            {
                UIHudControl.instance.setHandCursor(false);
            }
        }
        else
        {
            UIHudControl.instance.setHandCursor(false);
        }
    }
Example #28
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            //we create a ray
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //if the ray hits;
            if (Physics.Raycast(ray, out hit, 100))
            {
                //check if we hit an interactable
                Interactables interact = hit.collider.GetComponent <Interactables>();
                if (interact != null)
                {
                    //setfocus on the interactable
                    SetFocus(interact);
                    //collect it
                }
            }
        }
    }
Example #29
0
    // Update is called once per frame
    void Update()
    {
        if (selected == true)
        {
            Debug.Log("selected");
            if (Input.GetMouseButtonDown(1))
            {
                Debug.Log("moving");
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 20000, movementMask))
                {
                    motor.MoveToPoint(hit.point);
                    //Move to

                    RemoveFocus();
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 20000))
                {
                    Interactables interactable = hit.collider.GetComponent <Interactables>();
                    if (interactable != null)
                    {
                        SetFocus(interactable);
                    }
                }
            }
        }
    }
    public void AddNewInteraction(Interactables tag, State state, CritterBehaviour behaviour = null)
    {
        foreach (CritterInteraction interaction in critter.critterInteractions)
        {
            if (interaction.interactableTag == tag)
            {
                if (interaction.inducedState == state)
                {
                    return;
                }
                else
                {
                    critter.critterInteractions.Remove(interaction);
                    break;
                }
            }
        }
        CritterInteraction newInteraction = new CritterInteraction();

        newInteraction.interactableTag = tag;
        newInteraction.inducedState    = state;
        newInteraction.behaviour       = behaviour;
        critter.critterInteractions.Add(newInteraction);
    }
Example #31
0
        //private bool isFuture;

        /// <summary>
        /// Creates a level given a file name and a dictionary of tile textures to use
        /// </summary>
        public Level(String fileName, Dictionary <String, Texture2D> tileTextures)
        {
            myRNG         = new Random();
            tileVariant   = 0;
            interactables = new List <Interactable>();
            recepticles   = new List <Recepticle>();
            indicators    = new List <Indicator>();
            doors         = new List <Point>();
            tiles         = new Tile[12, 16];
            //finds file, creates holder string for reader
            StreamReader reader = new StreamReader(fileName);
            String       line   = "";

            String[] words;

            //for every tile in the 2D array:\
            //checks if this tile is a floor tile is past and/or future
            //if floor, make it non-collidable in that timeState
            //otherwise, it is collidable
            for (int h = 0; h < 12; h++)
            {
                for (int w = 0; w < 16; w++)
                {
                    line = reader.ReadLine();
                    //ignore documented lines in Level files
                    if (line[0] != '/')
                    {
                        tileVariant = myRNG.Next(20) + 1;

                        if (tileVariant == 17)
                        {
                            tileVariant = 1;
                        }
                        else if (tileVariant == 18)
                        {
                            tileVariant = 2;
                        }
                        else if (tileVariant == 19)
                        {
                            tileVariant = 3;
                        }
                        else if (tileVariant == 20)
                        {
                            tileVariant = 4;
                        }
                        else
                        {
                            tileVariant = 0;
                        }

                        words = line.Split(' ');

                        //handles situations where both, one, or neither time state is collidable
                        //HEY YOURE GONNA HAVE TO FIX THIS LATER
                        //^^this is bad documentation
                        //I think I fixed this, because this only generates an error with out-of-date level files
                        if (words[0] == "door" || words[0] == "OpenDoorExtHoriz" || words[0] == "OpenDoorExtVert" || words[0] == "OpenDoorIntVert" || words[0] == "OpenDoorIntVert" ||
                            words[2] == "door" || words[2] == "OpenDoorExtHoriz" || words[2] == "OpenDoorExtVert" || words[2] == "OpenDoorIntVert" || words[2] == "OpenDoorIntVert")
                        {
                            tiles[h, w] = new Door(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), false,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), false, 1);
                            doors.Add(new Point(h, w));
                        }
                        else if (words[0] == "LockedDoorExtHoriz" || words[0] == "LockedDoorExtVert" || words[0] == "LockedDoorIntVert" || words[0] == "LockedDoorIntVert" ||
                                 words[2] == "LockedDoorExtHoriz" || words[2] == "LockedDoorExtVert" || words[2] == "LockedDoorIntVert" || words[2] == "LockedDoorIntVert")
                        {
                            tiles[h, w] = new Door(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), true,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), true, 1);
                            doors.Add(new Point(h, w));
                        }
                        else if (words[0] == "Floor" && words[2] == "Floor")
                        {
                            tiles[h, w] = new Tile(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), false,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), false, 1);
                        }
                        else if (words[0] == "Floor" && words[2] != "Floor")
                        {
                            tiles[h, w] = new Tile(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), false,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), true, 1);
                        }
                        else if (words[0] != "Floor" && words[2] == "Floor")
                        {
                            tiles[h, w] = new Tile(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), true,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), false, 1);
                        }
                        //HEY YOURE GONNA HAVE TO FIX THIS LATER
                        //see above document
                        else if (words[0] != "Floor" && words[2] != "Floor")
                        {
                            tiles[h, w] = new Tile(
                                new Rectangle((w * 64), (h * 64), 64, 64),
                                new AnimatedTexture(0, 32, 32, tileTextures["Past" + words[0]]), int.Parse(words[1]), true,
                                new AnimatedTexture(0, 32, 32, tileTextures["Future" + words[2] + tileVariant]), int.Parse(words[3]), true, 1);
                        }
                    }
                    //this part of if ladder just makes sure that skipping lines due to documentation in the level files
                    //doesn't skip a tile
                    else if (w == 0)
                    {
                        w = 15;
                        h--;
                    }
                    else
                    {
                        w--;
                    }
                }
            }

            //begin interactable stuff
            while (true)
            {
                line = reader.ReadLine();
                if (line == null || line == "/recepticles")
                {
                    break;
                }
                words = line.Split(' ');
                if (words.Length < 4)
                {
                    continue;
                }
                string    interactableName  = words[0];
                string    interactableState = words[1];
                int       gridX             = int.Parse(words[2]);
                int       gridY             = int.Parse(words[3]);
                Rectangle r = new Rectangle(gridX * 64, gridY * 64, 64, 64);
                switch (interactableName)
                {
                case "Chicken":
                    interactables.Add(new Chicken(r, (ChickenState)Enum.Parse(typeof(ChickenState), interactableState), 1, this));
                    break;

                case "Flower":
                    interactables.Add(new Flower(r, (FlowerState)Enum.Parse(typeof(FlowerState), interactableState), 1, this));
                    break;

                case "Tree":
                    interactables.Add(new Tree(r, (TreeState)Enum.Parse(typeof(TreeState), interactableState), 1, this));
                    break;

                case "WateringCan":
                    interactables.Add(new WateringCan(r, (WateringCanState)Enum.Parse(typeof(WateringCanState), interactableState), 1, this));
                    break;

                case "Shovel":
                    interactables.Add(new Shovel(r, (ShovelState)Enum.Parse(typeof(ShovelState), interactableState), 1, this));
                    break;

                case "Axe":
                    Interactables.Add(new Axe(r, (AxeState)Enum.Parse(typeof(AxeState), interactableState), 1, this));
                    break;
                }
            }

            //skip documentation line in level file
            line = reader.ReadLine();

            //handles recepticles
            while (line != null)
            {
                //to store coordinates of the door
                String[] doorCoord;
                //a temporary reference to a door that needs to be linked to this recepticle
                Tile door;
                //a temporary reference to this recepticle
                Recepticle r;

                words = line.Split(' ');

                if (words[0] == "Past")
                {
                    r = new Recepticle(
                        TimeState.Past,
                        (words[1] + "_" + words[2]),
                        new Rectangle(int.Parse(words[4]) * 64, int.Parse(words[3]) * 64, 64, 64));

                    //loops through remainder of words
                    //which are only coordinates for doors to link to the recepticles
                    for (int i = 5; i < words.Length; i++)
                    {
                        doorCoord = words[i].Split(',');
                        //find that door
                        door = tiles[int.Parse(doorCoord[1]), int.Parse(doorCoord[0])];
                        ((Door)(door)).LinkRecepticle(r);
                    }
                    recepticles.Add(r);
                }
                else if (words[0] == "Future")
                {
                    r = new Recepticle(
                        TimeState.Future,
                        (words[1] + "_" + words[2]),
                        new Rectangle(int.Parse(words[4]) * 64, int.Parse(words[3]) * 64, 64, 64));

                    //loops through remainder of words
                    //which are only coordinates for doors to link to the recepticles
                    for (int i = 5; i < words.Length; i++)
                    {
                        doorCoord = words[i].Split(',');
                        //find that door
                        door = tiles[int.Parse(doorCoord[1]), int.Parse(doorCoord[0])];
                        ((Door)(door)).LinkRecepticle(r);
                    }
                    recepticles.Add(r);
                }

                //go to next line
                line = reader.ReadLine();
            }
        }
    void CheckInteractables()
    {
        if (isViewing)
        {
            if (currentInteractable.item.grabbable && Input.GetMouseButton(0))
            {
                RotateObject();
            }

            if (canFinish && Input.GetMouseButtonDown(1))
            {
                FinishView();
            }

            return;
        }

        RaycastHit hit;
        Vector3    rayOrigin = myCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.5f));

        if (Physics.Raycast(rayOrigin, myCam.transform.forward, out hit, rayDistance))
        {
            Interactables interactable = hit.collider.GetComponent <Interactables>();
            if (interactable != null)
            {
                UIManager.instance.SetHandCursor(true);
                if (Input.GetMouseButtonDown(0))
                {
                    if (interactable.isMoving)
                    {
                        return;
                    }


                    currentInteractable = interactable;

                    currentInteractable.OnInteract.Invoke();

                    if (currentInteractable.item != null)
                    {
                        OnView.Invoke();

                        isViewing = true;

                        bool hasPreviousItem = false;

                        for (int i = 0; i < currentInteractable.previousItem.Length; i++)
                        {
                            if (inventory.itens.Contains(currentInteractable.previousItem[i].requiredItem))
                            {
                                Interact(currentInteractable.previousItem[i].interactionItem);
                                currentInteractable.previousItem[i].OnInteract.Invoke();
                                hasPreviousItem = true;
                                break;
                            }
                        }

                        if (hasPreviousItem)
                        {
                            return;
                        }

                        Interact(currentInteractable.item);

                        if (currentInteractable.item.grabbable)
                        {
                            originPosition = currentInteractable.transform.position;
                            originRotation = currentInteractable.transform.rotation;
                            StartCoroutine(MovingObject(currentInteractable, objectViewer.position));
                        }
                    }
                }
            }
            else
            {
                UIManager.instance.SetHandCursor(false);
            }
        }
        else
        {
            UIManager.instance.SetHandCursor(false);
        }
    }
Example #33
0
 void Start() {
     inter = GetComponent<Interactables>();
 }
Example #34
0
 void Start() {
     inter = GetComponent<Interactables>();
     childMesh = this.GetComponentInChildren<MeshRenderer>();
 }