Exemplo n.º 1
0
        public override void Interact()
        {
            if (destroyed)
            {
                return;
            }

            SceneSaver.Instance.AddUsed(this.name);

            Logger.Log($"interacting with {EntityName}");

            if (runScriptOnInteraction)
            {
                LuaScript.Execute(script);
            }

            if (runYarnProgramOnInteraction)
            {
                FindObjectOfType <DialogueRunner>().StartDialogue(yarnNodeToStart);
            }

            if (destroyOnInteraction)
            {
                SceneSaver.Instance.AddDestroyed(this.name);
                destroyed = true;
                Destroy(this.gameObject);
            }
        }
Exemplo n.º 2
0
        // it means that journal has little notes in it
        private void DrawNoteText(string text)
        {
            Logger.Log($"drawing text in note");

            noteText.text = text;

            counterText.text = $"{currentNoteIndex + 1}/{_currentCollection.notes.Length}";
        }
Exemplo n.º 3
0
        public override void Interact()
        {
            Debug.Log("saving player position...");

            SceneSaver.Instance.SavePlayerPositionAtScene(SceneManager.GetActiveScene().name, GameManager.Instance.GetPlayerPosition());

            Logger.Log("LoadScene DevLocation");

            SceneManager.LoadScene(leadsTo);
        }
Exemplo n.º 4
0
        private void OnTriggerExit2D(Collider2D other)
        {
            Logger.Log("Trigger", "Player->OnTriggerExit2D");

#if UNITY_EDITOR
            interactableEntity?.StopHighlighting();
#endif

            interactableEntity = null;
        }
Exemplo n.º 5
0
        public override void StartTalking()
        {
            state = NPCState.Talking;

            Logger.Log("[NPC] StartTalking()");

            if (shouldExecScript)
            {
                LuaScript.Execute(dialogueScript);
            }
        }
        public override void Interact()
        {
            Logger.Log($"picking up {itemId}");

            // disable everything so we could dodge exceptions i guess
            GetComponent <SpriteRenderer>().enabled = false;
            GetComponent <BoxCollider2D>().enabled  = false;

            Destroy(this);

            GameManager.Instance.AddItemToInventory(itemId);
        }
Exemplo n.º 7
0
        public override void Interact()
        {
            Logger.Log($"Using computer {id}");

            ComputerUI.Instance.Context = this;

            if (locked)
            {
                // TODO: send computers id or object cause it looks like doesn't even know about
                // computer that player might wanna hack
                StartCoroutine(ComputerUI.Instance.DrawOnLockedMenu());
            }
        }
Exemplo n.º 8
0
        private void DrawNoteOfCharacter(string character)
        {
            foreach (NoteCollection coll in _currentJournal.collections)
            {
                if (coll.character != character)
                {
                    continue;
                }

                Logger.Log($"found {character}'s notes");
                _currentCollection = coll;
            }



            DrawNoteText(_currentCollection.notes[currentNoteIndex].text);
        }
Exemplo n.º 9
0
        void Update()
        {
            // TODO: there is not only pc version but also smartphone one
            // use either click/tocuh either some big button with "USE" text
            if (Input.GetKeyDown(KeyCode.E)) //interact with something
            {
                player.Interact();
            }

            // TODO: show inventory in UI
            else if (Input.GetKeyDown(KeyCode.I))
            {
                Logger.Log("===INVENTORY===");
                foreach (var item in _playerInventory)
                {
                    Logger.Log("ITEM " + item);
                }
                Logger.Log("===INVENTORY END===");
            }

            // TODO: maybe create menu for that
            else if (Input.GetKeyDown(KeyCode.C))
            {
                StartCoroutine(DialogueScript.Instance.StartDialogue("1a"));
            }

            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                StartCoroutine(WaitAndQuit());
            }

            else if (Input.GetKeyUp(KeyCode.Escape))
            {
                _quitByEsc = false;
            }

            else if (Input.GetKeyUp(KeyCode.Space))
            {
                var runner = FindObjectOfType <DialogueRunner>();

                if (runner.IsDialogueRunning)
                {
                    FindObjectOfType <DialogueUI>().MarkLineComplete();
                }
            }
        }
Exemplo n.º 10
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            Logger.Log("Trigger", "Player->OnTriggerEnter2D");

            interactableEntity = other.GetComponent <Entity>();

            if (interactableEntity is null)
            {
                Logger.Warning("didnt find interactableEntity, some entity either not interactable either something went wrong");
                return;
            }

            _interactableTag = other.tag;

#if  UNITY_EDITOR
            interactableEntity?.Highlight();
