Exemplo n.º 1
0
 public CurrentGameState(GameMode gameMode, Hero hero)
 {
     Me          = new CurrentHeroData();
     Minimap     = new MinimapData();
     Me.HeroData = hero;
     GameMode    = gameMode;
 }
Exemplo n.º 2
0
 public CurrentGameState(GameMode gameMode, Hero hero)
 {
     Me = new CurrentHeroData();
     Minimap = new MinimapData();
     Me.HeroData = hero;
     GameMode = gameMode;
 }
    private GameObject GetOrCreateCamera()
    {
        MinimapData data            = target as MinimapData;
        Transform   transform       = data.gameObject.transform;
        Transform   cameraTransform = transform.Find("Minimap-Camera");

        Bounds?    terrainBounds = null;
        GameObject cameraNode    = cameraTransform != null ? cameraTransform.gameObject : null;

        if (cameraNode == null)
        {
            cameraNode             = new GameObject("Minimap-Camera");
            cameraTransform        = cameraNode.transform;
            cameraTransform.parent = transform;
            if (data.Player != null)
            {
                cameraTransform.Translate(data.Player.transform.position + new Vector3(0, 500, 0));
            }
            else if (data.Terrain != null)
            {
                terrainBounds = CalculateBounds(data.Terrain);
                cameraTransform.Translate(terrainBounds.Value.center + new Vector3(0, 100, 0));
            }
            cameraTransform.Rotate(new Vector3(1, 0, 0), 90);
        }

        Camera camera = cameraNode.GetComponent <Camera>();

        if (camera == null)
        {
            camera = cameraNode.AddComponent <Camera>();
            camera.targetTexture = (RenderTexture)AssetDatabase.LoadAssetAtPath("Assets/Minimap/MinimapTexture.renderTexture", typeof(RenderTexture));
            camera.orthographic  = true;
            if (terrainBounds == null && data.Terrain != null)
            {
                terrainBounds = CalculateBounds(data.Terrain);
            }
            if (terrainBounds != null)
            {
                camera.orthographicSize = terrainBounds.Value.extents.magnitude / 2;
            }
        }

        LinearObjectTracking tracking = cameraNode.GetComponent <LinearObjectTracking>();

        if (tracking == null)
        {
            tracking        = cameraNode.AddComponent <LinearObjectTracking>();
            tracking.target = data.Player;
        }

        return(cameraNode);
    }
    private GameObject GetOrCreateCanvas()
    {
        MinimapData data            = target as MinimapData;
        Transform   transform       = data.gameObject.transform;
        Transform   canvasTransform = transform.Find("Minimap-Canvas");

        GameObject canvasNode = canvasTransform != null ? canvasTransform.gameObject : null;

        if (canvasNode == null)
        {
            GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/Minimap/Canvas.prefab", typeof(GameObject));
            canvasNode      = Instantiate(prefab, transform);
            canvasNode.name = "Minimap-Canvas";
        }

        return(canvasNode);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Recalculate Minimap"))
        {
            MinimapData data      = target as MinimapData;
            Transform   transform = data.gameObject.transform;
            while (transform.childCount > 0)
            {
                Transform child = transform.GetChild(0);
                if (Application.isEditor)
                {
                    DestroyImmediate(child.gameObject);
                }
                else
                {
                    Destroy(child.gameObject);
                }
            }
        }
        GetOrCreateCamera();
        GetOrCreateCanvas();
    }
Exemplo n.º 6
0
 public CurrentGameState()
 {
     Me = new CurrentHeroData();
     Minimap = new MinimapData();
 }
Exemplo n.º 7
0
 public CurrentGameState()
 {
     Me      = new CurrentHeroData();
     Minimap = new MinimapData();
 }