void Start() { cellQ = new List <Vector2>(400); qDist = new List <float>(400); cellSize = .2f; hCellNum = 25; vCellNum = 25; origin = new Vector3(-3, 3, 0); newPaint = false; newPaint2 = false; maxTimer = 60; Vector3 pos; //Quaternion angle = new Quaternion(0, 0, 0, 0); //Debug.Log(cellPrefab); GameObject backdrop = GameObject.CreatePrimitive(PrimitiveType.Cube); backdrop.transform.position = origin + 2.5f * Vector3.right + 2.5f * Vector3.down; backdrop.transform.localScale = new Vector3(5, 5, .01f); backdrop.GetComponent <Renderer>().material = new Material(Shader.Find("Sprites/Default")); backdrop.GetComponent <Renderer>().material.color = Color.white; backdrop.GetComponent <Renderer>().sortingLayerName = "Default"; backdrop.GetComponent <Renderer>().sortingOrder = 2; cells = new GameObject[hCellNum, vCellNum]; gotCell = new cell[hCellNum, vCellNum]; for (int i = 0; i < hCellNum; i++) { for (int j = 0; j < vCellNum; j++) { pos = origin + Vector3.right * cellSize * i + Vector3.down * cellSize * j; //newCell = Instantiate(cellPrefab, pos, angle) as UnityEngine.Object; //Debug.Log(newCell.GetComponent<cell>()); //GameObject c = GameObject.FindGameObjectWithTag("newCell"); //Debug.Log(newCell.GetType()); //cells[i][j] = newCell; newCell = GameObject.CreatePrimitive(PrimitiveType.Cube); newCell.transform.position = pos; newCell.transform.localScale = new Vector3(cellSize, cellSize, cellSize); newCell.GetComponent <Renderer>().material = new Material(Shader.Find("Sprites/Default")); //Debug.Log(newCell.GetType()); newCell.AddComponent <cell>(); //newCell.AddComponent<Collider2D>(); CHECK THIS LATER //moving to nontrigger paradigm //newCell.GetComponent<BoxCollider>().isTrigger = true; newCell.tag = "cell"; cells[i, j] = newCell; } } celLox = new Vector2[hCellNum, vCellNum]; for (int i = 0; i < hCellNum; i++) { for (int j = 0; j < vCellNum; j++) { celLox[i, j] = cells[i, j].transform.position; gotCell[i, j] = cells[i, j].GetComponent <cell>(); } } //p1 p1Brush = Instantiate(brushPrefab).GetComponent <brush>(); //Debug.Log(p1Brush); p1Brush.playerNum = 1; p1Input = Instantiate(inputHandlerPrefab).GetComponent <inputHandler>(); var initPos = new Vector3(-3, -3, 0); p1bucket = Instantiate(bucketPrefab, initPos, Quaternion.identity).GetComponent <bucket>(); p1bucket.playerNum = 1; //p1oom = false; p1color = Color.blue; p1Brush.myColor = Color.blue; //p2 p2Brush = Instantiate(brushPrefab).GetComponent <brush>(); //Debug.Log(p1Brush); p2Brush.playerNum = 2; p2Input = Instantiate(p2testInputPrefab).GetComponent <p2testInputHandler>(); initPos = new Vector3(3, -3, 0); p2bucket = Instantiate(bucketPrefab, initPos, Quaternion.identity).GetComponent <bucket>(); p2bucket.playerNum = 2; //p2oom = false; p2color = Color.magenta; p2Brush.myColor = Color.magenta; frame1 = true; cellQ.Clear(); qDist.Clear(); //bfsSort= }
void Start() { //Debug.Log(Screen.width); //Debug.Log(Camera.main.fieldOfView); //Debug.Log(Camera.main); displayScore = false; started = false; sliderCanvas = GameObject.FindGameObjectWithTag("sliderCanvas").GetComponent <Canvas>(); chargeSlider = GameObject.FindGameObjectWithTag("chargeSlider").GetComponent <Slider>(); scoreSlider = GameObject.FindGameObjectWithTag("scoreSlider").GetComponent <Slider>(); scrt = sliderCanvas.GetComponent <RectTransform>(); csrt = chargeSlider.GetComponent <RectTransform>(); //Debug.Log(GameObject.FindGameObjectWithTag("chargeSlider")); csFill = (chargeSlider as UnityEngine.UI.Slider).GetComponentsInChildren <UnityEngine.UI.Image>().FirstOrDefault(t => t.name == "csFill"); ammoSlider = GameObject.FindGameObjectWithTag("ammoSlider").GetComponent <Slider>(); Debug.Log("network mode"); gotBoard = false; ready = false; cd = false; cdTimer = 0; cellTemp = new List <GameObject>(625); cellQ = new List <Vector2>(625); qDist = new List <float>(625); cellSize = .2f; hCellNum = 25; vCellNum = 25; origin = new Vector3(-3, 3, 0); newPaint = false; newPaint2 = false; addingAmmo = false; maxTimer = 60; //Vector3 pos; //Quaternion angle = new Quaternion(0, 0, 0, 0); //Debug.Log(cellPrefab); worldToCanvasConversion(scrt, Camera.main, origin + Vector3.up * cellSize * (vCellNum / 8) + Vector3.right * cellSize * (hCellNum / 2)); //+ Vector3.up * .5f) scoreSlider.GetComponent <RectTransform>().anchoredPosition = w2c; GameObject backdrop = GameObject.CreatePrimitive(PrimitiveType.Cube); backdrop.transform.position = origin + 2.5f * Vector3.right + 2.5f * Vector3.down; backdrop.transform.localScale = new Vector3(5, 5, .01f); backdrop.GetComponent <Renderer>().material = new Material(Shader.Find("Sprites/Default")); backdrop.GetComponent <Renderer>().material.color = Color.white; backdrop.GetComponent <Renderer>().sortingLayerName = "Default"; backdrop.GetComponent <Renderer>().sortingOrder = 2; cells = new GameObject[hCellNum, vCellNum]; gotCell = new _netCell[hCellNum, vCellNum]; celLox = new Vector2[hCellNum, vCellNum]; PhotonNetwork.ConnectUsingSettings("alpha"); //Debug.Log("wait for connection?"); //p1 p1Brush = Instantiate(brushPrefab).GetComponent <_netBrush>(); //Debug.Log(p1Brush); p1Brush.playerNum = 1; p1Input = Instantiate(inputHandlerPrefab).GetComponent <_netInputHandler>(); var initPos = new Vector3(-3, -3, 0); p1bucket = Instantiate(bucketPrefab, initPos, Quaternion.identity).GetComponent <_netBucket>(); p1bucket.playerNum = 1; worldToCanvasConversion(scrt, Camera.main, initPos + Vector3.down * .6f); //+ Vector3.up * .5f) ammoSlider.GetComponent <RectTransform>().anchoredPosition = w2c; //p1oom = false; //p1color = Color.blue; //p1Brush.myColor = Color.blue; //p2 p2Brush = Instantiate(brushPrefab).GetComponent <_netBrush>(); //Debug.Log(p1Brush); p2Brush.playerNum = 2; p2Input = Instantiate(p2testInputPrefab).GetComponent <p2testInputHandler>(); initPos = new Vector3(3, -3, 0); p2bucket = Instantiate(bucketPrefab, initPos, Quaternion.identity).GetComponent <_netBucket>(); p2bucket.playerNum = 2; //p2oom = false; p2color = Color.magenta; p2Brush.myColor = Color.magenta; cellQ.Clear(); qDist.Clear(); //bfsSort= }