Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        tiles      = new GameObject[Width, Height];
        gridHolder = new GameObject();
        gridHolder.transform.position = new Vector3(0, 0, 0);

        Instance = this;

        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                GameObject newTile = Instantiate(tilePrefab);
                newTile.transform.parent        = gridHolder.transform;
                newTile.transform.localPosition = new Vector2(Width - x - xOffset, Height - y - yOffset);
                tiles[x, y] = newTile;
                TileScript tileScript = newTile.GetComponent <TileScript>();
                tileScript.SetColor(Random.Range(0, tileScript.Colors.Length));
            }
        }

        GameObject centerTile = tiles[Width / 2, Height / 2];
        GameObject newPlayer  = Instantiate(playerPrefab);

        newPlayer.transform.parent        = gridHolder.transform;
        newPlayer.transform.localPosition = centerTile.transform.localPosition;
        Destroy(centerTile);
        tiles[Width / 2, Height / 2] = newPlayer;
        //Destroy(tiles[2,3]);
    }
Esempio n. 2
0
    void Start()
    {
        var g = Instantiate(GridPrefab, new Vector3(0, 0, 0), Quaternion.identity);

        grid = g.GetComponent <GridMaker>();
        grid.MoveCharacter        += MoveCharacter;
        grid.GetSelectedCharacter += () => { return(SelectedCharacter); };
        grid.GetCharacters        += GetCharacters;
        grid.IsFirstTurn          += IsFirstTurn;
        grid.SetFirstPosition     += SetInitialCharacterPosition;

        team1 = new List <Character>();
        team2 = new List <Character>();

        InitializeTeams();

        var teams = new List <Character>();

        teams.AddRange(team1);
        teams.AddRange(team2);
        initative = new Initiative();
        initative.Init(teams);

        Next();
    }
Esempio n. 3
0
        private void NewSudoku()
        {
            myCanvas.Children.Clear();

            GridMaker.AddRandomDigitsToGrid(ref grid, 81 - level);
            gridDrafter = new GridDrafter(grid);

            gridDrafter.CreateGridForSudoku(myCanvas);

            solved = new int[81];
            Array.Copy(grid, solved, 81);

            Solver.TrySolveSudoku(solved);

            gridDrafter.AddInputsForUser(myCanvas, grid);

            TextBox[] tbs = gridDrafter.GetInputs();
            foreach (TextBox tb in tbs)
            {
                if (tb != null)
                {
                    tb.KeyDown += Inputs_KeyDown;
                }
            }

            NextSudoku.IsEnabled  = false;
            CheckInputs.IsEnabled = true;
            SolveButton.IsEnabled = true;
            PointsText.Content    = $"Points: {points}";
        }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        gridMaker = GameObject.Find("GridMaker").GetComponent <GridMaker>();


        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A) && !gridMaker.stopTile)
        {
            gridMaker.AudioSource.PlayOneShot(gridMaker.arrowDown);
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.A) && !gridMaker.stopTile)
        {
            Swap(1, 0);
            gridMaker.AudioSource.PlayOneShot(gridMaker.arrowUp);
        }


        if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D) && !gridMaker.stopTile)
        {
            gridMaker.AudioSource.PlayOneShot(gridMaker.arrowDown);
        }
        if (Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.D) && !gridMaker.stopTile)
        {
            Swap(-1, 0);
            gridMaker.AudioSource.PlayOneShot(gridMaker.arrowUp);
        }
    }
Esempio n. 5
0
 public void TearDown()
 {
     // need to delete everything...
     if (isDirty)
     {
         // save it
     }
     if (gridMaker != null)
     {
         gridMaker.destroy();
         gridMaker = null;
     }
     if (Layers != null)
     {
         int ix = 0;
         while (ix < Layers.Count)
         {
             Layers[ix].TearDown();
             ix++;
         }
     }
     if (parentRoomObject != null)
     {
         GameObject.DestroyImmediate(parentRoomObject);
     }
 }
