void Start() { CF = GameObject.Find("RimaVirtualBody/rima").GetComponent <bodyController>(); text = GameObject.Find("Canvas/InputField/Text").GetComponent <Text>(); ; ////client = new TcpClient("172.20.20.241", 8140); // client = new TcpClient("127.0.0.1", 8139); // netstream = client.GetStream(); clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //IPAddress mIp = IPAddress.Parse("172.20.20.241"); //IPEndPoint ip_end_point = new IPEndPoint(mIp, 8140); }
void loadObjs() { worldObject[] goArray = UnityEngine.MonoBehaviour.FindObjectsOfType(typeof(worldObject)) as worldObject[]; foreach (worldObject obj in goArray) { if (obj.objectName == "mainBody") { mainBody = (bodyController)obj; } else if (obj.objectName == "leftHand") { leftHand = obj; } else if (obj.objectName == "rightHand") { rightHand = obj; } } }
//The head moves if there is nothing blocking its current direction in the world. virtual public void Move() { PrintGrid(); if (oneMoveDelayDone) { oldVx = vx; oldVy = vy; } if (dir == dirs.LEFT) { vx = -1; vy = 0; } else if (dir == dirs.RIGHT) { vx = 1; vy = 0; } else if (dir == dirs.UP) { vx = 0; vy = 1; } else if (dir == dirs.DOWN) { vx = 0; vy = -1; } if (World.grid[posy - vy][posx + vx] <= 2) { if (digesting) { bodyController oldNext = next; next = ((GameObject)Instantiate(Resources.Load("prefabs/body"), new Vector3(posx * World.blockSize, -1 * posy * World.blockSize, 0), Quaternion.identity)).GetComponent <bodyController>(); next.setV(oldVx, oldVy); if (oldNext != null) { next.setNext(oldNext); } digesting = false; finishedDigesting = true; } if (World.grid[posy - vy][posx + vx] == World.FOOD) { Destroy(nextFood); World.generateFood(this); digesting = true; } if (!finishedDigesting) { World.grid[posy][posx] = World.FREE; } posy = posy - vy; posx = posx + vx; World.grid[posy][posx] = World.HEAD; transform.position = new Vector3(posx * World.blockSize, -1 * posy * World.blockSize, 0); if (!finishedDigesting && next != null) { next.Move(oldVx, oldVy); } oneMoveDelayDone = true; finishedDigesting = false; } else { Debug.Log("Game Over!"); World.Reset(); SceneManager.LoadScene("snake"); } }
void loadObjs() { worldObject[] goArray = UnityEngine.MonoBehaviour.FindObjectsOfType(typeof(worldObject)) as worldObject[]; foreach (worldObject obj in goArray) { if (obj.objectName == "mainBody") mainBody = (bodyController)obj; else if (obj.objectName == "leftHand") leftHand = obj; else if (obj.objectName == "rightHand") rightHand = obj; } }
public void setNext(bodyController bc) { next = bc; }