示例#1
0
        private void OnGUI() {
                if(!isSelected) return;

                if(delay > 0) {
                        if(sabotageTime > 0) {
                                GUI.Box(new Rect(10, Camera.main.pixelHeight - 100, 64, 25), ((int)Mathf.Ceil((float)(delay * sabotageTimeMultiplier))).ToString());
                        } else {
                                GUI.Box(new Rect(10, Camera.main.pixelHeight - 100, 64, 25), ((int)Mathf.Ceil((float)delay)).ToString());
                        }
                } else {
                        GUI.Box(new Rect(10, Camera.main.pixelHeight - 100, 64, 25), "Ready");
                }
                if(sabotageTime > 0) {
                        GUI.Box(new Rect(84, Camera.main.pixelHeight - 100, 100, 25), "Sabotaged! " + Mathf.Ceil((float)sabotageTime));
                }

                var building = buildQueue.Any() ? buildQueue.Peek().what : -1;

                for(int i = 0; i < prefabs.Length; ++i) {
                        GUI.backgroundColor = (i == building && Time.time % 1 < 0.5f) ? Color.green : Color.white;
                        // Closures!
                        var prefab = prefabs[i];
                        var id = i;

                        if(GUI.Button(new Rect(10 + i * 74, Camera.main.pixelHeight - 74, 64, 64),
                                      new GUIContent(prefab.buildIcon, prefab.BuildToolTip()))) {
                                if(prefab.buildAtPoint) {
                                        playerInterface.PlaceThingOnTerrain(prefab.ghostPrefab,
                                                                            position => { return CanPlaceAt(prefab, position); },
                                                                            position => ComSat.IssueBuild(entity, id, position, false));
                                } else {
                                        ComSat.IssueBuild(entity, id, new DVector2(), Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift));
                                }
                        }

                        GUI.backgroundColor = Color.white;

                        var queued = buildQueue.Count(qi => qi.what == i);
                        if(queued > 0) {
                                GUI.Label(new Rect(14 + i * 74, Camera.main.pixelHeight - 70, 64, 24), buildQueue.First(qi => qi.what == i).repeat ? "\u221e" : queued.ToString());
                        }
                }

                GUI.Label(new Rect(0,30,200,300), GUI.tooltip);

                if(buildQueue.Any() && GUI.Button(new Rect(10 + prefabs.Length * 74, Camera.main.pixelHeight - 74, 64, 64), "Stop")) {
                        ComSat.IssueUIAction(entity, clearQueue);
                }
        }