Exemplo n.º 1
0
    static public void AddPoint(VmodMonkeMapLoader.Behaviours.Teleporter teleporter)
    {
        Transform point = Object.Instantiate(MapDescriptorConfig.TeleportPoint, teleporter.transform.parent).transform;

        teleporter.TeleportPoints.Add(point);

        point.transform.position = teleporter.transform.position;
        Selection.activeObject   = point.gameObject;
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        VmodMonkeMapLoader.Behaviours.Teleporter targetTele = (VmodMonkeMapLoader.Behaviours.Teleporter)target;

        DrawDefaultInspector();
    }
Exemplo n.º 3
0
    static public void DrawTeleport(VmodMonkeMapLoader.Behaviours.Teleporter targetTele, bool single = false)
    {
        Color theColor = Color.green;

        if (targetTele.TagOnTeleport)
        {
            theColor = Color.Lerp(Color.red, Color.yellow, .5f);
        }
        Handles.color = theColor;

        if (targetTele.TeleportPoints == null || targetTele.TeleportPoints.Count == 0)
        {
            Handles.SphereHandleCap(0, targetTele.transform.position, targetTele.transform.rotation, 1.0f, EventType.Repaint);
            if (!single)
            {
                HandleHelpers.ResizeLabel(targetTele.transform.position + Vector3.up, "TreeTeleporter");
            }
        }
        else
        {
            for (int i = 0; i < targetTele.TeleportPoints.Count; i++)
            {
                Transform point = targetTele.TeleportPoints[i];
                if (point == null)
                {
                    targetTele.TeleportPoints.RemoveAt(i);
                    continue;
                }
                DrawPoint(point, targetTele.transform, theColor, single);
            }

            Handles.color = theColor;

            if (!single)
            {
                HandleHelpers.ResizeLabel(targetTele.transform.position + Vector3.up, targetTele.gameObject.name);
                if (Handles.Button(targetTele.transform.position, targetTele.transform.rotation, 1.0f, 1.0f, Handles.SphereHandleCap))
                {
                    MapDescriptorEditor.moveTo(targetTele.transform);
                }
            }
            else
            {
                Handles.SphereHandleCap(0, targetTele.transform.position, targetTele.transform.rotation, 1.0f, EventType.Repaint);
            }
        }

        if (single)
        {
            Vector3    position = targetTele.transform.position + targetTele.transform.forward * 2;
            Quaternion rotation = SceneView.lastActiveSceneView.rotation;
            //Handles.Rectang;

            Handles.BeginGUI();

            Rect vertical = EditorGUILayout.BeginVertical(MapDescriptorConfig.textStyle, GUILayout.Width(MapDescriptorConfig.guiWidth));
            GUILayout.Label(targetTele.gameObject.name, EditorStyles.boldLabel);

            if (GUILayout.Button("Add New Teleport Point"))
            {
                AddPoint(targetTele);
            }

            targetTele.TagOnTeleport = EditorGUILayout.Toggle("Tag on Teleport", targetTele.TagOnTeleport);

            targetTele.TouchType = (VmodMonkeMapLoader.Behaviours.GorillaTouchType)EditorGUILayout.EnumPopup("TouchType", targetTele.TouchType);

            targetTele.Delay = EditorGUILayout.FloatField("Delay", targetTele.Delay);
            EditorGUILayout.EndVertical();
            Handles.EndGUI();
        }
    }
Exemplo n.º 4
0
    public void OnSceneGUI()
    {
        VmodMonkeMapLoader.Behaviours.Teleporter targetTele = (VmodMonkeMapLoader.Behaviours.Teleporter)target;

        DrawTeleport(targetTele, true);
    }