#endif
        }
Exemplo n.º 11
0
        public IEnumerator ExecuteCommand(string commandLine)
        {
            var splittedCommand = commandLine.Split(':');
            var command         = splittedCommand[0];
            var arg             = splittedCommand[1]; // for now there is only 1 argument

            Logger.Log($"Executing {command} in dialogue");

            // TODO: use strategy
            switch (command)
            {
            case "pause":
                yield return(StartCoroutine(PauseDialogue(float.Parse(arg))));

                break;

            default:
                break;
            }
        }
Exemplo n.º 12
0
        public void SayPhrase(string characterName, string phrase)
        {
            if (!IsInTalkingMode)
            {
                DialogueCanvas.Instance.OnTalkingStarted();
            }

            var characters = FindObjectsOfType <MonoBehaviour>().OfType <ICharacter>(); //use some caching or whatever

            var foundCharacter = FindCharacter(characterName);

            var found = foundCharacter != null;

            if (!found)
            {
                Logger.Error($"Something went wrong, cant find {characterName} in the scene; will skip line `{phrase}`");
                return;
            }

            DialogueCanvas.Instance.DrawPhrase(foundCharacter, phrase, singlePhrase: !IsInTalkingMode);
        }
Exemplo n.º 13
0
        public void ShowJournal()
        {
            if (isShown)
            {
                return;
            }

            isShown = true;
            buttonLayout.gameObject.SetActive(true);

            if (_currentJournal == null)
            {
                return;
            }

            GameEvent.current.NewFrontInterfaceShown();

            foreach (var character in _currentJournal.characters)
            {
                var newButton = buttonLayout.AddButton(character);

                newButton.onClick.AddListener(() =>
                {
                    Logger.Log($"pressing button - character = {character}");

                    currentNoteIndex = 0;

                    DrawNoteOfCharacter(character);
                });
            }

            // TODO: fix repeating the same lines
            noteBackground.gameObject.SetActive(true);
            noteText.gameObject.SetActive(true);
            buttonClose.gameObject.SetActive(true);

            DrawNoteText(_currentJournal.collections[0].notes[0].text);
        }
Exemplo n.º 14
0
    public void EndedDialogue()
    {
        onDialogueEnded?.Invoke();

        Logger.Log("onDialogueEnded()");
    }
Exemplo n.º 15
0
 public void AddNewInteractionVariable(string variable)
 {
     Logger.Log("State", $"Added {variable} to game state");
     _gameplayVars.Add(variable);
 }
Exemplo n.º 16
0
 public void DeleteFromInventory(string itemName)
 {
     _playerInventory.Remove(itemName);
     Logger.Log("Inventory", $"Deleted {itemName} from inventory");
 }
Exemplo n.º 17
0
 public void AddItemToInventory(string itemName)
 {
     _playerInventory.Add(itemName);
     Logger.Log("Inventory", $"Added {itemName} to inventory");
 }
Exemplo n.º 18
0
 void Quit()
 {
     Logger.Log("Bye!");
     Application.Quit();
 }
Exemplo n.º 19
0
        public override void Interact()
        {
            //actually call something that shows inventory

            Logger.Log("Interactable", "Looking 4 something in shelf...");
        }
Exemplo n.º 20
0
        public override void StopTalking()
        {
            state = NPCState.DoingNothing;

            Logger.Log("[NPC] StopTalking()");
        }
Exemplo n.º 21
0
    public void StartedDialogueWithEva()
    {
        onDialogueWithEvaStarted?.Invoke();

        Logger.Log("onDialogueWithEvaStarted()");
    }
Exemplo n.º 22
0
        public void OnTalkingStarted()
        {
            Logger.Warning("[DialogueCanvas] OnTalkingStarted()");

            dialogueImage.gameObject.SetActive(true);
        }
Exemplo n.º 23
0
    public void NewFrontInterfaceShown()
    {
        onNewFrontInterfaceShown?.Invoke();

        Logger.Log("NewFrontInterfaceShown()");
    }
Exemplo n.º 24
0
    public void NewFrontInterfaceClosed()
    {
        onNewFrontInterfaceClosed?.Invoke();

        Logger.Log("NewFrontInterfaceClosed()");
    }
Exemplo n.º 25
0
        public void OnTalkingEnded()
        {
            Logger.Warning("[DialogueCanvas] OnTalkingEnded()");

            dialogueImage.gameObject.SetActive(false);
        }
Exemplo n.º 26
0
    public void EnteredTrigger()
    {
        onTriggerEnter?.Invoke();

        Logger.Log("onTriggerEnter()");
    }