Esempio n. 1
0
    public static void initialize()
    {
        if (Camera.main == null)
        {
            GameObject camera = new GameObject();
            camera.AddComponent <Camera>();
            camera.name = "MainCamera";
            camera.tag  = "MainCamera";
            GameObject.DontDestroyOnLoad(camera);
        }
        RenderSettings.ambientLight = Color.white;

        Camera.main.orthographic = true;
        Texture2D baseTile = IsoSettingsManager.getInstance().getIsoSettings().defautTextureScale;

        float angle = 30;

        if (baseTile != null)
        {
            float angulo = Mathf.Rad2Deg * Mathf.Acos(baseTile.height / (baseTile.width * 1f));
            angle = 90f - angulo;
        }
        Camera.main.transform.rotation = Quaternion.Euler(angle, 45, 0);

        separation = new Vector3(0, 0, distance);
        separation = Quaternion.Euler(angle, 45, 0) * separation;
    }
Esempio n. 2
0
    public void ghostCell(Vector3 position, float intensity)
    {
        checkTransform();

        if (ghost == null || ghostType != 1)
        {
            removeGhost();
            ghostType          = 1;
            instanciatingGhost = true;
            ghost           = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultCellPrefab) as GameObject;
            ghost.name      = "Ghost";
            ghost.hideFlags = HideFlags.HideAndDontSave;
            ghost.GetComponent <Cell>().Map = this;
            instanciatingGhost = false;
        }

        // Getting the localPosition
        position = m_transform.InverseTransformPoint(position);

        Cell cell = ghost.GetComponent <Cell>();

        cell.Width = cellSize;

        //La refresco
        Vector2 coords = getCoords(position);

        cell.Height = position.y;
        cell.transform.localPosition = new Vector3((coords.x + 0.5f) * cellSize, 0, (coords.y + 0.5f) * cellSize);

        Material mat = new Material(Shader.Find("Transparent/Diffuse"));

        mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, intensity);
        ghost.GetComponent <Renderer>().sharedMaterial = mat;
    }
Esempio n. 3
0
    /* ********** *
    * CRUD Zone  *
    * ********** */

    public GameObject addCell(Vector3 position)
    {
        checkTransform();

        // Creating the gameObject
#if UNITY_EDITOR
        GameObject go = UnityEditor.PrefabUtility.InstantiatePrefab(IsoSettingsManager.getInstance().getIsoSettings().defaultCellPrefab) as GameObject;
#else
        GameObject go = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultCellPrefab);
#endif

        // Getting the localPosition
        position = m_transform.InverseTransformPoint(position);

        // Setting base properties
        Cell cell = go.GetComponent <Cell>();
        cell.Map = this;
        cell.transform.localPosition = new Vector3(position.x, 0, position.z);
        cell.Height = position.y;
        cell.Width  = cellSize;
        cell.forceRefresh();

        //Añado la celda al conjunto de celdas

        //La refresco
        updateCell(cell, true);

        return(go);
    }
Esempio n. 4
0
 /// <summary>
 /// Loads new state of ViewModel
 /// </summary>
 private void InitialiazeDataContext()
 {
     this._viewModel = new ProjectEditorContext(App.DbConnectionString);
     this._viewModel.LoadData((int)IsoSettingsManager.LoadRecord("CurrentProjectId"));
     this.DataContext = this._viewModel;
     _playerManager   = new PlayerManager(_viewModel.CurrentProject.Tempo);
     _playerManager.StateChangedEvent += _playerManager_StateChangeEvent;
 }
 /// <summary>
 /// Loads new state of ViewModel
 /// </summary>
 private void InitialiazeDataContext()
 {
     this._viewModel = new SampleEditorContext(App.DbConnectionString);
     this._viewModel.LoadData((int)IsoSettingsManager.LoadRecord("CurrentSampleId"));
     this.DataContext                  = this._viewModel;
     this.PianoRoll.ItemsSource        = this._viewModel.Tacts;
     _playerManager                    = new PlayerManager(_viewModel.CurrentSample.TrackRef.ProjectRef.Tempo);
     _playerManager.StateChangedEvent += _playerManager_StateChangeEvent;
 }
 /// <summary>
 /// Loads new state of ViewModel
 /// </summary>
 private void InitialiazeDataContext()
 {
     this._viewModel = new TrackEditorContext(App.DbConnectionString);
     this._viewModel.LoadData((int)IsoSettingsManager.LoadRecord("CurrentTrackId"));
     this.DataContext = this._viewModel;
     this._viewModel.CurrentTrack.Samples.CollectionChanged += Samples_CollectionChanged;
     _playerManager = new PlayerManager(_viewModel.CurrentTrack.ProjectRef.Tempo);
     _playerManager.StateChangedEvent += PlayerManager_OnStateChangeEvent;
     _playerManager.TactChangedEvent  += PlayerManager_OnTactChangedEvent;
 }
