Exemple #1
0
        // Returns the SDK version specified in the .OPM file. Otherwise, returns null
        public static string GetSDKVersion(MissionData missionData)
        {
            string missionPath = Path.Combine(GetCachePath(), missionData.missionID.ToString());

            // DLL or OPM
            string dllName           = missionData.fileNames.FirstOrDefault((filename) => filename.IndexOf(".dll", System.StringComparison.OrdinalIgnoreCase) >= 0);
            string opmName           = missionData.fileNames.FirstOrDefault((filename) => filename.IndexOf(".opm", System.StringComparison.OrdinalIgnoreCase) >= 0);
            bool   isStandardMission = string.IsNullOrEmpty(dllName) && !string.IsNullOrEmpty(opmName);

            if (isStandardMission)
            {
                // Get the SDK version from the mission file
                try
                {
                    string      filePath = Path.Combine(missionPath, opmName);
                    MissionRoot root     = MissionReader.GetMissionData(filePath);
                    return(root.sdkVersion);
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex);
                }
            }

            return(null);
        }
    int zFront = 0; //forward

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        dropDownMenuObject = GameObject.Find("Panel").GetComponent<DropDownMenu>();
        missionReader = GameObject.FindGameObjectWithTag("Grid").GetComponent<MissionReader>();
        astarPath = GameObject.FindGameObjectWithTag("Grid").GetComponent<AstarPath>();
        xLeft = -27;
        xRight = 27;
        zFront = -110;
        zBack = -140;
    }
Exemple #3
0
 private MissionRoot GetMissionData(string path)
 {
     try
     {
         return(MissionReader.GetMissionData(path));
     }
     catch (System.Exception ex)
     {
         Debug.LogException(ex);
         return(null);
     }
 }
Exemple #4
0
        private MissionRoot LoadMission(string path)
        {
            MissionRoot missionRoot = null;

            // Load mission
            try
            {
                missionRoot = MissionReader.GetMissionData(path);
            }
            catch (System.Exception ex)
            {
                Debug.LogException(ex);
            }

            return(missionRoot);
        }