Esempio n. 6
0
        public void AddRandomDigitsToGrid_TooFewNumbers_Throws(int numberOfDigits)
        {
            int[] grid = new int[81];

            var ex = Assert.Throws <Exception>(() => GridMaker.AddRandomDigitsToGrid(ref grid, numberOfDigits));

            StringAssert.Contains("too few", ex.Message);
        }
Esempio n. 7
0
 public override void CleanUp()
 {
     if (gridPreview != null)
     {
         gridPreview.destroy();
         gridPreview = null;
     }
 }
Esempio n. 8
0
 // Use this for initialization
 void Start()
 {
     if (useDebug)
     {
         _grid      = GameObject.Find("Grid");
         _gridmaker = _grid.GetComponent <GridMaker>();
     }
 }
Esempio n. 9
0
        public void AddRandomDigitsToGrid_WhenCalled_PutRandomDigitsToGrid(int numberOfDigits)
        {
            int[] grid = new int[81];

            GridMaker.AddRandomDigitsToGrid(ref grid, numberOfDigits);
            int result = grid.Count(g => g != 0);

            Assert.AreEqual(numberOfDigits, result);
        }
Esempio n. 10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            GridMaker data = (GridMaker)target;

            if (GUILayout.Button("Update"))
            {
                data.OnButtonPressed();
            }
        }
    public IEnumerator SetCellToGreen(Cell cell)
    {
        yield return(new WaitForSecondsRealtime(delayStep));

        GridMaker  gridMaker = pathFinder.gridMaker;
        GameObject gridCell  = gridMaker.gridCells[cell.x, cell.y];

        //UpdateVisual(gridCell, cell);
        gridCell.GetComponent <NodeVisual>().SetColorGreen();
    }
Esempio n. 12
0
 private void MakeEmptySudoku()
 {
     NewEmptySudokuButton.IsEnabled = false;
     SolveButton.IsEnabled          = true;
     ErrorText.Content = "";
     GridMaker.AddRandomDigitsToGrid(ref grid, 0);
     gridDrafter = new GridDrafter(grid);
     gridDrafter.CreateGridForSudoku(myCanvas);
     gridDrafter.AddInputsForUser(myCanvas, grid);
 }
Esempio n. 13
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Esempio n. 14
0
    // Start is called before the first frame update
    void Awake()
    {
        // set singleton
        Instance = this;
        Instantiate(Player);

        // ref other scripts
        gm = GameObject.Find("Grid Maker").GetComponent <GridMaker>();
        progressController = GameObject.Find("Progress Arrow").GetComponent <ProgressController>();
        st          = GameObject.Find("Species Tracker").GetComponent <SpeciesTracker>();
        audioSource = GetComponent <AudioSource>();
    }
Esempio n. 15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();


        GridMaker myScript = (GridMaker)target;

        if (GUILayout.Button("Refresh Grid"))
        {
            myScript.RefreshGrid();
        }
    }
Esempio n. 16
0
    protected void Start()
    {
        GameCore.CheckSameColorEvent += ListenEvent; //Subscribes the event in the gameCore component
        gridMaker            = FindObjectOfType <GridMaker>();
        gameCore             = FindObjectOfType <GameCore>();
        myRigidbody          = GetComponent <Rigidbody2D>();
        myRigidbody.bodyType = RigidbodyType2D.Static;

        lastRow = (gridMaker.Rows * -2) + 2; //Calculates the last row

        ListenEvent();                       //Runs the event just in case
    }
Esempio n. 17
0
 private void CreateGrid()
 {
     gameGrid = new GameObject("GameGrid");
     gameGrid.transform.parent   = transform;
     gameGrid.transform.position = transform.position;
     gridMaker                 = gameGrid.AddComponent <GridMaker>();
     gridMaker.cellCount       = cellCount;
     gridMaker.sizeSideGrid    = sizeSideGrid;
     gridMaker.firstCellImage  = firstCellImage;
     gridMaker.secondCellImage = secondCellImage;
     gridMaker.SetGrid();
 }
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
        _grid        = GameObject.Find("Grid");
        _gridmaker   = _grid.GetComponent <GridMaker>();
        spriteRender = GetComponent <SpriteRenderer>();
        bomb         = Random.value < 0.15;

        x = (int)this.transform.position.x + 10;
        y = (int)this.transform.position.y + 10;
        Debug.Log(x);
        Debug.Log(y);

        _gridmaker.elements[x, y] = this;
    }