Esempio n. 7
0
    public static void createMap(MenuCommand menuCommand)
    {
                #if UNITY_EDITOR
        GameObject go = UnityEditor.PrefabUtility.InstantiatePrefab(IsoSettingsManager.getInstance().getIsoSettings().defaultMapPrefab) as GameObject;
                #else
        GameObject go = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultMapPrefab);
                #endif

        Selection.activeObject = go;
    }
Esempio n. 8
0
    public GameObject addDecoration(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec)
    {
        GameObject newdecoration = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject;

        newdecoration.name = "Decoration (clone)";
        newdecoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
        newdecoration.GetComponent <Decoration>().Father       = this;

        Decoration der = newdecoration.GetComponent <Decoration>();

        der.IsoDec = dec;

        der.setParameters(position, angle, parallel, centered);

        return(newdecoration);
    }
Esempio n. 9
0
        /// <summary>
        /// Chose project for editing
        /// </summary>
        private void TrackListBoxItem_OnTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var grid = sender as TextBlock;

            if (grid == null)
            {
                return;
            }
            var chosenTrack = grid.DataContext as ToDoTrack;

            if (chosenTrack == null)
            {
                return;
            }
            IsoSettingsManager.SaveRecord("CurrentTrackId", chosenTrack.Id);
            NavigationService.Navigate(new Uri("/Views/TrackEditorPage.xaml", UriKind.Relative));
        }
Esempio n. 10
0
        /// <summary>
        /// Chose project for editing.
        /// </summary>
        /// <param name="sender">Project item displayed like a list box item</param>
        /// <param name="e">One tap</param>
        private void ProjectItemGrid_OnTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var grid = sender as Grid;

            if (grid == null)
            {
                return;
            }
            var chosenProject = grid.DataContext as ToDoProject;

            if (chosenProject == null)
            {
                return;
            }
            IsoSettingsManager.SaveRecord("CurrentProjectId", chosenProject.Id);
            NavigationService.Navigate(new Uri("/Views/ProjectEditorPage.xaml", UriKind.Relative));
        }
        /// <summary>
        /// Chose sample for editing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sample_OnTap(object sender, GestureEventArgs e)
        {
            var grid = sender as Grid;

            if (grid == null)
            {
                return;
            }
            var chosenSample = grid.DataContext as ToDoSample;

            if (chosenSample == null)
            {
                return;
            }
            IsoSettingsManager.SaveRecord("CurrentSampleId", chosenSample.Id);
            NavigationService.Navigate(new Uri("/Views/SampleEditorPage.xaml", UriKind.Relative));
        }
Esempio n. 12
0
    private void setPerspective(SceneView scene)
    {
        /* Selection.transforms	*/

        float   angle    = 30;
        Texture baseTile = IsoSettingsManager.getInstance().getIsoSettings().defautTextureScale;

        if (baseTile != null)
        {
            float angulo = Mathf.Rad2Deg * Mathf.Acos(baseTile.height / (baseTile.width * 1f));
            angle = 90f - angulo;
        }

        scene.LookAtDirect(scene.pivot, Quaternion.Euler(angle, 45, 0));
        scene.orthographic = true;

        scene.Repaint();
    }