Exemplo n.º 5
0
        private void InitializeGlobalData()
        {
            if (_globalData == null)
            {
                _globalData = new GlobalData();
            }

            _globalData.Origin = GameObject.Find("slide")?.transform.position ?? Vector3.zero;

            _globalData.TreeOrigin = GameObject.Find("stool")?.transform.position ?? Vector3.zero;

            // Tree Teleport Stuff
            if (_globalData.BigTreeTeleportToMap == null)
            {
                var         teleporterPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(MapFileUtils).Assembly.Location), Constants.MiscObjectsFolderName, "Teleporter");
                AssetBundle bundle         = MapFileUtils.GetAssetBundleFromZip(teleporterPath);
                _globalData.BigTreeTeleportToMap = Object.Instantiate(bundle.LoadAsset <GameObject>("_Teleporter"));

                _globalData.BigTreeTeleportToMap.layer = Constants.MaskLayerPlayerTrigger;
                Object.DontDestroyOnLoad(_globalData.BigTreeTeleportToMap);
                _globalData.BigTreeTeleportToMap.transform.position += new Vector3(0, -0.05f, 2.9f);
                _globalData.BigTreeTeleportToMap.transform.Rotate(new Vector3(0, 20, 0));
            }


            var         orbPath   = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(MapFileUtils).Assembly.Location), Constants.MiscObjectsFolderName, "Orb");
            AssetBundle orbBundle = MapFileUtils.GetAssetBundleFromZip(orbPath);

            GameObject orb        = Object.Instantiate(orbBundle.LoadAsset <GameObject>("_Orb"));
            GameObject orbVisuals = Object.Instantiate(orb);

            orb.AddComponent <RotateByHand>();
            orb.GetComponent <Renderer>().enabled = false;
            Object.Destroy(orb.GetComponent <Renderer>());
            orb.layer = 18;

            orbVisuals.transform.SetParent(orb.transform);
            orbVisuals.transform.localPosition = Vector3.zero;
            orbVisuals.transform.localScale    = Vector3.one;
            orbVisuals.transform.localRotation = Quaternion.identity;

            orbVisuals.AddComponent <PreviewOrb>();
            orbVisuals.GetComponent <Collider>().enabled = false;
            Object.Destroy(orbVisuals.GetComponent <Collider>());

            //orb.layer = Constants.MaskLayerPlayerTrigger;

            Teleporter treeTeleporter = _globalData.BigTreeTeleportToMap.GetComponent <Teleporter>();

            treeTeleporter.TeleporterType     = TeleporterType.Map;
            treeTeleporter.JoinGameOnTeleport = true;
            treeTeleporter.TeleportPoints     = new List <Transform>();
            treeTeleporter.Delay     = 1.5f;
            treeTeleporter.TouchType = GorillaTouchType.Head;

            Object.DontDestroyOnLoad(treeTeleporter);
            if (_globalData.BigTreePoint == null)
            {
                _globalData.BigTreePoint = new GameObject("TreeHomeTargetObject");
                _globalData.BigTreePoint.transform.position = new Vector3(-66f, 12.3f, -83f);
                _globalData.BigTreePoint.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
                Object.DontDestroyOnLoad(_globalData.BigTreePoint);
            }
            treeTeleporter.TeleportPoints.Add(_globalData.BigTreePoint.transform);

            ColorTreeTeleporter(new Color(0, 1, 0));

            // Emergency Teleport Stuff
            if (_globalData.FallEmergencyTeleport != null)
            {
                Object.Destroy(_globalData.FallEmergencyTeleport);
                _globalData.FallEmergencyTeleport = null;
            }
            _globalData.FallEmergencyTeleport       = new GameObject("FallEmergencyTeleport");
            _globalData.FallEmergencyTeleport.layer = Constants.MaskLayerHandTrigger;
            _globalData.FallEmergencyTeleport.AddComponent <BoxCollider>().isTrigger = true;
            _globalData.FallEmergencyTeleport.transform.localScale = new Vector3(1000f, 1f, 1000f);
            _globalData.FallEmergencyTeleport.transform.position   = _globalData.TreeOrigin + new Vector3(0f, -200f, 0f);
            Object.DontDestroyOnLoad(_globalData.FallEmergencyTeleport);

            Teleporter emergencyFallTeleporter = _globalData.FallEmergencyTeleport.AddComponent <Teleporter>();

            emergencyFallTeleporter.TeleportPoints = new List <Transform>()
            {
                _globalData.BigTreePoint.transform
            };
        }