示例#1
0
 public void solution_file_is_generated_correctly()
 {
     SlnFile.ReadString().ShouldBe("\r\nMicrosoft Visual Studio Solution File, Format Version 11.00\r\n" +
                                   "# Visual Studio 2010\r\n" +
                                   string.Format("Project(\"{{{0}}}\") = \"{1}\", \"{2}\", \"{{{3}}}\"\r\n",
                                                 ProjectConstants.GuidFromType("csharp").ToString().ToUpper(),
                                                 _projectFile.NameWithoutExtension,
                                                 _projectFile.Path.MakeRelative(SlnFile.Parent.Path),
                                                 _projectGuid.ToString().ToUpper()) +
                                   "EndProject\r\n");
 }
示例#2
0
    public void SetTopScoreTexts()
    {
        // Load all scores to a string, example of what it could look like:
        // Name1:200|Name2:100|Name3:1000|
        string _allScores = PlayerPrefs.GetString("Scores");

        // Temprorary variables
        string _nameAndScore = "";
        string _name         = "";
        int    _score        = 0;

        Dictionary <string, int> _namesAndScores = new Dictionary <string, int>();

        // Separate names and scores from the all scores string and add them to a dictionary
        for (int i = 0; i < _allScores.Length; ++i)
        {
            if (_allScores[i] != '|')
            {
                _nameAndScore += _allScores[i];
            }
            else
            {
                string[] _splitStrings = _nameAndScore.Split(')');
                _nameAndScore = "";

                _name  = _splitStrings[0];
                _score = Convert.ToInt32(_splitStrings[1]);

                _namesAndScores.Add(_name, _score);
            }
        }

        // Sort the dictionary by score from highest to lowest
        _namesAndScores = _namesAndScores.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        // Set the top score texts
        for (int i = 1; i < TopScores.transform.childCount; ++i)
        {
            if (i <= _namesAndScores.Count)
            {
                _name  = _namesAndScores.Keys.ElementAt(i - 1).Split('(')[0]; // Split in order to remove ID from the name
                _score = _namesAndScores.Values.ElementAt(i - 1);
                TopScores.transform.GetChild(i).GetComponent <Text>().text = ProjectConstants.AddOrdinal(i) + ": " + _name + " | " + _score;
            }
            else
            {
                TopScores.transform.GetChild(i).GetComponent <Text>().text = "";
            }
        }
    }
示例#3
0
    private void spawnEnemies(int amount)
    {
        for (int i = 0; i < amount; ++i)
        {
            // Get a random sector (excluding the middle sector that the player spawns in) to spawn the enemy in
            int _randomSectorIndex = Random.Range(0, Level.childCount);
            if (_randomSectorIndex == Mathf.CeilToInt(GameManager.Instance.Level.childCount / 2.0f) - 1)
            {
                ++_randomSectorIndex;
            }
            Transform _sectorToSpawnIn = Level.GetChild(_randomSectorIndex);
            Transform _enemy           = spawnShip(EnemyPrefab, _sectorToSpawnIn.position, _sectorToSpawnIn).transform;

            // Get a random position near the center of the sector and set that as the enemy's position
            _enemy.position = ProjectConstants.PickRandomPositionNearby(_sectorToSpawnIn.position, 0.0f, ProjectConstants.SECTOR_WIDTH / 3);
        }
    }
示例#4
0
    void Update()
    {
        // Move the enemy towards its current target position and pick a new target when reaching it
        transform.localPosition = Vector2.MoveTowards(transform.localPosition, m_targetPosition, MovementSpeed * Time.deltaTime);
        if (transform.localPosition == m_targetPosition)
        {
            m_targetPosition = ProjectConstants.PickRandomPositionNearby(transform.localPosition, m_minRoamingDistance, m_maxRoamingDistance);
        }

        // Get the sector the enemy is currently in and adjust the enemy's position and target according to it if needed
        m_currentSector = getCurrentSector();

        // Shoot at the player when close enough
        if (GameManager.Instance.PlayerShip != null && Mathf.Abs(GameManager.Instance.PlayerShip.position.x - transform.position.x) <= ShootingRange)
        {
            shoot(transform.position, (GameManager.Instance.PlayerShip.position - transform.position).normalized, ProjectileSpeed, transform.parent);
        }
    }
示例#5
0
 public override void Initialize()
 {
     // Get the sector the enemy is currently in and get a random position for the enemy to roam to
     m_currentSector  = getCurrentSector();
     m_targetPosition = ProjectConstants.PickRandomPositionNearby(transform.localPosition, m_minRoamingDistance, m_maxRoamingDistance);
 }
示例#6
0
 public void AddScoreToLeaderBoard(string leaderboardId, int credit)
 {
     Social.ReportScore(credit, leaderboardId, success => { ProjectConstants.UpdateUserCredit(credit); });
 }
示例#7
0
 public static void LoseGame()
 {
     ProjectConstants.UpdateUserCredit(-matchCost);
 }
示例#8
0
 public static void WinGame()
 {
     ProjectConstants.UpdateUserCredit(matchCost);
 }