Esempio n. 13
0
    void OnEnable()
    {
        this.map = (Map)target;

        /*this.modules = new MapEditorModule[]{
         *      new NothingModule(),
         *      new EditModule(),
         *      new PaintModule(),
         *      new DecorateModule(),
         *      new EntityModule()
         * };*/
        List <MapEditorModule> modules = new List <MapEditorModule>();

        var type = typeof(MapEditorModule);

        Assembly[] assembly = AppDomain.CurrentDomain.GetAssemblies();
        foreach (Assembly a in assembly)
        {
            foreach (Type t in a.GetTypes())
            {
                if (type.IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
                {
                    modules.Add(Activator.CreateInstance(t) as MapEditorModule);
                }
            }
        }

        modules.Sort(new ModuleComparision());

        this.modules = modules.ToArray() as MapEditorModule[];

        this.selected = 0;

        toolBarStyle        = new GUIStyle();
        toolBarStyle.margin = new RectOffset(50, 50, 5, 10);

        IsoSettings iso = IsoSettingsManager.getInstance().getIsoSettings();

        if (!iso.Configured)
        {
            IsoSettingsPopup.ShowIsoSettingsPopup(iso);
        }
    }
Esempio n. 14
0
    public GameObject addGhost(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity)
    {
        if (this.ghost == null)
        {
            ghost           = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject;
            ghost.name      = "GhostDer";
            ghost.hideFlags = HideFlags.HideAndDontSave;

            Material ghostMaterial = new Material(Shader.Find("Transparent/Diffuse"));
            ghostMaterial.color = new Color(ghostMaterial.color.r, ghostMaterial.color.g, ghostMaterial.color.b, intensity);
            ghost.GetComponent <Renderer>().sharedMaterial = ghostMaterial;
        }
        Decoration der = ghost.GetComponent <Decoration>();

        der.Father = this;
        der.IsoDec = dec;

        der.setParameters(position, angle, parallel, centered);

        return(this.ghost);
    }
Esempio n. 15
0
        private void RenameProjectDialog_OnCompleted(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            var input = sender as InputPrompt;

            if (input == null)
            {
                return;
            }
            if (e.PopUpResult == PopUpResult.Ok)
            {
                if (_viewModel.OnRenameProject == null)
                {
                    var newProject = this._viewModel.CreateProject(input.Value);
                    IsoSettingsManager.SaveRecord("CurrentProjectId", newProject.Id);
                    NavigationService.Navigate(new Uri("/Views/ProjectEditorPage.xaml", UriKind.Relative));
                }
                else
                {
                    this._viewModel.RenameProjectTo(input.Value);
                }
            }
            _viewModel.OnRenameProject = null;
        }
Esempio n. 16
0
    public static void createMap()
    {
        GameObject go = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultMapPrefab) as GameObject;

        Selection.activeObject = go;
    }
