Esempio n. 1
0
    public static Config CreateNewConfig()
    {
        Config config = new Config
        {
            Id             = 0,
            Name           = "Nazwa",
            CreationDate   = DateTime.Now,
            DrawStartPoint = true,
            NrOfLevels     = 2,
            WaitingTime    = 3f,
            Levels         = new List <LevelConfig>()
        };
        var level1 = new LevelConfig {
            levelNumber = 1, shape = Shape.HorizontalLine, lineStroke = LineStroke.Medium, shapeColor = PastelColorFactory.RandomColor
        };

        level1.brushColor = PastelColorFactory.RandomColorWithExclude(level1.shapeColor);
        config.Levels.Add(level1);
        var level2 = new LevelConfig {
            levelNumber = 2, shape = Shape.VerticalLine, lineStroke = LineStroke.Medium, shapeColor = PastelColorFactory.RandomColor
        };

        level2.brushColor = PastelColorFactory.RandomColorWithExclude(level2.shapeColor);
        config.Levels.Add(level2);

        return(config);
    }
Esempio n. 2
0
    public void AddLevel(int pos)
    {
        var level = new LevelConfig {
            levelNumber = pos + 1, shape = Shape.HorizontalLine, lineStroke = LineStroke.Medium, shapeColor = PastelColorFactory.RandomColor
        };

        level.brushColor = PastelColorFactory.RandomColorWithExclude(level.shapeColor);

        config.Levels.Insert(pos, level);

        config.NrOfLevels++;

        OnLevelAdded(pos);

        _levelManagers.Insert(pos, InstantiateLevelManager(level, pos));

        int from = 0;
        int to   = 0;

        if (pos <= activeLevelManager)
        {
            activeLevelManager++;
            from = 0;
            to   = activeLevelManager;

            config.Levels[activeLevelManager].levelNumber = activeLevelManager + 1;
            _levelManagers[activeLevelManager].UpdateTitle();
        }
        else
        {
            from = pos + 1;
            to   = _levelManagers.Count;
        }

        for (int i = from; i < to; ++i)
        {
            SetPosition(_levelManagers[i].gameObject, i);
        }

        for (int i = pos; i < config.Levels.Count; ++i)
        {
            config.Levels[i].levelNumber = i + 1;
        }

        foreach (var lvl in _levelManagers)
        {
            lvl.UpdateTitle();
        }

        if (pos <= activeLevelManager)
        {
            SetActiveLevelPrevious();
        }
        else
        {
            SetActiveLevelNext();
        }
    }
Esempio n. 3
0
    // Use this for initialization
    void Awake()
    {
        this.screenWidth                     = (float)Screen.width;
        this.screenHeight                    = (float)Screen.height;
        this.screenRatio                     = this.screenWidth / this.screenHeight;
        this.gameUnitsVertical               = 2 * Camera.main.orthographicSize;
        this.gameUnitsHorizontal             = this.gameUnitsVertical * this.screenRatio;
        this.screenMargin                    = 0.1f;
        this.gameUnitsVerticalMargin         = this.gameUnitsVertical * this.screenMargin;
        this.gameUnitsHorizontalMargin       = this.gameUnitsHorizontal * this.screenMargin;
        this.gameUnitsVerticalInActiveArea   = (this.gameUnitsVertical / 2) - (this.gameUnitsVerticalMargin);
        this.gameUnitsHorizontalInActiveArea = (this.gameUnitsHorizontal / 2) - (this.gameUnitsHorizontalMargin);

        lf = new LineFactory();

        pcf = new PastelColorFactory();

        BezierCurves = new List <List <Vector2> >
        {
            new List <Vector2> {
                new Vector2(-3, -2), new Vector2(-5, 2), new Vector2(-2, 3), new Vector2(0, 1)
            },
            new List <Vector2> {
                new Vector2(-5, 2), new Vector2(-3, -2), new Vector2(-2, 3), new Vector2(0, 1)
            },
            new List <Vector2> {
                new Vector2(-7, -2), new Vector2(-2, 4), new Vector2(-2, 4), new Vector2(7, -2)
            },
            new List <Vector2> {
                new Vector2(4, 3), new Vector2(-5, 3), new Vector2(-4, -1), new Vector2(4, -2)
            },
            new List <Vector2> {
                new Vector2(-6, -2), new Vector2(-2, 3), new Vector2(-0, -3), new Vector2(7, 2)
            },
            new List <Vector2> {
                new Vector2(-2, 3), new Vector2(-5, -2), new Vector2(5, -2), new Vector2(2, 3)
            },
            new List <Vector2> {
                new Vector2(-2, 3), new Vector2(-2, -3), new Vector2(-1, -3), new Vector2(6, 2)
            },
            new List <Vector2> {
                new Vector2(-7, 0), new Vector2(-2, 1), new Vector2(1, -2), new Vector2(5, 1)
            },
            new List <Vector2> {
                new Vector2(-5, 2), new Vector2(-3, -3), new Vector2(0, 3), new Vector2(3, 2)
            },
            new List <Vector2> {
                new Vector2(-5, -2), new Vector2(-2, -2), new Vector2(0, 2), new Vector2(5, 0)
            },
            new List <Vector2> {
                new Vector2(-2, 3), new Vector2(1, 1), new Vector2(-2, -1), new Vector2(-1, -3)
            },
            new List <Vector2> {
                new Vector2(-4, -1), new Vector2(-2, 3), new Vector2(5, -1), new Vector2(5, -1)
            },
        };

        shapeMap = new Dictionary <Shape, CreateFunc>
        {
            { Shape.HorizontalLine, CreateHorizontalLine },
            { Shape.VerticalLine, CreateVerticalLine },
            { Shape.DiagonalLine, CreateDiagonalLine },
            { Shape.CurvedLine, CreateCurvedLine },
            { Shape.Triangle, CreateTriangle },
            { Shape.Circle, CreateCircle },
            { Shape.Ellipse, CreateEllipse },
            { Shape.Square, CreateSquare },
            { Shape.Rectangle, CreateRectangle }
        };
    }
Esempio n. 4
0
 private void SetShapeColor(GameObject sender, string newValue, int index)
 {
     cfg.shapeColor = PastelColorFactory.GetColor(newValue);
 }
Esempio n. 5
0
 private void UpdateShapeColor(int i)
 {
     cfg.shapeColor = PastelColorFactory.GetColor(ShapeColorDropdown.options[i].text);
 }
Esempio n. 6
0
 private void UpdateLineColor(int i)
 {
     cfg.brushColor = PastelColorFactory.GetColor(LineColorDropdown.options[i].text);
 }