Esempio n. 19
0
    // Start is called before the first frame update
    void Awake()
    {
        // set singleton
        Instance = this;
        Instantiate(Player);

        // ref other scripts
        gm = GameObject.Find("Grid Maker").GetComponent <GridMaker>();
        progressController = GameObject.Find("Progress Arrow").GetComponent <ProgressController>();
        st            = GameObject.Find("Species Tracker").GetComponent <SpeciesTracker>();
        hd            = GetComponent <HintDetection>();
        audioSource   = GetComponent <AudioSource>();
        originalScale = backButton.transform.localScale.x;
    }
Esempio n. 20
0
    // Start is called before the first frame update
    void Start()
    {
        // ref to grid maker
        gm           = GameObject.Find("Grid Maker").GetComponent <GridMaker>();
        pc           = GameObject.Find("Progress Arrow").GetComponent <ProgressController>();
        gradeTracker = GameObject.Find("Current Grade").GetComponent <CurrentGradeTracker>();

        // initialize player position
        this.transform.position = gm.tiles[2, 2].transform.position;

        matrixX        = 2;
        matrixY        = 2;
        gm.tiles[2, 2] = this.gameObject;
        moves.text     = moveNum.ToString();
    }
Esempio n. 21
0
    // Start is called before the first frame update
    void Start()
    {
        // ref to grid maker
        gm            = GameObject.Find("Grid Maker").GetComponent <GridMaker>();
        pc            = GameObject.Find("Progress Arrow").GetComponent <ProgressController>();
        currentAnimal = GameObject.Find("Game Manager").GetComponent <DisplayCurrentAnimal>();
        audioSource   = GetComponent <AudioSource>();

        // initialize player position
        this.transform.position = gm.tiles[2, 2].transform.position;

        matrixX        = 2;
        matrixY        = 2;
        gm.tiles[2, 2] = this.gameObject;
    }
Esempio n. 22
0
    //public Text score;
    //public int scoreInt;
    //Does score go into the tiles script?



    //public int C;
    //public int W;

    // Start is called before the first frame update

    void Start()
    {
        //GridMaker gridScript = gridMaker.GetComponent<GridMaker>();
        gridMaker     = GameObject.Find("Grid").GetComponent <GridMaker>();
        mvmnt         = 10;
        movement.text = mvmnt.ToString();
        //scoreInt = 0
        Up = GameObject.Find("ButtonUP").GetComponent <Button>();
        Up.onClick.AddListener(delegate { Pressed(0, -1, "Button UP"); });
        Down = GameObject.Find("ButtonDOWN").GetComponent <Button>();
        Down.onClick.AddListener(delegate { Pressed(0, 1, "Button Down"); });
        Left = GameObject.Find("ButtonLeft").GetComponent <Button>();
        Left.onClick.AddListener(delegate { Pressed(1, 0, "Button Left"); });
        Right = GameObject.Find("ButtonRight").GetComponent <Button>();
        Right.onClick.AddListener(delegate { Pressed(-1, 0, "Button Right"); });
    }
Esempio n. 23
0
    // Start is called before the first frame update
    void Start()
    {
        //set up instance and create the gridHolder
        Instance = this;

        gameState = "start";

        monsterScript = monster.GetComponent <MonsterScript>();

        tiles = new GameObject[WIDTH, HEIGHT];

        gridHolder = new GameObject();
        gridHolder.transform.position = new Vector3(-1f, -0.5f, 0);

        CreateGrid();
    }