Esempio n. 17
0
    public void updateTextures()
    {
        float scale = Mathf.Sqrt(2f) / IsoSettingsManager.getInstance().getIsoSettings().defautTextureScale.width;

        this.transform.localScale = new Vector3(isoDec.getTexture().width *scale / ((float)isoDec.nCols), (isoDec.getTexture().height *scale) / ((float)isoDec.nRows), 1);

        if (!parallel)
        {
            this.transform.localScale = new Vector3(this.transform.localScale.x, this.transform.localScale.y / Mathf.Sin(45f), 1);
        }
        else
        {
            if (this.angle == 0)
            {
                this.transform.localScale = new Vector3(this.transform.localScale.x, this.transform.localScale.y * 2f, 1);
            }
            else
            {
                this.transform.localScale = new Vector3(Mathf.Sqrt(2f * (this.transform.localScale.x * this.transform.localScale.x)), this.transform.localScale.y / Mathf.Sin(45f), 1);

                Mesh mesh = this.GetComponent <MeshFilter>().mesh;


                if (quadVertices == null)
                {
                    quadVertices = new Vector3[mesh.vertices.Length];
                    for (int i = 0; i < mesh.vertices.Length; i++)
                    {
                        quadVertices[i] = new Vector3(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z);
                    }
                }

                Vector3[] vertices = new Vector3[quadVertices.Length];
                for (int i = 0; i < quadVertices.Length; i++)
                {
                    vertices[i] = new Vector3(quadVertices[i].x, quadVertices[i].y, quadVertices[i].z);
                }

                float xprima = this.transform.localScale.x;
                float omega  = xprima * 0.57735026f;
                float gamma  = omega / (this.transform.localScale.y * Mathf.Sqrt(2));

                Vector3 bajada = new Vector3(0, gamma, 0);

                if (this.angle == 2)
                {
                    vertices[0] -= bajada;
                    vertices[3] -= bajada;
                }
                else if (this.angle == 1)
                {
                    vertices[1] -= bajada;
                    vertices[2] -= bajada;
                }

                mesh.vertices = vertices;

                this.GetComponent <MeshFilter>().sharedMesh = mesh;
            }
        }

        Material myMat = new Material(this.GetComponent <Renderer>().sharedMaterial);

        myMat.mainTextureScale  = new Vector2(1f / ((float)isoDec.nCols), 1f / ((float)isoDec.nRows));
        myMat.mainTextureOffset = new Vector2(0, 1 - 1f / ((float)isoDec.nRows));
        myMat.SetTexture("_MainTex", isoDec.getTexture());
        this.GetComponent <Renderer>().sharedMaterial = myMat;
    }
 private void ToRightButton_OnTap(object sender, GestureEventArgs e)
 {
     IsoSettingsManager.SaveRecord("CurrentTrackId", _viewModel.NextTrack.Id);
     this.InitialiazeDataContext();
 }
Esempio n. 19
0
    public void OnSceneGUI(SceneView scene)
    {
        if (setPerspective)
        {
            /* Selection.transforms	*/
            setPerspective = false;
            float   angle    = 30;
            Texture baseTile = IsoSettingsManager.getInstance().getIsoSettings().defautTextureScale;
            if (baseTile != null)
            {
                float angulo = Mathf.Rad2Deg * Mathf.Acos(baseTile.height / (baseTile.width * 1f));
                angle = 90f - angulo;
            }
            scene.LookAtDirect(scene.pivot, Quaternion.Euler(angle, 45, 0));
            scene.orthographic = true;

            if (fixView)
            {
                fixedRotation = Quaternion.Euler(angle, 45, 0);
            }

            scene.Repaint();
        }

        if (fixView)
        {
            scene.LookAtDirect(scene.pivot, fixedRotation);
        }

        HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
        if (Event.current.isMouse)
        {
            if (Event.current.button == 0)
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    startCreatingCells();
                }
                else if (Event.current.type == EventType.MouseUp)
                {
                    endCreatingCells();
                }
                else
                {
                    createCell();
                }
            }
            else if (Event.current.button == 1)
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    startMovingGrid();
                }
                else if (Event.current.type == EventType.MouseUp)
                {
                    endMovingGrid();
                }
                else
                {
                    moveGrid();
                }
            }
            scene.Repaint();
        }

        Vector3 centerGridPoint = map.getMousePositionOverMap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition), Mathf.RoundToInt(gridHeight * 2f) / 2f);

        map.ghostCell(centerGridPoint, 0.5f);

        Vector3[] puntos = new Vector3[4];
        puntos[0] = new Vector3(centerGridPoint.x - cellSize / 2.0f, centerGridPoint.y, centerGridPoint.z - cellSize / 2.0f);
        puntos[1] = new Vector3(centerGridPoint.x - cellSize / 2.0f, centerGridPoint.y, centerGridPoint.z + cellSize / 2.0f);
        puntos[2] = new Vector3(centerGridPoint.x + cellSize / 2.0f, centerGridPoint.y, centerGridPoint.z + cellSize / 2.0f);
        puntos[3] = new Vector3(centerGridPoint.x + cellSize / 2.0f, centerGridPoint.y, centerGridPoint.z - cellSize / 2.0f);
        Handles.DrawSolidRectangleWithOutline(puntos, Color.yellow, Color.white);
    }