示例#9
0
        public Form1()
        {
            cleanup();

            InitializeComponent();

            string workingDirectory       = MainGUI.Properties.Settings.Default.WorkingDirectory;
            string wiimoteApplicationPath = MainGUI.Properties.Settings.Default.WiimoteApplicationPath;
            string matlabApplicationPath  = MainGUI.Properties.Settings.Default.MatlapApplicationPath;
            string mediaDirectory         = MainGUI.Properties.Settings.Default.MediaDirectory;

            ProjectConstants.initialize(workingDirectory, wiimoteApplicationPath, matlabApplicationPath, mediaDirectory);
            Environment.CurrentDirectory         = ProjectConstants.PROJECT_PATH;
            this.openVideoDialog                 = new System.Windows.Forms.OpenFileDialog();
            this.openMP3FileDialog               = new System.Windows.Forms.OpenFileDialog();
            this.openWiimoteSimulationFileDialog = new System.Windows.Forms.OpenFileDialog();
            // openVideoDialog
            //
            this.openVideoDialog.DefaultExt = "avi";
            this.openVideoDialog.FileName   = "kangaroo.avi";
            this.openVideoDialog.Filter     = "movie files|*.avi||";
            this.openVideoDialog.Title      = "Choose a movie to play";


            // openMP3Dialog
            //
            this.openMP3FileDialog.DefaultExt = "mpw";
            this.openMP3FileDialog.Filter     = "mp3 files|*.mp3||";
            this.openMP3FileDialog.Title      = "Choose a mp3 file to play";

            // openWiimoteSimulationDialog
            //
            this.openWiimoteSimulationFileDialog.DefaultExt = "csv";
            this.openWiimoteSimulationFileDialog.Filter     = "csv files|*.csv||";
            this.openWiimoteSimulationFileDialog.Title      = "Choose a wiimote data file for simulation";


            //open Wiimote Dialog
            this.openWiimoteDataDialog            = new System.Windows.Forms.OpenFileDialog();
            this.openWiimoteDataDialog.DefaultExt = "csv";
            this.openWiimoteDataDialog.Filter     = "csv files|*.csv||";
            this.openWiimoteDataDialog.Title      = "Choose Wiimote Data File to upload";


            this.saveFileDialog             = new System.Windows.Forms.SaveFileDialog();
            this.saveFileDialog.DefaultExt  = "csv";
            this.saveFileDialog.Filter      = "csv files|*.csv||";
            saveFileDialog.InitialDirectory = ProjectConstants.WIIMOTE_REFERENCE_DATA_PATH;

            this.wiimoteDisconnect.Enabled = false;

            Configuration config = Configuration.getConfiguration();

            config.initialize();
            this.configurationBindingSource.DataSource = config;

            WiimoteDataStore.getWiimoteDataStore().initialize();

            Wiimotes l_Wiimotes = Wiimotes.getWiimotesObject();

            m_WiimoteRecordingHandler = new WiimoteRecordingHandler(l_Wiimotes, this);
            m_WiimoteRecordingHandler.Initialize();

            m_WiimoteCalibrationHandler = new WiimoteCalibrationHandler(l_Wiimotes, this);
            m_WiimoteCalibrationHandler.Initialize();

            this.trainingSegmentInfoBindingSource.DataSource = WiimoteDataStore.getWiimoteDataStore().TrainingSegmentInfoRecords;

            InitializeBluetoothSetupTab();

            initializeTraining(l_Wiimotes);

            applicationStartSpeech();

            InitializeMogreComponent();


            mSpeechRecognition = SpeechRecognition.getSpeechRecognition();
            mSpeechRecognition.VoiceCommandReceivedEvent += new SpeechRecognition.OnVoiceCommandReceivedEvent(OnVoiceCommandReceivedEvent);
            setButtonVoiceCommandOff(false);

            this.quartenionViewerControl.SetWiimotes(l_Wiimotes);

            //OSCCommunication oscCommunication = new OSCCommunication();
            //oscCommunication.Initialize(l_Wiimotes);

/*
 *          try
 *          {
 *              m_OgreControl = new OgreControl(this.ogrePanel.Handle);
 *              m_OgreControl.Init();
 *
 *          }
 *          catch (MogreWrapperException e)
 *          {
 *              MessageBox.Show(e.Message,
 *                       "An Ogre exception has occurred!");
 *          }
 *
 *          Disposed += new EventHandler(Form1_Disposed);
 *          Resize += new EventHandler(Form1_Resize);
 *          Paint += new PaintEventHandler(Form1_Paint);
 */
        }
示例#10
0
 private static int ReturnIndex(string name)
 {
     return(ProjectConstants.ReturnElementIndex(name));
 }
示例#11
0
 private static void HandleVideoReward(object sender, Reward reward)
 {
     UnityEngine.Debug.Log("Reward received: " + reward.Type + " " + reward.Amount
                           + " from" + sender.ToString());
     ProjectConstants.UpdateUserCredit((int)reward.Amount);
 }