Esempio n. 24
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        GridMaker maker = (GridMaker)target;

        if (GUILayout.Button("Build Grid"))
        {
            maker.CreateGrid();
        }

        if (GUILayout.Button("Delete Grid"))
        {
            maker.DeleteGrid();
        }
    }
Esempio n. 25
0
    // Start is called before the first frame update
    void Start()
    {
        tiles      = new GameObject[Width, Height];
        gridHolder = new GameObject();
        gridHolder.transform.position = new Vector3(0, 0, 0);

        Instance = this;

        source = GetComponent <AudioSource>();


        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                GameObject newTile = Instantiate(tilePrefab);
                newTile.transform.parent        = gridHolder.transform;
                newTile.transform.localPosition = new Vector2(Width - x - xOffset, Height - y - yOffset);
                tiles[x, y] = newTile;
                TileScript tileScript = newTile.GetComponent <TileScript>();
                tileScript.SetSprite(Random.Range(0, tileScript.Sprites.Length));
            }
        }

        if (!TimerScript.Paused)
        {
            source.PlayOneShot(Music, Vol2);
            Debug.Log("music");
        }

        //particles

        /*ParticleSystem particleSys = tilePrefab.GetComponent<ParticleSystem>();
         * var em = particleSys.emission;
         * em.enabled = false;
         */


        GameObject centerTile = tiles[Width / 2, Height / 2];
        GameObject newPlayer  = Instantiate(playerPrefab);

        newPlayer.transform.parent        = gridHolder.transform;
        newPlayer.transform.localPosition = centerTile.transform.localPosition;
        Destroy(centerTile);
        tiles[Width / 2, Height / 2] = newPlayer;
        //Destroy(tiles[2,3]);
    }
Esempio n. 26
0
    public CreateRoomWindow(Architect g)
    {
        GameObject gpo = new GameObject();

        gpo.name    = "CreateGridPreview";
        gridPreview = (GridMaker)gpo.AddComponent(typeof(GridMaker));
        //gridPreview.setup(posx, posy, width, height, 2);
        architect = g;

        if (gridPreview.setup(posx, posy, width, height, 2))
        {
            // position the camera in the middle of the new room
            architect.setPosition(posx + (width / 2), posy + (height / 2));
        }

        title = "Create Room";
    }
Esempio n. 27
0
    // Use this for initialization
    void Start()
    {
        //grab the grid maker
        grid = GameObject.Find("Grid");
        DebugUtils.Assert(grid);
        gridMaker = grid.GetComponent <GridMaker> ();
        DebugUtils.Assert(gridMaker);
        sand = GameObject.Find("SandBackground");
        DebugUtils.Assert(sand);
        cameraObject = GameObject.Find("Main Camera");
        DebugUtils.Assert(cameraObject);


        //make sure we have a global state - create one if it's missing (probably started scene from within Unity editor)
        GameObject glob = GameObject.Find("GlobalState");

        if (glob)
        {
            globalState = glob.GetComponent <GlobalState>();
        }
        else
        {
            globalState = grid.AddComponent <GlobalState>();
            Debug.LogWarning("Creating global state object on the fly - assuming game is running in editor");
        }

        //size the ant to fill one grid cell, and put it in a bottom centre cell
        Sprite sprite = GetComponent <SpriteRenderer> ().sprite;

        antBounds            = sprite.bounds;
        transform.localScale = new Vector3(1.0f / antBounds.size.x * gridMaker.gridCellWidth, 1.0f / antBounds.size.y * gridMaker.gridCellHeight, 1.0f);
        antPos.x             = (int)(gridMaker.gridSizeHorizontal / 2.0f);
        targetPos            = antPos;


        ResetProbabilities();
        UpdateMovement();
    }
