Exemplo n.º 1
0
    public void Start()
    {
        GameObject t = new GameObject();

        _Temp = t.transform;
        MainCameraTransfom = Camera.main.transform;

        Buttons = new Button[] {
            new Button(Game.Instance.ButtonXPositon + new Vector2(GuiButtonX.Instance.ScreenWidth * 0.5f, GuiButtonX.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonOPositon + new Vector2(GuiButtonY.Instance.ScreenWidth * 0.5f, GuiButtonY.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonRPositon + new Vector2(GuiButtonRoll.Instance.ScreenWidth * 0.5f, GuiButtonRoll.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonOPositon + new Vector2(GuiButtonUse.Instance.ScreenWidth * 0.5f, GuiButtonUse.Instance.ScreenHeight * 0.5f)),
            new Button(GuiButtonShop.Instance.Center),
            new Button(GuiButtonInGameMenu.Instance.Center),
            new Button(GuiShopButtonOk.Instance.ScreenLeft, GuiShopButtonOk.Instance.ScreenBottom - GuiShopButtonOk.Instance.ScreenHeight, GuiShopButtonOk.Instance.ScreenWidth, GuiShopButtonOk.Instance.ScreenHeight * 2),
            new Button(GuiShopButtonBack.Instance.ScreenLeft, GuiShopButtonBack.Instance.ScreenBottom - GuiShopButtonBack.Instance.ScreenHeight, GuiShopButtonBack.Instance.ScreenWidth, GuiShopButtonBack.Instance.ScreenHeight * 2),
            new Button(GuiShopComboButtons.BScreenLeft(0), GuiShopComboButtons.BScreenBottom(0), GuiShopComboButtons.BScreenWidth(0), GuiShopComboButtons.BScreenHeight(0)),
            new Button(GuiShopComboButtons.BScreenLeft(1), GuiShopComboButtons.BScreenBottom(1), GuiShopComboButtons.BScreenWidth(1), GuiShopComboButtons.BScreenHeight(1)),
            new Button(GuiShopComboButtons.BScreenLeft(2), GuiShopComboButtons.BScreenBottom(2), GuiShopComboButtons.BScreenWidth(2), GuiShopComboButtons.BScreenHeight(2)),
            new Button(GuiShopComboButtons.BScreenLeft(3), GuiShopComboButtons.BScreenBottom(3), GuiShopComboButtons.BScreenWidth(3), GuiShopComboButtons.BScreenHeight(3)),
            new Button(GuiShopComboButtons.BScreenLeft(4), GuiShopComboButtons.BScreenBottom(4), GuiShopComboButtons.BScreenWidth(4), GuiShopComboButtons.BScreenHeight(4)),
            new Button(GuiShopComboButtons.BScreenLeft(5), GuiShopComboButtons.BScreenBottom(5), GuiShopComboButtons.BScreenWidth(5), GuiShopComboButtons.BScreenHeight(5)),
            new Button(GuiShopComboButtons.BScreenLeft(6), GuiShopComboButtons.BScreenBottom(6), GuiShopComboButtons.BScreenWidth(6), GuiShopComboButtons.BScreenHeight(6)),
            new Button(GuiShopComboButtons.BScreenLeft(7), GuiShopComboButtons.BScreenBottom(7), GuiShopComboButtons.BScreenWidth(7), GuiShopComboButtons.BScreenHeight(7)),
            new Button(GuiShopBuyInfo.OkScreenLeft, GuiShopBuyInfo.OkScreenBottom - GuiShopBuyInfo.OkScreenHeight, GuiShopBuyInfo.OkScreenWidth, GuiShopBuyInfo.OkScreenHeight * 2),
            new Button(GuiShopBuyInfo.CancelScreenLeft, GuiShopBuyInfo.CancelScreenBottom - GuiShopBuyInfo.CancelScreenHeight, GuiShopBuyInfo.CancelScreenWidth, GuiShopBuyInfo.CancelScreenHeight * 2),
        };

        Joystick = new JoystickControl(Game.Instance.JoystickPositon + new Vector2(GuiJoystick.Instance.ScreenWidth * 0.5f, GuiJoystick.Instance.ScreenHeight * 0.5f));
    }
Exemplo n.º 2
0
        public void GameControllerReady(GameController gameController, IInputManager inputManager)
        {
            // This is called twice on a host - once when the client game
            // starts and once when the server game starts.
            if (pInputManager != null)
            {
                return;
            }

            if (eTeam != -1)
            {
                GetComponent <SpriteOverlay>().SetColor(TeamColor.FromIndex(eTeam));
            }

            pInputManager = inputManager;
            pJoystick     = new JoystickControl(inputManager);

            if (isLocalPlayer)
            {
                var leftButton = GameObject.Find("LeftButton");
                if (leftButton != null)
                {
                    pTouchButtons = leftButton.GetComponent <TouchButtons>();
                }
            }

            if (lRb != null)
            {
                Initialize();
                lInitialized = true;
            }
        }
Exemplo n.º 3
0
        private void GameListComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var modifyItem = (ComboBoxItem)((ComboBox)sender).SelectedItem;
            var profile    = (GameProfile)((ComboBoxItem)((ComboBox)sender).SelectedItem).Tag;
            var icon       = profile.IconName;
            Uri imageUri;

            if (File.Exists(icon))
            {
                imageUri = new Uri(icon, UriKind.Relative);
            }
            else
            {
                imageUri = new Uri("Resources/teknoparrot_by_pooterman-db9erxd.png", UriKind.Relative);
            }
            BitmapImage imageBitmap = new BitmapImage(imageUri);

            MainLogo.Source = imageBitmap;
            GameSettingsControl.LoadNewSettings(profile, modifyItem);
            JoystickControl.LoadNewSettings(profile, modifyItem, _parrotData);
            if (!profile.HasSeparateTestMode)
            {
                ChkTestMenu.IsChecked = false;
                ChkTestMenu.IsEnabled = false;
            }
            else
            {
                ChkTestMenu.IsEnabled = true;
                ChkTestMenu.ToolTip   = "Enable or disable test mode.";
            }
        }
Exemplo n.º 4
0
    public void Update()
    {
        try
        {
            if (exitOnMenuOpen.val && SuperController.singleton.mainHUD.gameObject.activeSelf)
            {
                context.embody.Deactivate();
                return;
            }

            const float yawSpeed   = 40f;
            const float pitchSpeed = 32f;
            _rigRotationOffsetSource += new Vector3(
                JoystickControl.GetAxis(SuperController.singleton.navigationUpAxis) * pitchSpeed,
                JoystickControl.GetAxis(SuperController.singleton.navigationTurnAxis) * yawSpeed,
                0f) * Time.unscaledDeltaTime;
            _rigRotationOffset = Quaternion.identity * Quaternion.Euler(_rigRotationOffsetSource);

            UpdateNavigationRig(false);
        }
        catch (Exception e)
        {
            SuperController.LogError($"Embody: Failed to apply Passenger.\n{e}");
            enabled = false;
        }
    }
Exemplo n.º 5
0
        public Joystick()
        {
            InitializeComponent();
            this.jcc = JoystickControl.Instance;
            Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown;
            Knob.MouseLeftButtonUp   += Knob_MouseLeftButtonUp;
            Knob.MouseMove           += Knob_MouseMove;

            centerKnob = Knob.Resources["CenterKnob"] as Storyboard;
        }
Exemplo n.º 6
0
 /// <summary>
 /// This button opens the controller settings option
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnControllerSettings(object sender, RoutedEventArgs e)
 {
     if (gameList.Items.Count == 0)
     {
         return;
     }
     Joystick = new JoystickControl(_contentControl, this);
     Joystick.LoadNewSettings(_gameNames[gameList.SelectedIndex], (ListBoxItem)gameList.SelectedItem);
     Joystick.Listen();
     Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = Joystick;
 }
Exemplo n.º 7
0
 private void FlyoutSettings_OnIsOpenChanged(object sender, RoutedEventArgs e)
 {
     if (FlyoutSettings.IsOpen)
     {
         JoystickControl.Listen();
     }
     else
     {
         JoystickControl.StopListening();
     }
 }
Exemplo n.º 8
0
 public void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     joystickLeft     = GameObject.Find("VirtualJoystickLeft").GetComponent <JoystickControl>();
     joystickRight    = GameObject.Find("VirtualJoystickRight").GetComponent <JoystickControl>();
     head             = transform.Find("Head");
     gyroControl      = this.GetComponent <GyroscopeController>();
     toggleFVR        = GameObject.Find("ToggleFVR").GetComponent <Toggle>();
     cam      = GameObject.Find("FOVCamera").GetComponent <Camera>();
     fjButton = GameObject.Find("JumpButton").GetComponent <FlyJumpButton>();
 }
Exemplo n.º 9
0
        public Library(ContentControl contentControl)
        {
            InitializeComponent();
            BitmapImage imageBitmap = new BitmapImage(new Uri(
                                                          "pack://application:,,,/TeknoParrotUi;component/Resources/teknoparrot_by_pooterman-db9erxd.png",
                                                          UriKind.Absolute));

            gameIcon.Source = imageBitmap;

            UpdatePatronText();

            _contentControl = contentControl;
            Joystick        = new JoystickControl(contentControl, this);
        }
Exemplo n.º 10
0
    private void Awake()
    {
        if (joystickObj)
        {
            joystick = joystickObj.GetComponentInChildren <JoystickControl>();
        }
        if (joystick)
        {
            joystick.onRelease = SpawnPlatform;
            joystick.onDrag    = DragEvent;
        }

        pc = GetComponent <PlayerController>();
    }
Exemplo n.º 11
0
    void Start()
    {
        TimeText     = GameObject.Find("Canvas/TimeText").GetComponent <Text>();
        VelocityText = GameObject.Find("Canvas/VelocityText").GetComponent <Text>();
        CarRigidbody = GameObject.Find("FireGTO").GetComponent <Rigidbody>();
        stopLight    = GameObject.Find("FireGTO/GTO_Body/StopLight");

        JoystickControler = GameObject.Find("GameControler").GetComponent <JoystickControl>();

        startTime = DateTime.Now;
        //particleSmoke = GameObject.Find("FireGTO/Particles");
        StartCoroutine("SmokeParticles");
        StartCoroutine(StopLight());
    }
Exemplo n.º 12
0
    void Start()
    {
        m_Rigidbody = GetComponent <Rigidbody>();
        m_Audio     = GetComponent <AudioSource>();
        //设置车的重心,使车更稳定
        Vector3 centerOfMass = m_Rigidbody.centerOfMass;

        centerOfMass.y           = -1.5f;
        m_Rigidbody.centerOfMass = centerOfMass;

        FrontWheelRotation = FrontLeftWheel.transform.rotation;
        BackWheelRotation  = BackLeftWheel.transform.rotation;

        JoystickControler = GameObject.Find("GameControler").GetComponent <JoystickControl>();
    }
Exemplo n.º 13
0
    public void Start()
    {
        GameObject t = new GameObject();

        _Temp = t.transform;
        MainCameraTransfom = Camera.main.transform;
        Debug.Log("player control start (check game instance=" + Game.Instance.name);
        //no game will cause no button
        //if (Buttons != null) {
        Buttons = new Button[] {
            new Button(Game.Instance.ButtonXPositon + new Vector2(GuiButtonX.Instance.ScreenWidth * 0.5f, GuiButtonX.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonOPositon + new Vector2(GuiButtonY.Instance.ScreenWidth * 0.5f, GuiButtonY.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonRPositon + new Vector2(GuiButtonRoll.Instance.ScreenWidth * 0.5f, GuiButtonRoll.Instance.ScreenHeight * 0.5f)),
            new Button(Game.Instance.ButtonOPositon + new Vector2(GuiButtonUse.Instance.ScreenWidth * 0.5f, GuiButtonUse.Instance.ScreenHeight * 0.5f)),
            new Button(GuiButtonShop.Instance.Center),
            new Button(GuiButtonInGameMenu.Instance.Center),
            new Button(GuiShopButtonOk.Instance.ScreenLeft, GuiShopButtonOk.Instance.ScreenBottom - GuiShopButtonOk.Instance.ScreenHeight, GuiShopButtonOk.Instance.ScreenWidth, GuiShopButtonOk.Instance.ScreenHeight * 2),
            new Button(GuiShopButtonBack.Instance.ScreenLeft, GuiShopButtonBack.Instance.ScreenBottom - GuiShopButtonBack.Instance.ScreenHeight, GuiShopButtonBack.Instance.ScreenWidth, GuiShopButtonBack.Instance.ScreenHeight * 2),
            new Button(GuiShopComboButtons.BScreenLeft(0), GuiShopComboButtons.BScreenBottom(0), GuiShopComboButtons.BScreenWidth(0), GuiShopComboButtons.BScreenHeight(0)),
            new Button(GuiShopComboButtons.BScreenLeft(1), GuiShopComboButtons.BScreenBottom(1), GuiShopComboButtons.BScreenWidth(1), GuiShopComboButtons.BScreenHeight(1)),
            new Button(GuiShopComboButtons.BScreenLeft(2), GuiShopComboButtons.BScreenBottom(2), GuiShopComboButtons.BScreenWidth(2), GuiShopComboButtons.BScreenHeight(2)),
            new Button(GuiShopComboButtons.BScreenLeft(3), GuiShopComboButtons.BScreenBottom(3), GuiShopComboButtons.BScreenWidth(3), GuiShopComboButtons.BScreenHeight(3)),
            new Button(GuiShopComboButtons.BScreenLeft(4), GuiShopComboButtons.BScreenBottom(4), GuiShopComboButtons.BScreenWidth(4), GuiShopComboButtons.BScreenHeight(4)),
            new Button(GuiShopComboButtons.BScreenLeft(5), GuiShopComboButtons.BScreenBottom(5), GuiShopComboButtons.BScreenWidth(5), GuiShopComboButtons.BScreenHeight(5)),
            new Button(GuiShopComboButtons.BScreenLeft(6), GuiShopComboButtons.BScreenBottom(6), GuiShopComboButtons.BScreenWidth(6), GuiShopComboButtons.BScreenHeight(6)),
            new Button(GuiShopComboButtons.BScreenLeft(7), GuiShopComboButtons.BScreenBottom(7), GuiShopComboButtons.BScreenWidth(7), GuiShopComboButtons.BScreenHeight(7)),
            new Button(GuiShopBuyInfo.OkScreenLeft, GuiShopBuyInfo.OkScreenBottom - GuiShopBuyInfo.OkScreenHeight, GuiShopBuyInfo.OkScreenWidth, GuiShopBuyInfo.OkScreenHeight * 2),
            new Button(GuiShopBuyInfo.CancelScreenLeft, GuiShopBuyInfo.CancelScreenBottom - GuiShopBuyInfo.CancelScreenHeight, GuiShopBuyInfo.CancelScreenWidth, GuiShopBuyInfo.CancelScreenHeight * 2),
        };
        //}

        if (Game.Instance != null)
        {
            Joystick = new JoystickControl(Game.Instance.JoystickPositon + new Vector2(GuiJoystick.Instance.ScreenWidth * 0.5f, GuiJoystick.Instance.ScreenHeight * 0.5f));
        }
        else
        {
            Joystick = new JoystickControl(new Vector2(100, 100));
        }
    }
Exemplo n.º 14
0
        public Library(ContentControl contentControl)
        {
            InitializeComponent();
            BitmapImage imageBitmap = new BitmapImage(new Uri(
                                                          "pack://*****:*****@"SOFTWARE\TeknoGods\TeknoParrot"))
            {
                var isPatron = key != null && key.GetValue("PatreonSerialKey") != null;

                if (isPatron)
                {
                    textBlockPatron.Text = "Yes";
                }
            }

            _contentControl = contentControl;
            Joystick        = new JoystickControl(contentControl, this);
        }
Exemplo n.º 15
0
    public void Update()
    {
        try
        {
            if (exitOnMenuOpen.val && SuperController.singleton.mainHUD.gameObject.activeSelf)
            {
                context.embody.activeJSON.val = false;
                return;
            }

            var turnAxis = JoystickControl.GetAxis(SuperController.singleton.navigationTurnAxis);
            if (turnAxis != 0)
            {
                _rigRotationOffset *= Quaternion.Euler(0f, turnAxis, 0f);
            }
            UpdateNavigationRig(false);
        }
        catch (Exception e)
        {
            SuperController.LogError($"Embody: Failed to apply Passenger.\n{e}");
            enabled = false;
        }
    }
Exemplo n.º 16
0
        protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
        {
            //if (GameUser.Instance.JumpState)
            //{
            //	transform.position += transform.forward * _positionSpeed * 2;
            //	GameUser.Instance.IsJump = false;
            //}

            if (_playerData.JumpState > 0)
            {
                transform.position += transform.forward * Time.deltaTime * (_playerData.JumpDistance / _playerData.JumpAnimationTime);
                var ySpeed = (_maxY / _playerData.JumpAnimationTime) * 2;
                if (_playerData.JumpState == 1)
                {
                    _currY += Time.deltaTime * ySpeed;
                    if (_currY > _maxY)
                    {
                        _playerData.JumpState = 2;
                    }
                }
                else
                {
                    _currY -= Time.deltaTime * ySpeed;
                    if (_currY < 0.0f)
                    {
                        _playerData.JumpState = 0;
                        _currY = 0.0f;
                    }
                }

                Vector3 pos = transform.position;
                pos.y = _currY;
                transform.position = pos;
            }

            if (_isSelf)
            {
                if (_playerData.JumpState == 0)
                {
                    var eulerAngles = JoystickControl.GetDestination();
                    if (eulerAngles != new Vector3())
                    {
                        Vector3    destDirection = new Vector3(eulerAngles.x, 0, eulerAngles.y);
                        Quaternion quaternion    = Quaternion.LookRotation(destDirection);
                        transform.rotation = quaternion;

                        var tmpPosition = transform.position + transform.forward * Time.deltaTime * _positionSpeed;
                        tmpPosition.x      = limitSize(tmpPosition.x);
                        tmpPosition.z      = limitSize(tmpPosition.z);
                        transform.position = tmpPosition;
                        AddTransformCommand();
                    }
                }
                var position = new Vector3(transform.position.x, 0, transform.position.z) + _offset;
                Camera.main.transform.position = position;
            }
            else
            {
                var destDirection = _playerData.Rotate;
                if (Vector3.Distance(transform.eulerAngles, _playerData.Rotate) > 0.0004f)
                {
                    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(destDirection), _rotateSpeed * Time.deltaTime);
                }

                float distance   = 0.0f;
                float deltaSpeed = (_positionSpeed * Time.deltaTime);

                var destPosition = _playerData.Position;
                distance = Vector3.Distance(destPosition, transform.position);

                if (distance > 0.01f)
                {
                    Vector3 pos = transform.position;

                    Vector3 movement = destPosition - pos;
                    movement.y = 0f;
                    movement.Normalize();

                    movement *= deltaSpeed;

                    if (distance > deltaSpeed || movement.magnitude > deltaSpeed)
                    {
                        pos += movement;
                    }
                    else
                    {
                        pos = destPosition;
                    }

                    transform.position = pos;
                }
            }
            FixedState();
            base.OnUpdate(elapseSeconds, realElapseSeconds);
        }
Exemplo n.º 17
0
 private void MainWindow_OnClosing(object sender, CancelEventArgs e)
 {
     JoystickControl.StopListening();
     SafeExit();
 }
Exemplo n.º 18
0
        /// <summary>
        /// Creates the trial from the row/column data contained in the csvreader
        /// </summary>
        /// <param name="csvReader">The csvreader containing the row and column data</param>
        /// <param name="row">The row number of the data to use for this trial</param>
        internal Trial(CsvReader csvReader, int row)
        {
            logger.Debug("Create: Trial(CsvReader, int)");

            status = Status.Initializing;

            directionOfBalance       = new RotationAngles();
            movingDirectionOfBalance = new RotationAngles();
            visualOrientationOffset  = new RotationAngles();

            beginAtPoint = new RotationAngles();

            reminderGiven = false;

            trialNumber              = csvReader.getValueAsInt("TrialNumber", row);
            condition                = csvReader.getValueAsString("Condition", row);
            directionOfBalance.roll  = csvReader.getValueAsDouble("DOBRoll", row);
            directionOfBalance.pitch = csvReader.getValueAsDouble("DOBPitch", row);
            directionOfBalance.yaw   = csvReader.getValueAsDouble("DOBYaw", row);
            accelerationConstant     = csvReader.getValueAsDouble("AccelConstant", row);
            maxAcceleration          = csvReader.getValueAsDouble("MaxAcceleration", row);
            maxVelocity              = csvReader.getValueAsDouble("MaxVelocity", row);
            maxAngle            = csvReader.getValueAsDouble("MaxAngle", row);
            maxAcceleration     = csvReader.getValueAsDouble("MaxAcceleration", row);
            restartWhenMaxAngle = csvReader.getValueAsBool("RestartWhenMaxAngle", row);
            timeLimit           = csvReader.getValueAsDouble("TimeLimit", row);
            joystickGain        = csvReader.getValueAsDouble("JoystickGain", row);

            restartDOBOffsetMaxYaw   = csvReader.getValueAsDouble("RestartDOBOffsetMaxYaw", row);
            restartDOBOffsetMinYaw   = csvReader.getValueAsDouble("RestartDOBOffsetMinYaw", row);
            restartDOBOffsetMaxPitch = csvReader.getValueAsDouble("RestartDOBOffsetMaxPitch", row);
            restartDOBOffsetMinPitch = csvReader.getValueAsDouble("RestartDOBOffsetMinPitch", row);
            restartDOBOffsetMaxRoll  = csvReader.getValueAsDouble("RestartDOBOffsetMaxRoll", row);
            restartDOBOffsetMinRoll  = csvReader.getValueAsDouble("RestartDOBOffsetMinRoll", row);

            string val = csvReader.getValueAsString("JoystickControl", row);

            if (val.ToUpper() == "MIRROR")
            {
                joystickControl = JoystickControl.Mirrored;
            }
            else if (val.ToUpper() == "CW")
            {
                joystickControl = JoystickControl.Clockwise;
            }
            else if (val.ToUpper() == "CCW")
            {
                joystickControl = JoystickControl.Counterclockwise;
            }
            else
            {
                joystickControl = JoystickControl.Normal;
            }

            noiseProfile   = csvReader.getValueAsString("NoiseProfile", row);
            noiseAmplitude = csvReader.getValueAsDouble("NoiseAmplitude", row);
            useRoll        = csvReader.getValueAsBool("UseRoll", row);
            usePitch       = csvReader.getValueAsBool("UsePitch", row);
            useYaw         = csvReader.getValueAsBool("UseYaw", row);

            joystickIndicationsMandatory = csvReader.getValueAsBool("JoystickIndicationsMandatory", row);

            bool useBeginPoint = false;

            if (csvReader.hasValueAsDouble("BeginAtPitch", row) &&
                csvReader.hasValueAsDouble("BeginAtYaw", row) &&
                csvReader.hasValueAsDouble("BeginAtRoll", row))
            {
                beginAtPoint.yaw   = csvReader.getValueAsDouble("BeginAtYaw", row);
                beginAtPoint.pitch = csvReader.getValueAsDouble("BeginAtPitch", row);
                beginAtPoint.roll  = csvReader.getValueAsDouble("BeginAtRoll", row);
                useBeginPoint      = true;
            }

            if (!useBeginPoint)
            {
                beginAtPoint = null;
            }

            visualOrientationOffset.yaw   = csvReader.getValueAsDouble("VisualYawOffset", row);
            visualOrientationOffset.pitch = csvReader.getValueAsDouble("VisualPitchOffset", row);
            visualOrientationOffset.roll  = csvReader.getValueAsDouble("VisualRollOffset", row);

            moveSound       = csvReader.getValueAsString("MoveSound", row);
            startSound      = csvReader.getValueAsString("TrialStartSound", row);
            endSound        = csvReader.getValueAsString("TrialEndSound", row);
            resetStartSound = csvReader.getValueAsString("ResetStartSound", row);
            resetEndSound   = csvReader.getValueAsString("ResetEndSound", row);
            reminderSound   = csvReader.getValueAsString("ReminderSound", row);

            // sanity check
            if (restartDOBOffsetMaxYaw > maxAngle)
            {
                throw new Exception("Error when reading row " + (row + 1) + " from file " + csvReader.FileName + "\r\n" + "Reason: the maximum DOB yaw offset when restarting (column: RestartDOBOffsetMaxYaw) is larger than the maximum angle (column: MaxAngle)");
            }
            if (restartDOBOffsetMaxPitch > maxAngle)
            {
                throw new Exception("Error when reading row " + (row + 1) + " from file " + csvReader.FileName + "\r\n" + "Reason: the maximum DOB pitch offset when restarting (column: RestartDOBOffsetMaxPitch) is larger than the maximum angle (column: MaxAngle)");
            }
            if (restartDOBOffsetMaxRoll > maxAngle)
            {
                throw new Exception("Error when reading row " + (row + 1) + " from file " + csvReader.FileName + "\r\n" + "Reason: the maximum DOB roll offset when restarting (column: RestartDOBOffsetMaxRoll) is larger than the maximum angle (column: MaxAngle)");
            }

//            SetNoiseProfile();
            SetSoundPlayers();
        }
Exemplo n.º 19
0
        public Boolean generateImageFilesWithRatio(float XRatio, float YRatio)
        {
            if (this.Project == null)
            {
                return(false);
            }
            if (this.Project.ImageSuffix == null)
            {
                return(false);
            }

            float moyenneRatio = (XRatio + YRatio) / 2;

            try
            {
                for (int i = 0; i < this.Project.Scenes.Count; i++)
                {
                    if (this.Project.Scenes[i].isEnabled == true)
                    {
                        for (int j = 0; j < this.Project.Scenes[i].Layers.Count; j++)
                        {
                            if (this.Project.Scenes[i].Layers[j].isEnabled == true)
                            {
                                for (int k = 0; k < this.Project.Scenes[i].Layers[j].CoronaObjects.Count; k++)
                                {
                                    CoronaObject coronaObject = this.Project.Scenes[i].Layers[j].CoronaObjects[k];
                                    if (coronaObject.isEnabled == true)
                                    {
                                        if (coronaObject.isEntity == false)
                                        {
                                            DisplayObject obj = coronaObject.DisplayObject;
                                            if (obj.Type.Equals("IMAGE"))
                                            {
                                                if (obj.GorgonSprite != null)
                                                {
                                                    string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                    obj.OriginalAssetName + ".png");

                                                    Size   finalSize      = new Size(Convert.ToInt32(obj.SurfaceRect.Size.Width * XRatio), Convert.ToInt32(obj.SurfaceRect.Size.Height * YRatio));
                                                    string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + finalSize.Width + "x" + finalSize.Height;
                                                    if (File.Exists(imagePath))
                                                    {
                                                        if (!File.Exists(finalImageName + ".png"))
                                                        {
                                                            Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                            //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                            Image finalImage = new Bitmap(originalImage, finalSize);
                                                            finalImage.Save(finalImageName + ".png",
                                                                            System.Drawing.Imaging.ImageFormat.Png);
                                                            finalImage.Dispose();
                                                            finalImage = null;

                                                            originalImage.Dispose();
                                                            originalImage = null;
                                                        }
                                                    }
                                                }
                                            }

                                            if (coronaObject.BitmapMask != null)
                                            {
                                                if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                {
                                                    Image finalImage = new Bitmap(coronaObject.BitmapMask.MaskImage,
                                                                                  new Size(Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Width * moyenneRatio),
                                                                                           Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Height * moyenneRatio)));
                                                    finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                    finalImage.Dispose();
                                                    finalImage = null;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < coronaObject.Entity.CoronaObjects.Count; e++)
                                            {
                                                CoronaObject child = coronaObject.Entity.CoronaObjects[e];
                                                if (child.isEnabled == true)
                                                {
                                                    DisplayObject obj = child.DisplayObject;
                                                    if (obj.Type.Equals("IMAGE"))
                                                    {
                                                        if (obj.GorgonSprite != null)
                                                        {
                                                            string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                            obj.OriginalAssetName + ".png");

                                                            Size   finalSize      = new Size(Convert.ToInt32(obj.SurfaceRect.Size.Width * XRatio), Convert.ToInt32(obj.SurfaceRect.Size.Height * YRatio));
                                                            string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + finalSize.Width + "x" + finalSize.Height;
                                                            if (File.Exists(imagePath))
                                                            {
                                                                if (!File.Exists(finalImageName + ".png"))
                                                                {
                                                                    Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                    //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                                    Image finalImage = new Bitmap(originalImage, finalSize);
                                                                    finalImage.Save(finalImageName + ".png",
                                                                                    System.Drawing.Imaging.ImageFormat.Png);
                                                                    finalImage.Dispose();
                                                                    finalImage = null;
                                                                    originalImage.Dispose();
                                                                    originalImage = null;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    if (coronaObject.BitmapMask != null)
                                                    {
                                                        if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                        {
                                                            Image finalImage = new Bitmap(coronaObject.BitmapMask.MaskImage,
                                                                                          new Size(Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Width * moyenneRatio),
                                                                                                   Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Height * moyenneRatio)));
                                                            finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);

                                                            finalImage.Dispose();
                                                            finalImage = null;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            Scene scene = this.Project.Scenes[i];


                            //scene.createAllSpriteSheetsImages("", moyenneRatio, moyenneRatio);

                            for (int l = 0; l < scene.SpriteSheets.Count; l++)
                            {
                                CoronaSpriteSheet sheet = scene.SpriteSheets[l];


                                //if (size.Width >= 4096 || size.Height >= 4096)
                                //{
                                //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //}

                                //Creer le fichier lua associé
                                SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), "", moyenneRatio, moyenneRatio);
                            }


                            for (int l = 0; l < scene.Layers.Count; l++)
                            {
                                CoronaLayer layer = scene.Layers[l];
                                if (layer.isEnabled == true)
                                {
                                    if (layer.TilesMap != null)
                                    {
                                        if (layer.TilesMap.isEnabled == true)
                                        {
                                            string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                            string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                            string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                            string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";

                                            float orientedXRatio = 0;
                                            float orientedYRatio = 0;
                                            if (this.Project.Orientation == CoronaGameProject.OrientationScreen.Portrait)
                                            {
                                                orientedXRatio = XRatio;
                                                orientedYRatio = YRatio;
                                            }
                                            else
                                            {
                                                orientedXRatio = YRatio;
                                                orientedYRatio = XRatio;
                                            }

                                            layer.TilesMap.refreshTilesMapContent();
                                            layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, "", orientedXRatio, orientedYRatio);


                                            string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, orientedXRatio, orientedYRatio);
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Controls.Count; k++)
                            {
                                CoronaControl control = this.Project.Scenes[i].Layers[j].Controls[k];
                                if (control.isEnabled == true)
                                {
                                    if (control.Type == CoronaControl.ControlType.joystick)
                                    {
                                        JoystickControl joy = control as JoystickControl;

                                        //Pour l'image OUTER
                                        if (joy.outerImage != null)
                                        {
                                            //Enregistrer l'image en size *ratio
                                            Size   sizeBack   = new Size(Convert.ToInt32(joy.outerRadius * 2 * XRatio), Convert.ToInt32(joy.outerRadius * 2 * moyenneRatio));
                                            Bitmap OuterImage = new Bitmap(joy.outerImage, sizeBack);
                                            OuterImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer.png", System.Drawing.Imaging.ImageFormat.Png);
                                            OuterImage.Dispose();
                                        }

                                        //Pour l'image Inner
                                        if (joy.innerImage != null)
                                        {
                                            //Enregistrer l'image en size *ratio
                                            Size   sizeBack   = new Size(Convert.ToInt32(joy.innerRadius * 2 * moyenneRatio), Convert.ToInt32(joy.innerRadius * 2 * moyenneRatio));
                                            Bitmap InnerImage = new Bitmap(joy.innerImage, sizeBack);
                                            InnerImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner.png", System.Drawing.Imaging.ImageFormat.Png);
                                            InnerImage.Dispose();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 20
0
 private void BtnQuit(object sender, RoutedEventArgs e)
 {
     JoystickControl.StopListening();
     SafeExit();
 }
Exemplo n.º 21
0
 private void Start()
 {
     control = FindObjectOfType <JoystickControl>();
 }
Exemplo n.º 22
0
        public Boolean GenerateImageFile()
        {
            if (this.Project == null)
            {
                return(false);
            }
            if (this.Project.ImageSuffix == null)
            {
                return(false);
            }

            List <ImageSuffix> ListImgSuffix = new List <ImageSuffix>();

            // Fill All Image Suffix String in an Object
            for (int i = 0; i < this.Project.ImageSuffix.Count; i++)
            {
                ListImgSuffix.Add(new ImageSuffix(Project.ImageSuffix[i]));
            }

            try
            {
                for (int i = 0; i < this.Project.Scenes.Count; i++)
                {
                    if (this.Project.Scenes[i].isEnabled == true)
                    {
                        for (int j = 0; j < this.Project.Scenes[i].Layers.Count; j++)
                        {
                            if (this.Project.Scenes[i].Layers[j].isEnabled == true)
                            {
                                for (int k = 0; k < this.Project.Scenes[i].Layers[j].CoronaObjects.Count; k++)
                                {
                                    CoronaObject coronaObject = this.Project.Scenes[i].Layers[j].CoronaObjects[k];
                                    if (coronaObject.isEnabled == true)
                                    {
                                        if (coronaObject.isEntity == false)
                                        {
                                            DisplayObject obj = coronaObject.DisplayObject;
                                            if (obj.Type.Equals("IMAGE"))
                                            {
                                                //Enregistrer l'image en size *1
                                                if (!File.Exists(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png"))
                                                {
                                                    if (obj.GorgonSprite != null)
                                                    {
                                                        //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();
                                                        string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                        obj.OriginalAssetName + ".png");

                                                        string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + obj.SurfaceRect.Width + "x" + obj.SurfaceRect.Height;

                                                        if (File.Exists(imagePath))
                                                        {
                                                            if (!File.Exists(finalImageName + ".png"))
                                                            {
                                                                Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                Bitmap finalImage    = new Bitmap(originalImage, obj.SurfaceRect.Size);
                                                                finalImage.Save(finalImageName + ".png",
                                                                                System.Drawing.Imaging.ImageFormat.Png);
                                                                finalImage.Dispose();

                                                                for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                                                {
                                                                    Bitmap ImageResized = new Bitmap(originalImage, Convert.ToInt32(obj.SurfaceRect.Size.Width * ListImgSuffix[l].ratio),
                                                                                                     Convert.ToInt32(obj.SurfaceRect.Size.Height * ListImgSuffix[l].ratio));

                                                                    ImageResized.Save(finalImageName + ListImgSuffix[l].suffix + ".png",
                                                                                      System.Drawing.Imaging.ImageFormat.Png);

                                                                    ImageResized.Dispose();
                                                                }

                                                                originalImage.Dispose();
                                                            }
                                                        }
                                                    }
                                                    //else
                                                    //{
                                                    //    finalImage = new Bitmap(obj.Image, obj.SurfaceRect.Size);
                                                    //    finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                    //    finalImage.Dispose();
                                                    //}
                                                }
                                            }

                                            if (coronaObject.BitmapMask != null)
                                            {
                                                if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                {
                                                    coronaObject.BitmapMask.MaskImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < coronaObject.Entity.CoronaObjects.Count; e++)
                                            {
                                                CoronaObject child = coronaObject.Entity.CoronaObjects[e];
                                                if (child.isEnabled == true)
                                                {
                                                    DisplayObject obj = child.DisplayObject;
                                                    if (obj.Type.Equals("IMAGE"))
                                                    {
                                                        //Enregistrer l'image en size *1
                                                        if (!File.Exists(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png"))
                                                        {
                                                            if (obj.GorgonSprite != null)
                                                            {
                                                                string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                                obj.OriginalAssetName + ".png");

                                                                string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + obj.SurfaceRect.Width + "x" + obj.SurfaceRect.Height;

                                                                if (File.Exists(imagePath))
                                                                {
                                                                    if (!File.Exists(finalImageName + ".png"))
                                                                    {
                                                                        Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                        //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                                        Image finalImage = new Bitmap(originalImage, obj.SurfaceRect.Size);
                                                                        finalImage.Save(finalImageName + ".png",
                                                                                        System.Drawing.Imaging.ImageFormat.Png);
                                                                        finalImage.Dispose();

                                                                        for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                                                        {
                                                                            Bitmap ImageResized = new Bitmap(originalImage, Convert.ToInt32(obj.SurfaceRect.Size.Width * ListImgSuffix[l].ratio), Convert.ToInt32(obj.SurfaceRect.Size.Height * ListImgSuffix[l].ratio));
                                                                            ImageResized.Save(finalImageName + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                                            ImageResized.Dispose();
                                                                        }

                                                                        originalImage.Dispose();
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }



                                                    if (child.BitmapMask != null)
                                                    {
                                                        if (child.BitmapMask.MaskImage != null && child.BitmapMask.IsMaskEnabled == true)
                                                        {
                                                            child.BitmapMask.MaskImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            Scene scene = this.Project.Scenes[i];


                            // scene.createAllSpriteSheetsImages("", 1, 1);

                            for (int l = 0; l < scene.SpriteSheets.Count; l++)
                            {
                                CoronaSpriteSheet sheet = scene.SpriteSheets[l];

                                //if (size.Width >= 4096 || size.Height >= 4096)
                                //{
                                //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //}

                                //Creer le fichier lua associé
                                SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), "", 1, 1);
                            }

                            for (int l = 0; l < scene.Layers.Count; l++)
                            {
                                CoronaLayer layer = scene.Layers[l];
                                if (layer.isEnabled == true)
                                {
                                    if (layer.TilesMap != null)
                                    {
                                        if (layer.TilesMap.isEnabled == true)
                                        {
                                            string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                            string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                            string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                            string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";


                                            layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, "", 1, 1);
                                            layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, "", 1, 1);
                                            layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, "", 1, 1);
                                            layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, "", 1, 1);
                                            layer.TilesMap.refreshTilesMapContent();

                                            string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, 1, 1);
                                        }
                                    }
                                }
                            }

                            //Creer les sprites sheets
                            for (int k = 0; k < this.Project.ImageSuffix.Count; k++)
                            {
                                // scene.createAllSpriteSheetsImages(ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);

                                for (int l = 0; l < scene.SpriteSheets.Count; l++)
                                {
                                    CoronaSpriteSheet sheet = scene.SpriteSheets[l];


                                    //if (size.Width >= 4096 || size.Height >= 4096)
                                    //{
                                    //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                    //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    //}

                                    //Creer le fichier lua associé
                                    SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                    gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                }

                                for (int l = 0; l < scene.Layers.Count; l++)
                                {
                                    CoronaLayer layer = scene.Layers[l];
                                    if (layer.isEnabled == true)
                                    {
                                        if (layer.TilesMap != null)
                                        {
                                            if (layer.TilesMap.isEnabled == true)
                                            {
                                                string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                                string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                                string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                                string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";

                                                layer.TilesMap.refreshTilesMapContent();
                                                layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);


                                                //string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                            }
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Controls.Count; k++)
                            {
                                CoronaControl control = this.Project.Scenes[i].Layers[j].Controls[k];
                                if (control.isEnabled == true)
                                {
                                    if (control.Type == CoronaControl.ControlType.joystick)
                                    {
                                        JoystickControl joy = control as JoystickControl;

                                        //Pour l'image OUTER
                                        if (joy.outerImage != null)
                                        {
                                            //Enregistrer l'image en size *1
                                            Size   sizeBack   = new Size(joy.outerRadius * 2, joy.outerRadius * 2);
                                            Bitmap OuterImage = new Bitmap(joy.outerImage, sizeBack);
                                            OuterImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer.png", System.Drawing.Imaging.ImageFormat.Png);

                                            for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                            {
                                                Bitmap ImageResized = new Bitmap(joy.outerImage, Convert.ToInt32(sizeBack.Width * ListImgSuffix[l].ratio), Convert.ToInt32(sizeBack.Height * ListImgSuffix[l].ratio));
                                                ImageResized.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer" + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                ImageResized.Dispose();
                                                ImageResized = null;
                                            }

                                            OuterImage.Dispose();
                                            OuterImage = null;
                                        }

                                        //Pour l'image Inner
                                        if (joy.innerImage != null)
                                        {
                                            //Enregistrer l'image en size *1
                                            Size   sizeBack   = new Size(joy.innerRadius * 2, joy.innerRadius * 2);
                                            Bitmap InnerImage = new Bitmap(joy.innerImage, sizeBack);
                                            InnerImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner.png", System.Drawing.Imaging.ImageFormat.Png);

                                            for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                            {
                                                Bitmap ImageResized = new Bitmap(joy.innerImage, Convert.ToInt32(sizeBack.Width * ListImgSuffix[l].ratio), Convert.ToInt32(sizeBack.Height * ListImgSuffix[l].ratio));
                                                ImageResized.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner" + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                ImageResized.Dispose();
                                                ImageResized = null;
                                            }

                                            InnerImage.Dispose();
                                            InnerImage = null;
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Widgets.Count; k++)
                            {
                                CoronaWidget widget = this.Project.Scenes[i].Layers[j].Widgets[k];
                                if (widget.Type == CoronaWidget.WidgetType.tabBar)
                                {
                                    WidgetTabBar tabBar = (WidgetTabBar)widget;

                                    //Pour tous les bouttons
                                    for (int e = 0; e < tabBar.Buttons.Count; e++)
                                    {
                                        WidgetTabBar.TabBarButton bt = tabBar.Buttons[e];
                                        if (bt.ImagePressedState != null)
                                        {
                                            bt.ImagePressedState.Save(Project.BuildFolderPath + "\\" + tabBar.Name + bt.Id + "down.png");
                                        }
                                        if (bt.ImageUnPressedState != null)
                                        {
                                            bt.ImageUnPressedState.Save(Project.BuildFolderPath + "\\" + tabBar.Name + bt.Id + "up.png");
                                        }
                                    }

                                    /*if (tabBar.BackgroundImage != null)
                                     * {
                                     *  Bitmap bmp = new Bitmap(tabBar.BackgroundImage, tabBar.Size);
                                     *  bmp.Save(Project.BuildFolderPath + "\\" + tabBar.Name + "background.png");
                                     * }*/
                                }
                                else if (widget.Type == CoronaWidget.WidgetType.pickerWheel)
                                {
                                    WidgetPickerWheel pickW = (WidgetPickerWheel)widget;
                                    if (pickW.BackgroundImage != null)
                                    {
                                        Bitmap background = new Bitmap(pickW.BackgroundImage, pickW.BackgroundSize);
                                        background.Save(Project.BuildFolderPath + "\\" + pickW.Name + "background.png");
                                    }
                                }
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex) {
                MessageBox.Show("Error during image files generation !\n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
 public void Init(JoystickControl joystickControl)
 {
     m_JoystickControl = joystickControl;
 }
 public MainView()
 {
     InitializeComponent();
     jc          = JoystickControl.Instance;
     DataContext = jc;
 }
Exemplo n.º 25
0
 private void MainWindow_OnClosing(object sender, CancelEventArgs e)
 {
     JoystickControl.StopListening();
     Application.Current.Shutdown(0);
 }
 private void Joystick_OnInputChanged(Joystick sender, JoystickControl Type, int Value)
 {
     states[Type] = Value;
 }
Exemplo n.º 27
0
 public JoystickPropertyConverter(JoystickControl joy, Form1 MainForm)
 {
     this.joy      = joy;
     this.mainForm = MainForm;
 }