From c38d113433f93fa8810c36bc8118e87ff07f02a6 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 19 Aug 2014 17:14:23 +0100 Subject: [PATCH] Remove Room class --- Assets/Fungus/Editor/GameEditor.cs | 44 ----- Assets/Fungus/Editor/GameEditor.cs.meta | 8 - Assets/Fungus/Editor/RoomEditor.cs | 16 -- Assets/Fungus/Editor/RoomEditor.cs.meta | 8 - Assets/Fungus/Scripts/AnimationListener.cs | 11 +- Assets/Fungus/Scripts/GUIButton.cs | 7 +- Assets/Fungus/Scripts/Game.cs | 13 -- Assets/Fungus/Scripts/Parallax.cs | 35 +--- Assets/Fungus/Scripts/Room.cs | 169 ------------------ Assets/Fungus/Scripts/Room.cs.meta | 8 - Assets/Fungus/Scripts/RoomTemplate.cs | 39 ---- Assets/Fungus/Scripts/RoomTemplate.cs.meta | 8 - Assets/Fungus/Scripts/SceneLoader.cs | 7 +- Assets/Fungus/Tests.meta | 5 - Assets/Fungus/Tests/Sequence.meta | 5 - .../Fungus/Tests/Sequence/SequenceTest.unity | Bin 76016 -> 0 bytes .../Tests/Sequence/SequenceTest.unity.meta | 4 - .../Fungus/Tests/Sequence/SequenceTestRoom.cs | 38 ---- .../Tests/Sequence/SequenceTestRoom.cs.meta | 8 - Assets/Shuttle/ShuttleGame.unity | Bin 87772 -> 87636 bytes 20 files changed, 8 insertions(+), 425 deletions(-) delete mode 100644 Assets/Fungus/Editor/GameEditor.cs delete mode 100644 Assets/Fungus/Editor/GameEditor.cs.meta delete mode 100644 Assets/Fungus/Editor/RoomEditor.cs delete mode 100644 Assets/Fungus/Editor/RoomEditor.cs.meta delete mode 100644 Assets/Fungus/Scripts/Room.cs delete mode 100644 Assets/Fungus/Scripts/Room.cs.meta delete mode 100644 Assets/Fungus/Scripts/RoomTemplate.cs delete mode 100644 Assets/Fungus/Scripts/RoomTemplate.cs.meta delete mode 100644 Assets/Fungus/Tests.meta delete mode 100644 Assets/Fungus/Tests/Sequence.meta delete mode 100644 Assets/Fungus/Tests/Sequence/SequenceTest.unity delete mode 100644 Assets/Fungus/Tests/Sequence/SequenceTest.unity.meta delete mode 100644 Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs delete mode 100644 Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs.meta diff --git a/Assets/Fungus/Editor/GameEditor.cs b/Assets/Fungus/Editor/GameEditor.cs deleted file mode 100644 index 3f3c9429..00000000 --- a/Assets/Fungus/Editor/GameEditor.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UnityEditor; -using UnityEngine; -using System.Collections; - -namespace Fungus -{ - [CustomEditor (typeof(Game))] - public class GameEditor : Editor - { - private void OnSceneGUI() - { - GameEditor.DrawRoomNames(); - } - - static public void DrawRoomNames() - { - Handles.color = Color.white; - Handles.BeginGUI(); - - // Show labels for each room - Room[] rooms = GameObject.FindObjectsOfType(); - - foreach (Room room in rooms) - { - if (!room.renderer) - { - continue; - } - - Bounds bounds = room.renderer.bounds; - Vector3 pos = new Vector3(bounds.min.x, bounds.max.y, 0); - - GUIStyle style = new GUIStyle(GUI.skin.label); - style.normal.textColor = new Color(1,1,1); - style.fontSize /= 2; - Rect boxRect = HandleUtility.WorldPointToSizedRect(pos, new GUIContent(room.name), style); - boxRect.y -= boxRect.height * 1.5f; - GUI.Box(boxRect, room.name, style); - } - - Handles.EndGUI(); - } - } -} \ No newline at end of file diff --git a/Assets/Fungus/Editor/GameEditor.cs.meta b/Assets/Fungus/Editor/GameEditor.cs.meta deleted file mode 100644 index 7267527f..00000000 --- a/Assets/Fungus/Editor/GameEditor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5464e5745a4da462795a6f6f5b112962 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/Editor/RoomEditor.cs b/Assets/Fungus/Editor/RoomEditor.cs deleted file mode 100644 index 2b8b90bf..00000000 --- a/Assets/Fungus/Editor/RoomEditor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using UnityEditor; -using UnityEngine; -using System.Collections; - -namespace Fungus -{ - [CustomEditor (typeof(Room), true)] - [CanEditMultipleObjects] - public class RoomEditor : Editor - { - private void OnSceneGUI() - { - GameEditor.DrawRoomNames(); - } - } -} \ No newline at end of file diff --git a/Assets/Fungus/Editor/RoomEditor.cs.meta b/Assets/Fungus/Editor/RoomEditor.cs.meta deleted file mode 100644 index c343ab3b..00000000 --- a/Assets/Fungus/Editor/RoomEditor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0314fe408508a4b25afa76f65378a427 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/Scripts/AnimationListener.cs b/Assets/Fungus/Scripts/AnimationListener.cs index f9b44226..c101bdf3 100644 --- a/Assets/Fungus/Scripts/AnimationListener.cs +++ b/Assets/Fungus/Scripts/AnimationListener.cs @@ -19,16 +19,7 @@ namespace Fungus */ void CallRoomMethod(string methodName) { - Room room = Game.GetInstance().activeRoom; - if (room == null) - { - return; - } - - /* - CommandQueue commandQueue = Game.GetInstance().commandQueue; - commandQueue.CallCommandMethod(room.gameObject, methodName); - */ + // TODO: Execute a FungusScript sequence } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/GUIButton.cs b/Assets/Fungus/Scripts/GUIButton.cs index 4decb011..a6595663 100644 --- a/Assets/Fungus/Scripts/GUIButton.cs +++ b/Assets/Fungus/Scripts/GUIButton.cs @@ -101,12 +101,7 @@ namespace Fungus Application.OpenURL(actionParameter); break; case ClickAction.SendMessage: - // Send the message to all Room objects in the scene - Room[] allRooms = GameObject.FindObjectsOfType(); - foreach (Room room in allRooms) - { - room.SendMessage(actionParameter, SendMessageOptions.DontRequireReceiver); - } + // TODO: Execute a sequence break; } } diff --git a/Assets/Fungus/Scripts/Game.cs b/Assets/Fungus/Scripts/Game.cs index 1f15a683..8dbe9efb 100644 --- a/Assets/Fungus/Scripts/Game.cs +++ b/Assets/Fungus/Scripts/Game.cs @@ -19,12 +19,6 @@ namespace Fungus [RequireComponent(typeof(CameraController))] public class Game : MonoBehaviour { - /** - * The currently active Room. - */ - [Tooltip("The currently active Room.")] - public Room activeRoom; - /** * Show links between Rooms in scene view. */ @@ -99,16 +93,9 @@ namespace Fungus // Acquire references to required components cameraController = gameObject.GetComponent(); - // Auto-hide buttons should be visible at start of game autoHideButtonTimer = autoHideButtonDuration; - - if (activeRoom == null) - { - // Pick first room found if none is specified - activeRoom = GameObject.FindObjectOfType(typeof(Room)) as Room; - } } public virtual void Update() diff --git a/Assets/Fungus/Scripts/Parallax.cs b/Assets/Fungus/Scripts/Parallax.cs index 0a3bc16c..64f38a5f 100644 --- a/Assets/Fungus/Scripts/Parallax.cs +++ b/Assets/Fungus/Scripts/Parallax.cs @@ -35,52 +35,25 @@ namespace Fungus public float accelerometerScale = 0.5f; Vector3 startPosition; - Vector3 startScale; + // Vector3 startScale; Vector3 acceleration; Vector3 velocity; - Room parentRoom; - void Start () { // Store the starting position and scale of the sprite object startPosition = transform.position; - startScale = transform.localScale; - - // Store a reference to the parent Room object - Transform ancestor = transform.parent; - while (ancestor != null) - { - Room room = ancestor.GetComponent(); - if (room != null) - { - parentRoom = room; - break; - } - ancestor = ancestor.transform.parent; - } + // startScale = transform.localScale; } void Update () { - if (parentRoom == null) - { - // Don't apply offset if the sprite is not a child of a Room - return; - } - - if (Game.GetInstance().activeRoom != parentRoom) - { - // Early out if this sprite is not in the currently active Room - return; - } - Vector3 translation = Vector3.zero; // Apply parallax translation based on camera position relative to Room { - Vector3 a = parentRoom.transform.position; + Vector3 a = startPosition; Vector3 b = Camera.main.transform.position; translation = (a - b); translation.x *= parallaxScale.x; @@ -101,10 +74,12 @@ namespace Fungus transform.position = startPosition + translation; // Set new scale for sprite + /* float roomSize = parentRoom.renderer.bounds.extents.y; float t = Camera.main.orthographicSize / roomSize ; float scale = Mathf.Lerp (zoomedInScale, zoomedOutScale, t); transform.localScale = startScale * scale; + */ } } } diff --git a/Assets/Fungus/Scripts/Room.cs b/Assets/Fungus/Scripts/Room.cs deleted file mode 100644 index 32efa9d9..00000000 --- a/Assets/Fungus/Scripts/Room.cs +++ /dev/null @@ -1,169 +0,0 @@ -using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using Fungus.Script; - -namespace Fungus -{ - /** - * This is the primary base class for scripting Fungus games. - * Each Room in your game should have a script component which inherits from Room. - * The OnEnter() method is called when the player enters the room. - * The GameController base class provides easy access to all Fungus functionality. - */ - public abstract class Room : UnityEngine.MonoBehaviour - { - string GetVisitVariableKey() - { - return "_visits." + gameObject.name; - } - - /** - * Returns the number of times the player has visited this Room. - * The Room game object name is used to track the visit count and so must be unique in the game. - */ - public int GetVisitCount() - { - return GlobalVariables.GetInteger(GetVisitVariableKey()); - } - - /** - * Sets the number of times the player has visited this Room. - */ - void SetVisitCount(int count) - { - GlobalVariables.SetInteger(GetVisitVariableKey(), count); - } - - /** - * Returns true if this is the first time the player has visited this room. - */ - public bool IsFirstVisit() - { - return GetVisitCount() == 0; - } - - // Automatically draws arrows to other Rooms referenced in public properties - void OnDrawGizmos() - { - const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; - FieldInfo[] fields = this.GetType().GetFields(flags); - - foreach (FieldInfo fieldInfo in fields) - { - Room room = fieldInfo.GetValue(this) as Room; - if (room != null) - { - DrawLinkToRoom(room); - } - } - } - - void DrawLinkToRoom(Room room) - { - if (!room) - { - Gizmos.color = Color.red; - Gizmos.DrawWireCube(transform.position, renderer.bounds.size * 1.1f); - return; - } - - if (!Game.GetInstance().showLinks) - { - return; - } - - Gizmos.color = Color.green; - Vector3 posA = transform.position; - Vector3 posB = room.transform.position; - - Ray toA = new Ray(posB, posA - posB); - Ray toB = new Ray(posA, posB - posA); - - float tA = 0; - if (renderer) - { - if (renderer.bounds.IntersectRay(toA, out tA)) - { - posA = toA.GetPoint(tA * 0.95f); - } - } - - float tB = 0; - if (room.gameObject.renderer) - { - if (room.gameObject.renderer.bounds.IntersectRay(toB, out tB)) - { - posB = toB.GetPoint(tB * 0.95f); - } - } - - Gizmos.DrawLine(posA, posB); - - float arrowHeadSize = 0.25f; - - Vector3 arrowPosA = posB; - Vector3 arrowPosB = arrowPosA; - Vector3 arrowPosC = arrowPosA; - - arrowPosB.x += toB.direction.y * arrowHeadSize; - arrowPosB.y -= toB.direction.x * arrowHeadSize; - arrowPosB -= toB.direction * arrowHeadSize; - Gizmos.DrawLine(arrowPosA, arrowPosB); - - arrowPosC.x -= toB.direction.y * arrowHeadSize; - arrowPosC.y += toB.direction.x * arrowHeadSize; - arrowPosC -= toB.direction * arrowHeadSize; - Gizmos.DrawLine(arrowPosA, arrowPosC); - } - - // Called by Game when player enters the room - void Enter() - { - Game game = Game.GetInstance(); - CameraController cameraController = game.gameObject.GetComponent(); - - // Pick first view found in the room and snap to camera to this view. - // It is allowed for a room to not have any views. - // In this case the camera will attempt to snap to the room sprite. - View view = gameObject.GetComponentInChildren(); - if (view == null) - { - // No view defined for this room, try to center on room sprite - SpriteRenderer spriteRenderer = GetComponent(); - if (spriteRenderer != null) - { - cameraController.CenterOnSprite(spriteRenderer); - } - else - { - Debug.LogError("Failed to set camera view when entering room."); - } - } - else - { - // Snap to new view - cameraController.PanToPosition(view.transform.position, view.transform.rotation, view.viewSize, 0, null); - } - - // Hide all buttons in the room before entering - // Buttons must always be made visible using a ShowButton() command - Button[] buttons = game.activeRoom.GetComponentsInChildren