Esempio n. 28
0
    // Use this for initialization
    void Start()
    {
        NetworkStartPosition[] allPos = FindObjectsOfType <NetworkStartPosition>();
        NetworkStartPosition   myPos  = allPos[0];

        foreach (NetworkStartPosition p in allPos)
        {
            if (p.gameObject.transform.position == transform.position)
            {
                myPos = p;
            }
        }
        // Set Despawnpoint
        myPos.GetComponentInChildren <EndzoneDespawn>().gameObject.transform.SetParent(this.transform);

        // Set Grid
        GridMaker gm = myPos.GetComponentInChildren <GridMaker>();

        gm.gameObject.transform.SetParent(this.transform);
        gm.transform.position.Set(transform.position.x, 0.0f, transform.position.z);
        GetComponent <PlayerController>().Init();
        GetComponentInChildren <AlgorithmBot>(true).gridMaker = gm.gameObject;
    }
Esempio n. 29
0
    public void GenerateRoom()
    {
        if (parentRoomObject == null)
        {
            parentRoomObject      = new GameObject();
            parentRoomObject.name = "Room" + this.PositionX + "_" + this.PositionY;
            parentRoomObject.transform.localScale = new Vector3(1, 1, 1);
            parentRoomObject.transform.position   = new Vector3(this.PositionX, this.PositionY, 0);
        }

        if (grid != null)
        {
            //GameObject.DestroyImmediate(grid);
            //grid = null;
        }
        else
        {
            grid                  = new GameObject();
            grid.name             = "DisplayGrid";
            grid.transform.parent = parentRoomObject.transform;
            gridMaker             = (GridMaker)grid.AddComponent(typeof(GridMaker));
            gridMaker.posx        = this.PositionX;
            gridMaker.posy        = this.PositionY;
            gridMaker.width       = this.Width;
            gridMaker.height      = this.Height;
        }
        if (Layers != null)
        {
            int ix = 0;
            while (ix < Layers.Count)
            {
                Layers[ix].GenerateLayer(this);
                ix++;
            }
        }
    }
Esempio n. 30
0
 private void Awake()
 {
     grid = GetComponent <GridMaker>();
 }
Esempio n. 31
0
    // Use this for initialization
    void Start()
    {
        //grab the grid maker
        grid = GameObject.Find ("Grid");
        DebugUtils.Assert(grid);
        gridMaker = grid.GetComponent<GridMaker> ();
        DebugUtils.Assert(gridMaker);
        sand = GameObject.Find ("SandBackground");
        DebugUtils.Assert (sand);
        cameraObject = GameObject.Find ("Main Camera");
        DebugUtils.Assert(cameraObject);
        landslideIndicator = GameObject.Find("MySlider");
        DebugUtils.Assert (landslideIndicator);
        chanceDisplay = GameObject.Find("MyChanceDisplay");
        DebugUtils.Assert(chanceDisplay);
        timerDisplay = GameObject.Find("MyStageTimer");
        DebugUtils.Assert(timerDisplay);
        stageDisplay = GameObject.Find("MyStageIndicator");
        DebugUtils.Assert(stageDisplay);
        Text txt = stageDisplay.GetComponent<Text>();
        txt.text = "STAGE " + currentStage.ToString();
        finalChanceDisplay = GameObject.Find("MyLandslideChance");
        DebugUtils.Assert(finalChanceDisplay);

        //make sure we have a global state - create one if it's missing (probably started scene from within Unity editor)
        GameObject glob = GameObject.Find ("GlobalState");
        if (glob) {
            globalState = glob.GetComponent<GlobalState>();
        } else {
            globalState = grid.AddComponent<GlobalState>();
            Debug.LogWarning("Creating global state object on the fly - assuming game is running in editor");
        }

        //size the ant to fill one grid cell, and put it in a bottom centre cell
        Sprite sprite = GetComponent<SpriteRenderer> ().sprite;
        antBounds = sprite.bounds;
        transform.localScale = new Vector3 (1.0f/antBounds.size.x * gridMaker.gridCellWidth, 1.0f/antBounds.size.y*gridMaker.gridCellHeight, 1.0f);
        antPos.x = (int)(gridMaker.gridSizeHorizontal / 2.0f);
        targetPos = antPos;

        ResetProbabilities();
        UpdateMovement ();
    }