Esempio n. 1
0
        public void LoadNewMap()
        {
            MapData mapToLoad = mapLoader.loadMap();

            if (mapToLoad != null)
            {
                EraseCurrentMap();

                foreach (StateData sd in mapToLoad.actualStates)
                {
                    MovableState ms = CreateNewState(sd.texture, sd.positionInMap, sd.stateName);
                    ms.continent = sd.continentName;

                    foreach (string conn in sd.connection)
                    {
                        ms.connections.Add(conn);
                    }
                }
                for (int i = 0; i < mapToLoad.continents.Count; i++)
                {
                    Debug.Log(mapToLoad.continents[i]);
                    ChangeContinentName(mapToLoad.continents[i], i);
                }
            }
        }
Esempio n. 2
0
        MovableState CreateNewState(Texture2D stateTexture, Vector3 position, string stateName)
        {
            MovableState newMovableState = Instantiate(movableState, new Vector3(position.x, position.y, position.z - 1), Quaternion.identity);

            newMovableState.transform.SetParent(this.transform);

            newMovableState.SetState(stateTexture, stateName);

            Vector2 pos  = new Vector2(-8.6f, -4.5f);
            Vector2 size = new Vector2(10f, 7.5f);
            Rect    r    = new Rect(pos, size);

            newMovableState.setBoundraries(r);


            currentStates.Add(newMovableState);
            SelectState(newMovableState);

            newMovableState.Click.AddListener((State state) =>
            {
                SelectState(state);
            });

            return(newMovableState);
        }
Esempio n. 3
0
        public void CreateNewStateConnection(string conn)
        {
            MovableState stateToConnect = GetState(conn);

            if (selectedState != null && stateToConnect != null && stateToConnect != selectedState)
            {
                selectedState.connections.Add(stateToConnect.idName);
                stateToConnect.connections.Add(selectedState.idName);
            }


            showConnection();
        }
Esempio n. 4
0
        public MovableState GetState(string stateName)
        {
            MovableState stateToReturn = null;

            foreach (MovableState s in currentStates)
            {
                if (s.idName == stateName)
                {
                    stateToReturn = s;
                    break;
                }
            }

            return(stateToReturn);
        }