Exemple #1
0
        private void grdCurrentMissions_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int          selectedRowIndex, idMission;
            DataGridView grdCurrentMissions = (DataGridView)sender;

            selectedRowIndex = grdCurrentMissions.SelectedRows[0].Index;
            int.TryParse(grdCurrentMissions.Rows[selectedRowIndex].Cells["ID"].FormattedValue.ToString(), out idMission);

            MissionDetail missionDetailForm = new MissionDetail(idMission, true, false);

            missionDetailForm.ShowDialog();

            FillGrdCurrentMissions();
        }
    // Use this for initialization
    void Start()
    {
        camerapage.SetActive(false);
        messagepage.SetActive(false);
        soundpage.SetActive(false);
        statpage.SetActive(false);
        mobile.SetActive(false);
        settingpage.SetActive(false);
        wpicon.SetActive(true);
        albumpage.SetActive(false);
        docraw.SetActive(false);
        docManager = new DocManager();
        docManager.collectDoc(0, true);
        mission    = messagepage.GetComponent <MissionDetail>();
        documentID = -1;

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterEmotion>();
        system = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <GameController>();
    }
Exemple #3
0
    void Start()
    {
        iActiveMissionCount = 3;        //three missions active at a time by deafult
        missionsProgress    = new int[System.Enum.GetValues(typeof(MissionTypes)).Length];

        //set the next mission index
        if (PlayerPrefs.HasKey("NextMissionIndex"))
        {
            iNextMission = PlayerPrefs.GetInt("NextMissionIndex");
        }
        else
        {
            iNextMission = 0;
            PlayerPrefs.SetInt("NextMissionIndex", iNextMission);
        }

        hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));

        if (hInGameScriptCS.isCustomMenuEnabled())
        {
            hMenuScriptCS    = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
            hHUDControllerCS = (HUDControllerCS)GameObject.Find("HUDMainGroup").GetComponent(typeof(HUDControllerCS));
        }
        else
        {
            hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
            hNGUIHUDScript  = hNGUIMenuScript.getNGUIHUDScriptReference();
        }

        //get the MissionList file from the resources folder
        TextAsset taFile = (TextAsset)Resources.Load("MissionsList");

        string[] lines = taFile.text.Split('\n');

        if (lines.Length == 0)        //if the file was empty
        {
            Debug.Log("No missions found in file");
            this.enabled = false;
        }
        else        //read file and extract mission detail
        {
            int lineIndex  = 0;
            int arrayIndex = 0;
            iTotalMissionCount = lines.Length / 3;
            missions           = new MissionDetail[iTotalMissionCount];  //allocate memory according to the number of missions
            for (int i = 0; i < iTotalMissionCount; i++)
            {
                missions[i] = new MissionDetail();
            }

            while (lineIndex < lines.Length)            //store the file content in mission array
            {
                missions[arrayIndex].missionDescription = lines[lineIndex++];
                missions[arrayIndex].missionCount       = int.Parse(lines[lineIndex++]);
                missions[arrayIndex].missionType        = (MissionTypes)System.Enum.Parse(typeof(MissionTypes), lines[lineIndex++]);

                arrayIndex++;
            }            //end of while

            iActiveMissions = new int[iActiveMissionCount];
            for (int i = 0; i < iActiveMissionCount; i++)        //set the currently active missions
            {
                if (PlayerPrefs.HasKey("ActiveMission_" + i.ToString()))
                {
                    iActiveMissions[i] = PlayerPrefs.GetInt("ActiveMission_" + i.ToString());
                }
                else
                {
                    iActiveMissions[i] = getNextMission();
                    PlayerPrefs.SetInt("ActiveMission_" + i.ToString(), iActiveMissions[i]);
                }
            }            //end of for

            updateMenuDescriptions();
        }        //end of else

        PlayerPrefs.Save();
    }
Exemple #4
0
        private void btnUpdateVehicleLocation_Click(object sender, EventArgs e)
        {
            bool isMissingInfo = false;
            int  selectedRowIndex, idMission, newStatus;

            if (grdCurrentMissions.Rows.Count > 0)
            {
                selectedRowIndex = grdCurrentMissions.SelectedRows[0].Index;
                int.TryParse(grdCurrentMissions.Rows[selectedRowIndex].Cells["ID"].FormattedValue.ToString(), out idMission);

                Mission currentMission;
                if (_CurrentMissions.Count > 0)
                {
                    currentMission = _CurrentMissions.Where(a => a.ID == idMission).First();

                    newStatus = currentMission.Status + 1;

                    if (newStatus == (int)MissionStatusEnum.DetailsFilled)
                    {
                        _CurrentMissions = OperationsBlo.GetCurrentMissions();
                        currentMission   = _CurrentMissions.Where(a => a.ID == idMission).First();
                        CheckIfMissingInfoExist(currentMission, out isMissingInfo);
                        if (isMissingInfo)
                        {
                            MissionDetail missionDetail = new MissionDetail(idMission, true, true);
                            missionDetail.Show();
                            _CurrentMissions = OperationsBlo.GetCurrentMissions();
                            currentMission   = _CurrentMissions.Where(a => a.ID == idMission).First();
                            CheckIfMissingInfoExist(currentMission, out isMissingInfo);
                        }
                    }

                    if (isMissingInfo)
                    {
                        MessageBox.Show("الرجاء تعبئة كل تفاصيل المهمة", "تحذير", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        OperationsBlo.MoveVehicleToNextLocation(currentMission, newStatus);

                        if (newStatus == (int)MissionStatusEnum.ArrivalToCenter)
                        {
                            _CurrentMissions = OperationsBlo.GetCurrentMissions();
                            currentMission   = _CurrentMissions.Where(a => a.ID == idMission).First();
                            OperationsBlo.UpdateMissionDuration(currentMission);
                        }

                        FillGrdCurrentMissions();

                        if (newStatus != (int)MissionStatusEnum.DetailsFilled)
                        {
                            //Select the current row after filling the grid grdCurrentMissions
                            grdCurrentMissions.CurrentCell = grdCurrentMissions.Rows[selectedRowIndex].Cells[1];
                        }
                        else
                        {
                            //Update vehicle last mileage in case the mission is completed
                            //and all the details are filled(so the mission is closed and moved to day missions)
                            OperationsBlo.UpdateVehicleLastMileage(currentMission);
                        }

                        FillGrdDayMissions();
                    }
                }
            }
        }