コード例 #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);
            }
        }
コード例 #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}";
        }
コード例 #3
0
ファイル: Door.cs プロジェクト: cvertee/abandoned-steampunk
        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);
        }
コード例 #4
0
        private void OnTriggerExit2D(Collider2D other)
        {
            Logger.Log("Trigger", "Player->OnTriggerExit2D");

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

            interactableEntity = null;
        }
コード例 #5
0
ファイル: NPC.cs プロジェクト: cvertee/abandoned-steampunk
        public override void StartTalking()
        {
            state = NPCState.Talking;

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

            if (shouldExecScript)
            {
                LuaScript.Execute(dialogueScript);
            }
        }
コード例 #6
0
        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);
        }
コード例 #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());
            }
        }
コード例 #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);
        }
コード例 #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();
                }
            }
        }
コード例 #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
        }
コード例 #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;
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #14
0
    public void EndedDialogue()
    {
        onDialogueEnded?.Invoke();

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

            Logger.Log("Interactable", "Looking 4 something in shelf...");
        }
コード例 #20
0
ファイル: NPC.cs プロジェクト: cvertee/abandoned-steampunk
        public override void StopTalking()
        {
            state = NPCState.DoingNothing;

            Logger.Log("[NPC] StopTalking()");
        }
コード例 #21
0
    public void StartedDialogueWithEva()
    {
        onDialogueWithEvaStarted?.Invoke();

        Logger.Log("onDialogueWithEvaStarted()");
    }
コード例 #22
0
        public void OnTalkingStarted()
        {
            Logger.Warning("[DialogueCanvas] OnTalkingStarted()");

            dialogueImage.gameObject.SetActive(true);
        }
コード例 #23
0
    public void NewFrontInterfaceShown()
    {
        onNewFrontInterfaceShown?.Invoke();

        Logger.Log("NewFrontInterfaceShown()");
    }
コード例 #24
0
    public void NewFrontInterfaceClosed()
    {
        onNewFrontInterfaceClosed?.Invoke();

        Logger.Log("NewFrontInterfaceClosed()");
    }
コード例 #25
0
        public void OnTalkingEnded()
        {
            Logger.Warning("[DialogueCanvas] OnTalkingEnded()");

            dialogueImage.gameObject.SetActive(false);
        }
コード例 #26
0
    public void EnteredTrigger()
    {
        onTriggerEnter?.Invoke();

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