![alt text][1]
[1]: /storage/temp/101624-screen-shot-2017-09-10-at-42952-pm.pngusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameController : MonoBehaviour {
public Text displayText;
public InputAction[] inputActions;
[HideInInspector] public RoomNavigation roomNavigation;
[HideInInspector] public List interactionDescriptionsInRoom = new List ();
[HideInInspector] public InteractableItems interactableItems;
List actionLog = new List();
// Use this for initialization
void Awake ()
{
interactableItems = GetComponent ();
roomNavigation = GetComponent ();
}
void Start()
{
DisplayRoomText ();
DisplayLoggedText ();
}
public void DisplayLoggedText()
{
string logAsText = string.Join ("\n", actionLog.ToArray ());
displayText.text = logAsText;
}
public void DisplayRoomText()
{
ClearCollectionsForNewRoom ();
UnpackRoom ();
string joinedInteractionsDescriptions = string.Join ("\n", interactionDescriptionsInRoom.ToArray());
string combinedText = roomNavigation.currentRoom.description + "\n" + joinedInteractionsDescriptions;
LogStringWithReturn (combinedText);
}
void UnpackRoom() {
roomNavigation.UnpackExitsInRoom ();
PrepareObjectsToTakeOrExamine(RoomNavigation.currentRoom
}
void PrepareObjectsToTakeOrExamine(roomNavigation.currentRoom);
{
for (int i = 0; i < currentRoom.interactableObjectsInRoom.Length; i++)
{
string descriptionNotInInventory = interactableItems.GetObjectsNotInInventory (currentRoom, i);
if (descriptionNotInInventory != null)
{
interactionDescriptionsInRoom.Add (descriptionNotInInventory);
}
}
}
void ClearCollectionsForNewRoom()
{
interactionDescriptionsInRoom.Clear ();
roomNavigation.ClearExits ();
}
public void LogStringWithReturn(string stringToAdd)
{
actionLog.Add (stringToAdd + "\n");
}
// Update is called once per frame
void Update () {
}
}
↧