// Update is called once per frame void Update() { if (frame1) { p1Brush.playerNum = 1; p1bucket.playerNum = 1; p2Brush.playerNum = 2; p2bucket.playerNum = 2; //setAllCellBFS(); //Debug.Log("clearing old values"); unmarkAllCells(); clearAllCellBFS(); //Debug.Log("calling bfs"); gotCell[0, 0].marked = true; cellQ.Clear(); qDist.Clear(); Vector2 v0 = Vector2.zero; //setAllCellBFS(); setAllCellDistsTemp(); sortCellDists(); /* * for (int t=0; t < hCellNum * vCellNum - 1; t++) * { * Debug.Log(gotCell[5,5].bfs[t]); * } */ /* * cellQ.Add(v0); * qDist.Add(0); * cellBFS(0,0, -1); */ /* * Debug.Log(gotCell[0,0].bfs[0]); * Debug.Log(gotCell[0, 0].bfs[1]); * Debug.Log(gotCell[0, 0].bfs[2]); * Debug.Log(gotCell[0, 0].bfs[3]); * Debug.Log(gotCell[0, 0].bfs[4]); * Debug.Log(gotCell[0, 0].bfs[5]); * Debug.Log(gotCell[0, 0].bfs[6]); * Debug.Log(gotCell[0, 0].bfs[7]); * Debug.Log(gotCell[0, 0].bfs[8]); * Debug.Log(gotCell[0, 0].bfs[9]); */ for (int i = 0; i < hCellNum; i++) { for (int j = 0; j < vCellNum; j++) { p1Brush.cells[i, j] = cells[i, j]; p1Brush.celLox[i, j] = celLox[i, j]; p1Brush.gotCell[i, j] = cells[i, j].GetComponent <cell>(); } } for (int i = 0; i < hCellNum; i++) { for (int j = 0; j < vCellNum; j++) { p2Brush.cells[i, j] = cells[i, j]; p2Brush.celLox[i, j] = celLox[i, j]; p2Brush.gotCell[i, j] = cells[i, j].GetComponent <cell>(); } } frame1 = false; } //P1 p1Input.inputUpdate(); var v3 = Input.mousePosition; v3.z = 00.0f; v3 = Camera.main.ScreenToWorldPoint(v3); if (p1Brush.onBucket && p1Brush.isPainting) { if (p1Brush.ammo < p1Brush.maxAmmo) { //ammo++; p1Brush.ammo = p1Brush.ammo + 6; if (p1Brush.ammo == p1Brush.maxAmmo) { Debug.Log("full charge"); } if (p1Brush.ammo == p1Brush.paintTypeThreshold) { Debug.Log("half charge"); } } } if (!p1Brush.isPainting) { p1Brush.moveToXY(v3.x, v3.y); if (p1Brush.used) { newPaint = true; timer = maxTimer; p1Brush.ammo = 0; p1Brush.used = false; } } else { if (p1Brush.ammo > 0 && !p1Brush.onBucket) { if (p1Brush.drawType == "line") { p1Brush.moveToXYcapped(v3.x, v3.y); // put a different move function here if (p1Brush.lastFramePainting) { p1Brush.lastFramePainting = false; newPaint = true; timer = maxTimer; } } if (p1Brush.drawType == "dot") { //Debug.Log("dot"); p1Brush.dotPaint(); p1Brush.ammo = 0; newPaint = true; timer = maxTimer; } } } if ((!p1Input.mouseDown || ((p1Brush.ammo) <= 0) && !p1Brush.onBucket) && p1Brush.isPainting) { p1Brush.stopPainting(); //Debug.Log("stop painting"); } if (p1Input.mouseDown && !p1Brush.isPainting) { p1Brush.startPainting(); } // END P1 //P2 p2Input.inputUpdate(); v3 = Input.mousePosition; v3.z = 00.0f; v3 = Camera.main.ScreenToWorldPoint(v3); if (p2Brush.onBucket && p2Brush.isPainting) { if (p2Brush.ammo < p2Brush.maxAmmo) { //ammo++; p2Brush.ammo = p2Brush.ammo + 6; if (p2Brush.ammo == p2Brush.maxAmmo) { Debug.Log("full charge"); } if (p2Brush.ammo == p2Brush.paintTypeThreshold) { Debug.Log("half charge"); } } } if (!p2Brush.isPainting) { p2Brush.moveToXY(v3.x + 2, v3.y); // add 2 to offset players for testing purposes only if (p2Brush.used) { newPaint = true; timer = maxTimer; p2Brush.ammo = 0; p2Brush.used = false; } } else { if (p2Brush.ammo > 0 && !p2Brush.onBucket) { if (p2Brush.drawType == "line") { p2Brush.moveToXYcapped(v3.x + 2, v3.y); // put a different move function here // add 2 to offset players for testing purposes only if (p2Brush.lastFramePainting) { p2Brush.lastFramePainting = false; newPaint = true; timer = maxTimer; } } if (p2Brush.drawType == "dot") { //Debug.Log("dot"); p2Brush.dotPaint(); p2Brush.ammo = 0; newPaint = true; timer = maxTimer; } } } if ((!p2Input.mouseDown || ((p2Brush.ammo) <= 0) && !p2Brush.onBucket) && p2Brush.isPainting) { p2Brush.stopPainting(); //Debug.Log("stop painting"); } if (p2Input.mouseDown && !p2Brush.isPainting) { p2Brush.startPainting(); } //END P2 if (newPaint) { //Debug.Log("newPaint"); if (timer > 0) { timer--; } else { newPaint = false; { for (int i = 0; i < hCellNum; i++) { for (int j = 0; j < vCellNum; j++) { updateClosestPlayer(i, j); if (gotCell[i, j].closestPlayer == 1) { gotCell[i, j].updateClosestVisual(p1color); } if (gotCell[i, j].closestPlayer == 2) { gotCell[i, j].updateClosestVisual(p2color); } } } } //Debug.Log(gotCell[0, 0].r.material.color.a); } } }
public void p2Update() //for testing { //P2 p2Input.inputUpdate(); var v3 = Input.mousePosition; v3.z = 00.0f; v3 = Camera.main.ScreenToWorldPoint(v3); if (p2Brush.onBucket && p2Brush.isPainting) { if (p2Brush.ammo < p2Brush.maxAmmo) { //ammo++; p2Brush.ammo = p2Brush.ammo + 6; if (p2Brush.ammo == p2Brush.maxAmmo) { Debug.Log("full charge"); } if (p2Brush.ammo == p2Brush.paintTypeThreshold) { Debug.Log("half charge"); } } } if (!p2Brush.isPainting) { p2Brush.moveToXY(v3.x + 2, v3.y); // add 2 to offset players for testing purposes only if (p2Brush.used) { newPaint = true; timer = maxTimer; p2Brush.ammo = 0; p2Brush.used = false; } } else { if (p2Brush.ammo > 0 && !p2Brush.onBucket) { if (p2Brush.drawType == "line") { p2Brush.moveToXYcapped(v3.x + 2, v3.y); // put a different move function here // add 2 to offset players for testing purposes only if (p2Brush.lastFramePainting) { p2Brush.lastFramePainting = false; newPaint = true; timer = maxTimer; } } if (p2Brush.drawType == "dot") { //Debug.Log("dot"); p2Brush.dotPaint(); //p2Brush.dotpaintRPCcaller(); p2Brush.ammo = 0; newPaint = true; timer = maxTimer; } } } if ((!p2Input.mouseDown || ((p2Brush.ammo) <= 0) && !p2Brush.onBucket) && p2Brush.isPainting) { p2Brush.stopPainting(); //Debug.Log("stop painting"); } if (p2Input.mouseDown && !p2Brush.isPainting) { p2Brush.startPainting(); } //END P2 }