Answer the question
In order to leave comments, you need to log in
Why doesn't the same code work?
There are two parts of the code, almost exactly the same: only the names of the buttons and the location of the camera differ, the structure and algorithms are the same, but one part works, the other does not. What can be wrong?
One part:
case 1:
cam = GetComponent<Camera>();
cam.orthographicSize = 8;
this.transform.position = new Vector3(0,25,-10);
LocationButton = new Rect(new Vector2(ScreenCenter_X-200,0), new Vector2(250,190));
GUI.Box(LocationButton,"");
LocationButton = new Rect(new Vector2(ScreenCenter_X-85, 10), new Vector2(200,30));
GUI.Label(LocationButton,"Док");
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 50), new Vector2(200,30));
if(GUI.Button(LocationButton,"Вернуться в меню")){
PlayerPoleControl.Clear();
GameMode=0;
}
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 90), new Vector2(200,30));
if(GUI.Button(LocationButton,"Разместить флот")){
PlayerPoleControl.randomShips();
}
if(PlayerPoleControl.LifeShip()==20){
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 130), new Vector2(200,30));
if(GUI.Button(LocationButton,"В бой")) {
if(WhoPlayMode==1){
GameMode=2;
Player.GetComponent<GameField>().CopyMap();
Computer.GetComponent<GameField>().randomShips();
}
}
}
break;
cam = GetComponent<Camera>();
cam.orthographicSize = 8;
this.transform.position = new Vector3(48,27,-10);
LocationButton = new Rect(new Vector2(ScreenCenter_X-200,0), new Vector2(250,190));
GUI.Box(LocationButton,"");
LocationButton = new Rect(new Vector2(ScreenCenter_X-120, 10), new Vector2(200,30));
GUI.Label(LocationButton,"Первый игрок");
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 50), new Vector2(200,30));
if(GUI.Button(LocationButton,"Вернуться в меню")){
PlayerPoleControl.Clear();
GameMode=0;
}
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 90), new Vector2(200,30));
if(GUI.Button(LocationButton,"Разместить флот1 ")){
PlayerPoleControl.randomShips();
}
if(PlayerPoleControl.LifeShip()==20){
LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 130), new Vector2(200,30));
if(GUI.Button(LocationButton,"В бой!")) {
Player.GetComponent<GameField>().CopyMap();
}
}
break;
Answer the question
In order to leave comments, you need to log in
In the second case, there is no call to Computer.GetComponent().randomShips();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question