void Start() { mission_desc = missionText.GetComponentInChildren <Text> (); mission = GameControl.missiondb.get_mission(GameControl.control.selected_mission); if (mission == null) { Debug.LogError("debriefing: No mission"); //return; // for testing mission = GameControl.missiondb.get_mission(new MissionID("1:1")); Debug.Log("debriefing: Using mission " + mission.id.id + " for now"); } mission_desc.text = "Uppdrag> " + mission.title + "\n\n" + mission.short_desc + "\n\n" + mission.long_desc; t = 1; ending = false; gemsize = 1; content.transform.localPosition = new Vector3( content.transform.localPosition.x, 500f, content.transform.localPosition.z); missionGem = cameraA.AddComponent <MissionBall> (); missionGem.init(mission.id, cameraA, new Vector3(0, 0, 0), true, new Vector3(0, 0.8f, 2.5f), new Vector3(gemsize, gemsize, gemsize)); }
void fillMissionPipeline() { //Debug.Log ("===== fillMissionPipeline: Balls ====="); float pipe_y = 2.0f; foreach (var mid in GameControl.missiondb.get_ids()) { if (OngoingMission.get_missions(GameControl.control.pad.ongoing_missions).Contains(mid) || GameControl.control.pad.completed_missions.Contains(mid)) { //Debug.Log ("Skipping ongoing/completed mission " + mid.id); continue; } else { Debug.Log("Instantiating ball " + mid.id); MissionBall mb = gameObject.AddComponent <MissionBall> (); mb.init(mid, pipe, new Vector3((Random.value - 0.5f) * 2.0f, pipe_y, 0)); pipe_y += 2.0f; } } //Debug.Log ("===== fillMissionPipeline: Buttons ====="); float panel_y = 0.0f; foreach (var mid in OngoingMission.get_missions(GameControl.control.pad.ongoing_missions)) { //Debug.Log ("Instantiating button " + mid.id + " at y=" + (panel_y).ToString ()); panel_y += button_offset; RectTransform containerRectTransform = panel.GetComponent <RectTransform> (); containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -button_offset); containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, -panel_y - button_offset / 2); MissionButton mb = gameObject.AddComponent <MissionButton> (); mb.init(mid, panel, new Vector3(0, panel_y - button_offset, 0)); } Debug.Log("===== fillMissionPipeline: done ====="); }
public void init(MissionID mid, GameObject parent, Vector3 position) { omi = GameControl.control.get_ongoing_mission(mid); if (omi == null) { Debug.LogError("MissionButton: mid " + mid.id + " not ongoing"); return; } mission = GameControl.missiondb.get_mission(mid); UnityEngine.Object mission_prefab; switch (omi.get_timing()) { case OngoingMission.Timing.Ongoing: mission_prefab = Resources.Load("Prefabs/MissionButtons/OngoingMission"); break; case OngoingMission.Timing.Ended: mission_prefab = Resources.Load("Prefabs/MissionButtons/EndedMission"); break; default: case OngoingMission.Timing.Overdue: mission_prefab = Resources.Load("Prefabs/MissionButtons/OverdueMission"); break; } button = Instantiate( mission_prefab, new Vector3(0, 0, 0), Quaternion.identity, parent.transform) as GameObject; button.name = mission.id.id; button.transform.localScale = new Vector3(1, 1, 1); button.transform.localPosition = position; //Debug.Log ("MissionButton: Instantiantion successful"); Button uibutton = button.GetComponent <Button>(); uibutton.onClick.AddListener(() => { button_clicked(); }); // Setup sphere ball = button.AddComponent <MissionBall> (); ball.init(mid, button, new Vector3(0, 0, 0), true, new Vector3(-140f, 0f, 0f), new Vector3(40f, 40f, 0.4f)); // Setup text mission_title = button.GetComponentInChildren <Text> (); mission_title.text = mission.title; // Setup timer mission_timer = button.GetComponentInChildren <Slider> (); if (omi.get_timing() != OngoingMission.Timing.Overdue) { TimeSpan remain = omi.get_remaining_time(); mission_timer.maxValue = omi.days * 24 * 60; mission_timer.minValue = 0; mission_timer.value = (int)remain.TotalMinutes; mission_timer_text = mission_timer.GetComponentInChildren <Text> (); mission_timer_text.text = mission_timer_text.text = omi.get_remaining_time_description(); } else { mission_timer.enabled = false; } }