Exemple #5
0
        private void LoadMissions()
        {
            _MissionListBox.Clear();

            // Read missions in "ColonyGames" directory
            if (!Directory.Exists("ColonyGames"))
            {
                return;
            }

            // Add missions to list box
            foreach (string file in Directory.EnumerateFiles("ColonyGames", "*.opm", SearchOption.AllDirectories))
            {
                try
                {
                    MissionRoot mission = MissionReader.GetMissionData(file);
                    _MissionListBox.AddItem(mission.levelDetails.description, new ListBoxItemContents(file, mission));
                }
                catch (System.Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
        }
Exemple #6
0
 public void ExportMission(string path)
 {
     MissionReader.WriteMissionData(path, mission);
 }
Exemple #7
0
    //Create the grid squares
    void Update()
    {
        if(mReaderObject == null)
        {
            mReaderObject = GameObject.Find("A*").GetComponent<MissionReader>();
        }
        if(AstarPath.active.graphs[0] != null && (graphObject == null || graphObject != AstarPath.active.graphs[0] as GridGraph))
        {
            graphObject = AstarPath.active.graphs[0] as GridGraph;
        }
        if(mReaderObject.returnLayoutCompleted() == true)
        {
            if(gridParent == null)
            {
                gridParent = GameObject.Instantiate(Resources.Load("GridParent")) as GameObject;
            }
            if(depthCounter==graphObject.depth){
                createGrid = false;
                }
            if(createGrid){
                gridParent.transform.position = astarGrid.GetComponent<AstarPath>().astarData.gridGraph.center;
                for(int i = 0; i < graphObject.width; i++)
                {

                    instantiatedCollider = Instantiate(theCollider) as GameObject;
                    createdCount++;

                    if(atStart)
                    {
                        positionValues.y = astarGrid.transform.position.y+0.25f;
                        positionValues.x = astarGrid.transform.position.x + graphObject.nodeSize/2 - graphObject.unclampedSize.x/2;
                        positionValues.z = astarGrid.transform.position.z - graphObject.nodeSize/2 + graphObject.unclampedSize.y/2;
                        atStart = false;
                    }
                    else if(!atStart && !reset)
                    {
                        if(positionValues.x+graphObject.nodeSize >= astarGrid.transform.position.x + graphObject.unclampedSize.x/2)
                        {
                            depthCounter++;
                            positionValues.z -= graphObject.nodeSize;
                            positionValues.x = astarGrid.transform.position.x + graphObject.nodeSize/2 - graphObject.unclampedSize.x/2;
                        }
                        else
                        {
                            positionValues.x += graphObject.nodeSize;
                        }
                    }
                 	instantiatedCollider.transform.position = positionValues;
                    instantiatedCollider.name = instantiatedCollider.name + createdCount.ToString();
                    instantiatedCollider.GetComponent<Grid>().setXY(i+1,depthCounter);
                    instantiatedCollider.transform.parent = gridParent.transform;
                    gridColliders.Add(instantiatedCollider);
                }

                //This is mostly debug, we will be doing this with the mission creator later
            } else if(!missionInit){
                if(astarGrid.GetComponent<MissionReader>().rotate == true){
                    gridParent.transform.rotation = Quaternion.Euler(astarGrid.GetComponent<AstarPath>().astarData.gridGraph.rotation);

                }
                missionInit = true;
                if(mReaderObject.currentMission == 2){
                    mReaderObject.optionalTiles.Add(GameObject.Find("GridSquare(Clone)4"));
                    mReaderObject.optionalTiles.Add(GameObject.Find("GridSquare(Clone)5"));
                    mReaderObject.optionalTiles.Add(GameObject.Find("GridSquare(Clone)6"));
                }
                mReaderObject.PositionUnits();
            }
        }
            if(mReaderObject.returnNewMission() == true && gridColliders.Count > 0)
            {
                gridParent.transform.rotation = Quaternion.identity;
                int gridSquareCounter = 0;
                foreach(GameObject gridSquare in gridColliders)
                {
                    DestroyObject(gridColliders[gridSquareCounter]);
                    gridSquareCounter++;
                }
                graphObject = null;
                depthCounter = 1;
                atStart = true;
                createGrid = true;
                createdCount = 0;
                missionInit = false;
                gridColliders.Clear();

            }
        //		if(mReaderObject.returnLayoutCompleted() == false){
        //			if(graphObject == null)
        //			{
        //				graphObject = AstarPath.active.graphs[0] as GridGraph;
        //			}
        //		}
    }
Exemple #8
0
        public void OnClick_Install()
        {
            // Get the cached mission details
            string      json       = File.ReadAllText(CachePath.GetMissionDetailsFilePath(missionData.missionID));
            MissionData localData  = JsonUtility.FromJson <MissionData>(json);
            string      sdkVersion = CachePath.GetSDKVersion(localData);

            // Do not allow installation if mission files already exist
            foreach (string fileName in localData.fileNames)
            {
                string filePath = Path.Combine(UserPrefs.gameDirectory, fileName);

                if (File.Exists(filePath))
                {
                    InfoDialog.Create("Installation Failed", "The file '" + fileName + "' already exists in your game directory. Please remove it to continue.");
                    return;
                }
            }

            List <string> installedFiles = new List <string>();

            // Need to export plugin for standard mission OPM file
            if (m_IsStandardMission)
            {
                string opmFileName = localData.fileNames.FirstOrDefault((string fileName) => Path.GetExtension(fileName).ToLowerInvariant().Contains("opm"));
                string opmFilePath = Path.Combine(CachePath.GetMissionDirectory(localData.missionID), opmFileName);

                string pluginFileName = Path.ChangeExtension(opmFileName, ".dll");
                string pluginPath     = Path.Combine(UserPrefs.gameDirectory, pluginFileName);

                // Don't allow install if the plugin will overwrite another DLL of the same name
                if (File.Exists(pluginPath))
                {
                    InfoDialog.Create("Install Failed", "There is already a plugin named " + pluginFileName);
                    return;
                }

                // Export plugin
                MissionRoot root = MissionReader.GetMissionData(opmFilePath);
                PluginExporter.ExportPlugin(pluginPath, root.sdkVersion, root.levelDetails);

                FileReference.AddReference(pluginFileName);

                installedFiles.Add(pluginFileName);
            }

            // Install mission from cache into game folder
            foreach (string fileName in localData.fileNames)
            {
                string filePath = Path.Combine(CachePath.GetMissionDirectory(localData.missionID), fileName);

                InstallFile(fileName, filePath);

                installedFiles.Add(fileName);
            }

            // Install SDK
            if (!string.IsNullOrEmpty(sdkVersion))
            {
                InstallFile(CachePath.GetSDKFileName(sdkVersion), CachePath.GetSDKFilePath(sdkVersion));
                InstallFile(CachePath.DotNetInteropFileName, CachePath.GetInteropFilePath(), true);

                installedFiles.Add(CachePath.GetSDKFileName(sdkVersion));
                installedFiles.Add(CachePath.DotNetInteropFileName);
            }

            // Write installed files to cache
            using (FileStream fs = new FileStream(CachePath.GetMissionInstalledMetaFilePath(localData.missionID), FileMode.Create, FileAccess.Write, FileShare.Read))
                using (StreamWriter writer = new StreamWriter(fs))
                {
                    foreach (string fileName in installedFiles)
                    {
                        writer.WriteLine(fileName);
                    }
                }

            // Set buttons
            m_BtnInstall.gameObject.SetActive(false);
            m_BtnUninstall.gameObject.SetActive(true);
            m_BtnDelete.interactable = false;
        }
 // Use this for initialization
 void Start()
 {
     secondaryCameraObject = GameObject.FindGameObjectWithTag("SecondaryCamera").GetComponent<SecondaryCamera>();
     NarrativeAnchorObject = GameObject.FindGameObjectWithTag("NarrativeAnchor");
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
     //gridMask = LayerMask.NameToLayer("Grid");
     //astarMask = LayerMask.NameToLayer("AStar");
     playerTurn = true;
     mReaderObject = GameObject.FindGameObjectWithTag("Grid").GetComponent<MissionReader>();
     soundObject = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<SoundManager>();
 }
 //End of AI
 // Use this for initialization if we need it
 void Start()
 {
     gameManageObject = GameObject.FindGameObjectWithTag("GameController").GetComponent<gameManage>();
     soundObject = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<SoundManager>();
     missionReaderObject = GameObject.Find("A*").GetComponent<MissionReader>();
 }
 // Use this for initialization
 void Start()
 {
     mainCameraObj = GameObject.FindGameObjectWithTag("MainCamera");
     buttonText = GameObject.Find("DialogueLabel").GetComponent<UILabel>();
     narrativeAnchor = GameObject.FindGameObjectWithTag("NarrativeAnchor");
     narrativeDialogue = GameObject.FindGameObjectWithTag("NarrativeDialogue").GetComponent<UILabel>();
     mReaderObject = GameObject.Find("A*").GetComponent<MissionReader>();
     gameManageObject = GameObject.FindGameObjectWithTag("GameController").GetComponent<gameManage>();
     storeDataObject = GameObject.Find("SaveData").GetComponent<StoreData>();
     readDialogueFile();
     gameManageObject.narrativePanelOpen = true;
     if(Application.loadedLevelName == "Tutorial")
     {
         readSection(1);
     }
 }