Exemplo n.º 1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            InputFunctions inputfuncs = new InputFunctions();
            FileFunctions  filefuncs  = new FileFunctions();

            if (!inputfuncs.verifyEmail(txtEmail.Text))
            {
                MessageBox.Show("Please enter a valid email address.");
            }
            else if (filefuncs.checkUser(txtEmail.Text, "users.csv"))
            {
                MessageBox.Show("An account already exists with this email address.");
            }
            else if (txtConfirm.Text != txtPassword.Text)
            {
                MessageBox.Show("Passwords must match!");
            }
            else
            {
                User.Name     = txtName.Text;
                User.Email    = txtEmail.Text;
                User.Age      = txtAge.Text;
                User.Password = txtPassword.Text;
                filefuncs.writeUser("users.csv");
                this.Hide();
                frmLogin login = new frmLogin();
                login.ShowDialog();
            }
        }
Exemplo n.º 2
0
        // Update is called once per frame
        private void Update()
        {
            if (Time.time > 1 && goAuto)
            {
                goAuto = false;
                AddAutoSave("<Début>");
            }

            cancelButton.interactable = m_projects.Count > 0 == m_idx > 0;
            redoButton.interactable   = m_projects.Count > 0 && m_idx < m_projects.Count - 1;
            if (InputFunctions.CTRL())
            {
                // CANCEL
                if (Input.GetKeyDown(KeyCode.Z))
                {
                    Cancel();
                }
                // REDO
                else if (Input.GetKeyDown(KeyCode.Y))
                {
                    Redo();
                }
                //if(operations.Count > 0)
                //{
                //    Operation currentOperation = operations.Last();
                //    currentOperation.Cancel();
                //    operations.Remove(currentOperation);
                //}
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // [FOREACH PERFORMANCE] ALLOCATES GARBAGE
            EngineComponents.AllServices.ForEach(a => a.LoadContent());
            Debug  = renderer2d.Debug;
            Camera = renderer2d.GameCamera;
            loadingScene.LoadContent();

            // set desired default resolution
            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;

#if LINUX
            // No, thanks!
            graphics.IsFullScreen = false;
#else
            graphics.IsFullScreen = Settings <GameSettings> .Value.IsFullscreen; // fullscreen when not debugging
#endif
            // F11 to switch to fullscreen
            InputManager.AddGlobalHooks(new InputMapping(
                                            (f) => InputFunctions.FullScreen(f),
                                            (f) => ToggleFullscreen())
                                        );

            this.Window.AllowUserResizing = true;
            graphics.ApplyChanges();

            this.CurrentGameMode = new PlayerAndGameInfo(this);
            SwitchScene(new MainMenuScene(this));
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Move the opening along the wall, according to mouse.
        /// </summary>
        /// <param name="offset">The starting position when the users clicks</param>
        public override void Move(Vector3 offset)
        {
            Camera cam = GlobalManager.Instance.GetActiveCamera();

            switch (cam.gameObject.layer)
            {
            case (int)ErgoLayers.Top:

                Vector3       pos2D   = InputFunctions.GetWorldPoint2D(cam);
                Room          r       = SelectedObjectManager.Instance.currentRoomData;
                System.Single roomMod = r == null ? 1f : r.LockAngles ? 1f / 4f : 1f / 2f;
                SetPosition(VectorFunctions.Switch3D2D(Position) + (pos2D - offset) * roomMod);

                break;

            case (int)ErgoLayers.ThreeD:

                Vector3 pos3D = InputFunctions.GetWorldPoint3D(cam, false);
                Room    room  = SelectedObjectManager.Instance.currentRoomData;
                //System.Single roomModif = room == null ? 1f : room.LockAngles ? 1f / 4f : 1f / 2f;
                SetPosition(VectorFunctions.Switch3D2D(offset));

                //Debug.Log(pos3D+"   "+ VectorFunctions.Switch3D2D(offset) +"     Result = "+ (pos3D - offset) * 1 + "    final = " + VectorFunctions.Switch2D3D(Position) + (pos3D - offset) * 1);

                break;
            }
        }
        public PlayerControllerComponent(PlayerInfo player)
        {
            base.GamePadIndex = player.GamepadIndex;

            if (player.IsKeyboardPlayer)
            {
                Mappings.Add(new InputMapping(null, MovementFromKeyboard));

                Mappings.Add(new InputMapping(f => InputFunctions.KeyboardDash(f), f => StartDash()));

                Mappings.Add(new InputMapping(f => InputFunctions.KeyboardStartShout(f), f => SwitchState(PlayerState.Shouting)));
                Mappings.Add(new InputMapping(f => InputFunctions.KeyboardEndShout(f), f => SwitchState(PlayerState.Walking)));

                Mappings.Add(new InputMapping(f => InputFunctions.KeyboardStartLure(f), f => SwitchState(PlayerState.Luring)));
                Mappings.Add(new InputMapping(f => InputFunctions.KeyboardEndLure(f), f => SwitchState(PlayerState.Walking)));
            }
            else
            {
                Mappings.Add(new InputMapping(null, MovementFromGamepad));

                Mappings.Add(new InputMapping(f => InputFunctions.Dash(f), f => StartDash()));


                Mappings.Add(new InputMapping(f => InputFunctions.StartShout(f), f => SwitchState(PlayerState.Shouting)));
                Mappings.Add(new InputMapping(f => InputFunctions.EndShout(f), f => SwitchState(PlayerState.Walking)));

                Mappings.Add(new InputMapping(f => InputFunctions.StartLure(f), f => SwitchState(PlayerState.Luring)));
                Mappings.Add(new InputMapping(f => InputFunctions.EndLure(f), f => SwitchState(PlayerState.Walking)));
            }
        }
Exemplo n.º 6
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            InputFunctions inputfuncs = new InputFunctions();
            FileFunctions  filefuncs  = new FileFunctions();
            string         email      = txtEmail.Text;

            if (!inputfuncs.verifyEmail(email))
            {
                MessageBox.Show("Please enter a valid email address");
            }
            else if (filefuncs.checkUser(email, "users.csv"))
            {
                string password = filefuncs.getField(email, 3, "users.csv");
                if (password == txtPassword.Text)
                {
                    this.Hide();
                    User.Name     = filefuncs.getField(email, 0, "users.csv");
                    User.Email    = email;
                    User.Password = password;
                    frmProfile profile = new frmProfile();
                    profile.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Invalid password.");
                }
            }
            else
            {
                MessageBox.Show("An account does not exist with that email address.");
            }
        }
Exemplo n.º 7
0
 /// <summary>
 ///     Updates instructions when no selection context
 /// </summary>
 private void SetInstructionsText()
 {
     if (HelpersCreator.Instance.IsOccupied())
     {
     }
     else if (SelectedObjectManager.Instance.HasNoSelection())
     {
         if (InputFunctions.IsMouseOutsideUI())
         {
             if (GlobalManager.Instance.GetActiveCamera().gameObject == GlobalManager.Instance.cam2DTop)
             {
                 Instance.instructionsText.text = "Déplacez la caméra avec le clic droit. F1 pour changer de vue vers la 3D sur mac fin + F1";
             }
             else if (GlobalManager.Instance.GetActiveCamera().gameObject == GlobalManager.Instance.cam3D)
             {
                 Instance.instructionsText.text = "Déplacez la caméra avec les fleche et avec le clic molette tournez votre vue. F1 pour changer de vue vers la 2D, sur mac fin + F1";
             }
             else
             {
                 Instance.instructionsText.text = "Déplacez la caméra avec le clic molette ou avec les fleches du clavier. Tournez la caméra avec le clic droit. F1 pour changer de vue, sur mac fin + F1.";
             }
             //Debug.Log(GlobalManager.Instance.GetActiveCamera());
         }
     }
 }
Exemplo n.º 8
0
        private void StartIfReady()
        {
            if (!IsTransitioning)
            {
                if (players.Count > 0 && players.TrueForAll(t => t.CurrentState == JoinState.State.Ready))
                {
                    if (this.Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo && !Debugger.IsAttached)
                    {
                        if (players.Count(t => t.CurrentState == JoinState.State.Ready) < 4)
                        {
                            return;
                        }
                    }

#if DEBUG
                    if (InputFunctions.DebugModifierIsOn(Keyboard.GetState()))
                    {
                        this.TransitionOutAndSwitchScene(new EndlessGameScene(this.Game));
                    }
                    else
#endif
                    if (this.Game.CurrentGameMode.GameMode == GameMode.BigHerd)
                    {
                        this.TransitionOutAndSwitchScene(new BasicGameScene(this.Game));
                    }
                    else if (this.Game.CurrentGameMode.GameMode == GameMode.Waves)
                    {
                        this.TransitionOutAndSwitchScene(new RightToLeftGameScene(this.Game));
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Create a new text zone. Its a comment zone shown in both views.
        /// </summary>
        private void CreateTextZone()
        {
            if (m_isCreating)
            {
                if (!m_isDragging)
                {
                    if (InputFunctions.IsClickingOutsideUI())
                    {
                        m_startPoint   = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());
                        m_endPoint     = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());
                        m_isDragging   = true;
                        currentElement = new TextZoneElement
                        {
                            Text            = "Commentaire",
                            BackgroundColor = Color.gray,
                            TextColor       = Color.black,
                            TextSize        = 1
                        };
                        currentElement.associated2DObject = Instantiate(textZonePrefab);
                        currentElement.associated3DObject = Instantiate(textZonePrefab);

                        currentElement.associated2DObject.GetComponentInChildren <TextMesh>().fontStyle = FontStyle.Bold;
                        currentElement.associated3DObject.GetComponentInChildren <TextMesh>().fontStyle = FontStyle.Bold;

                        currentElement.associated2DObject.SetLayerRecursively((int)ErgoLayers.Top);
                        currentElement.associated3DObject.SetLayerRecursively((int)ErgoLayers.ThreeD);
                    }
                }
                else
                {
                    m_endPoint = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());

                    if (InputFunctions.IsClickingOutsideUI())
                    {
                        m_isCreating = false;
                        m_isDragging = false;
                        m_helpers.Add(currentElement);
                        OperationsBufferScript.Instance.AddAutoSave("Creation zone de texte");
                    }

                    currentElement.associated2DObject.transform.position = (m_startPoint + m_endPoint) / 2f;
                    currentElement.Position = VectorFunctions.Switch2D3D((m_startPoint + m_endPoint) / 2f);
                    currentElement.associated3DObject.transform.position = currentElement.Position;

                    (currentElement as TextZoneElement).Size = VectorFunctions.Switch2D3D(currentElement
                                                                                          .associated2DObject.GetComponent <TextZoneScript>().SetSize(m_startPoint, m_endPoint));
                    currentElement.associated3DObject.GetComponent <TextZoneScript>().SetSize(m_startPoint, m_endPoint);

                    // CANCEL
                    if (Input.GetMouseButtonDown(1))
                    {
                        m_isCreating = false;
                        m_isDragging = false;
                        Destroy(currentElement.associated2DObject);
                        currentElement = null;
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void ClickArrow()
        {
            // Press on arrow = select arrow
            if (Input.GetMouseButtonDown(0))
            {
                var go = InputFunctions.GetHoveredObject2D(GlobalManager.Instance.GetActiveCamera());
                if (!go || go.tag != "WallArrow")
                {
                    isMoving = false;
                    return;
                }

                currentArrow = go;
            }

            // Release = no arrow
            if (Input.GetMouseButtonUp(0))
            {
                currentArrow = null;
            }

            // if arrow
            if (currentArrow)
            {
                var proj     = Vector3.zero;
                var mousePos = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());
                var d        = 0f;
                switch (currentArrow.name)
                {
                case "P1o":
                    proj    = Vector3.Project(mousePos - wo.Position, wo.Wall.Direction) + wo.Position;
                    d       = Vector3.Distance(proj, wo.Position);
                    wo.Size = new Vector3(d, wo.Size.y, wo.Size.z);
                    wo.SetPosition(wo.Position - d * wo.Wall.Direction);
                    WallsCreator.Instance.AdjustAllWalls();
                    WallOpeningPropScript.Instance.UpdateWallOpeningProperties();

                    break;

                case "P2o":
                    proj    = Vector3.Project(mousePos - wo.Position, -wo.Wall.Direction) + wo.Position;
                    d       = Vector3.Distance(proj, wo.Position);
                    wo.Size = new Vector3(d, wo.Size.y, wo.Size.z);
                    wo.SetPosition(wo.Position + d * wo.Wall.Direction);
                    WallsCreator.Instance.AdjustAllWalls();
                    WallOpeningPropScript.Instance.UpdateWallOpeningProperties();

                    break;
                }

                currentArrow.transform.position = proj + m_decal;
                isMoving = true;
            }
            else
            {
                isMoving = false;
            }
        }
Exemplo n.º 11
0
        private void computeGlobalInput(MHiddenLayerHeader header, MNeuronStack neuronStack)
        {
            var inputFunction = header.InputFunction;

            foreach (MNeuron x in neuronStack.Stack)
            {
                x.GlobalInput = InputFunctions.computeGlobalInput(inputFunction, x);
                Console.WriteLine("test_input " + x.GlobalInput);
                Console.WriteLine(inputFunction);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 ///     Start 3d measure
 /// </summary>
 public void PutFirstPoint3D()
 {
     if (m_goPutFirstPoint3D)
     {
         if (InputFunctions.IsClickingOutsideUI())
         {
             measure3D.gameObject.SetActive(true);
             measure3D.start      = InputFunctions.GetWorldPoint(GlobalManager.Instance.cam3D.GetComponent <Camera>());
             m_goPutSecondPoint3D = true;
         }
     }
 }
Exemplo n.º 13
0
 /// <summary>
 ///     End 3d measure
 /// </summary>
 public void PutSecondPoint3D()
 {
     if (m_goPutSecondPoint3D)
     {
         measure3D.end = InputFunctions.GetWorldPoint(GlobalManager.Instance.cam3D.GetComponent <Camera>());
         if (InputFunctions.IsClickingOutsideUI())
         {
             IsMesuring          = false;
             m_goPutFirstPoint2D = m_goPutFirstPoint3D = m_goPutSecondPoint2D = m_goPutSecondPoint3D = false;
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 ///     Check all managers to see if camera must be locked or not
 /// </summary>
 /// <param name="cam"></param>
 /// <returns>true if camera can move</returns>
 public bool CanCameraMove(Camera2DMove cam)
 {
     return(!SelectedObjectManager.Instance.IsOccupied() &&
            !WallsCreator.Instance.IsCreating() &&
            InputFunctions.IsMouseOutsideUI() &&
            cam.GetComponent <Camera>().targetTexture == null &&
            !WallArrowsScript.Instance.isMoving &&
            !ElementArrowsScript.Instance.isMoving &&
            !HelpersCreator.Instance.IsOccupied() &&
            !ProjectManager.Instance.IsOccupied());
     //&& !WallOpeningArrowsScript.Instance.isMoving;
 }
Exemplo n.º 15
0
            public override bool Inputs()
            {
                bool ret = false;

                if (InputFunctions != null && InputFunctions.TryGetValue((Mode)GetMode(), out Func <bool> fun))
                {
                    ret = fun();
                }
                if (!ret && Input2.Button(FF8TextTagKey.Confirm))
                {
                    SetMode(((Mode)GetMode()) + 1);
                }
                return(true);
            }
Exemplo n.º 16
0
        // Update is called once per frame
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.F1) && InputFunctions.IsMouseOutsideUI())
            {
                SwitchViewMode();
            }

            grid.SetActive(SettingsManager.Instance.SoftwareParameters.ShowGrid);

            var go             = InputFunctions.GetHoveredObject2D(cam2DTop.GetComponent <Camera>());
            var isElementArrow = false;

            if (go && go.tag.Contains("Arrow"))
            {
                isElementArrow = true;
            }

            // CURSOR
            UpdateCursor(isElementArrow);

            // Camera render texture

            if (m_mode == ViewMode.Top)
            {
                //if (!cam3D.GetComponent<Camera>().orthographic)
                //{
                //    cam3D.GetComponent<Camera3DMove>().SetTopView();
                //}

                ///<summary>
                ///suivre la cam 2D
                /// </summary>

                //cam3D.transform.localEulerAngles = Vector3.right * 90f;
                //cam3D.GetComponent<Camera3DMove>().SetPosition(VectorFunctions.Switch2D3D(
                //cam2DTop.transform.position + Vector3.right * 2.5f, cam2DTop.transform.position.z * -1f));
            }
            else if (m_mode == ViewMode.ThreeD)
            {
                if (cam3D.GetComponent <Camera>().orthographic)
                {
                    cam3D.GetComponent <Camera3DMove>().SetNormalView();
                }
                // cam2DTop.GetComponent<Camera2DMove>().SetPosition(cam3D.transform.position + Vector3.right * 2.5f);
            }

            // UI Bindings
            //UI.faceButton.interactable = som.currentWallsData.Count == 1;
        }
Exemplo n.º 17
0
        public override void Draw(GameTime gameTime, float elapsedSeconds, float totalSeconds)
        {
            bool drawDebug = InputFunctions.DrawDebug(Keyboard.GetState());

            DrawLayer(GameCamera, EntityType.Game, drawDebug, elapsedSeconds, totalSeconds);
            DrawLayer(null, EntityType.UI, drawDebug, elapsedSeconds, totalSeconds);
            DrawLayer(GameCamera, EntityType.OverlayLayer, drawDebug, elapsedSeconds, totalSeconds);

#if DEBUG
            if (drawDebug)
            {
                this.GameCamera.Debug.Draw(gameTime, spriteBatch, new Vector2(0, 0));
            }
#endif
        }
Exemplo n.º 18
0
        public override void LoadContent()
        {
            base.LoadContent();

            SpawnCattleInZone(new Rectangle(-10, -6, 20, 12), 1, 1);

            AddEntity(new Entity(this, EntityType.LayerIndependent,
                                 new InputComponent(0, new InputMapping(f => InputFunctions.SpawnBoar(f), f =>
            {
                SpawnCattleInZone(new Rectangle(-10, -6, 20, 12), 1, 0);
            }), new InputMapping(f => InputFunctions.SpawnChicken(f), f =>
            {
                SpawnCattleInZone(new Rectangle(-10, -6, 20, 12), 0, 1);
            }), new InputMapping(f => InputFunctions.EndRound(f), f =>
            {
                this.Game.SwitchScene(new WinScene(this.Game));
            })
                                                    )));

            // Trees
            AddEntity(new Entity(this, EntityType.Game, new Vector2(-11f, 0f), 0.4f,
                                 //300 x 344
                                 new SpriteComponent("tree1", new Vector2(3 * 1.75f, 3.44f * 1.75f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(new Vertices(new[]
            {
                new Vector2(-2, 0), new Vector2(1, -2), new Vector2(2, -1),
                new Vector2(2, 1), new Vector2(0, 2)
            }), 1))
                                 ));
            AddEntity(new Entity(this, EntityType.Game, new Vector2(11f, 0f), 1.4f,
                                 //300 x 344
                                 new SpriteComponent("tree1", new Vector2(3 * 1.75f * 1.1f, 3.44f * 1.75f * 1.1f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(new Vertices(new[]
            {
                new Vector2(-2, 0), new Vector2(1, -2), new Vector2(2, -1),
                new Vector2(2, 1), new Vector2(0, 2)
            }.Select(v => v * 1.1f)), 1))
                                 ));
        }
Exemplo n.º 19
0
        private void Update()
        {
            // If we press the left mouse button, save mouse location and begin selection
            if (InputFunctions.IsClickingOutsideUI())
            {
                firstPosition = Input.mousePosition;
                firstClickOk  = true;
            }

            if (Input.GetMouseButton(0) && firstClickOk && Vector3.Distance(firstPosition, Input.mousePosition) > 5f)
            {
                IsSelecting = true;
            }

            // If we let go of the left mouse button, end selection
            if (Input.GetMouseButtonUp(0) || ElementArrowsScript.Instance.isMoving ||
                WallArrowsScript.Instance.isMoving || SelectedObjectManager.Instance.IsOccupied() ||
                WallsCreator.Instance.IsCreating())
            {
                firstClickOk = false;
            }
        }
Exemplo n.º 20
0
        public override void LoadContent()
        {
            base.LoadContent();

            //Game.CurrentGameMode.ClearPlayers();
            Game.EngineComponents.Get <AudioManager>().PreloadSongs("Audio\\joinScreen", "Audio\\gamePlay");
            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -0.9f)));

            // UI
            HUDTextComponent pressStartText    = new HUDTextComponent(MainFont, 0.04f, "PRESS START", offset: new Vector2(0.5f, 0.9f), origin: new Vector2(0.5f, 0.5f), layerDepth: 1f);
            HUDComponent     vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0)
            {
                MaintainAspectRation = false, OnVirtualUIScreen = false,
                Color = Color.FromNonPremultiplied(22, 59, 59, 163)
            };
            Vector2      logoSize      = new Vector2(1, 0.7684f);
            HUDComponent logoComponent = new HUDComponent("titleScreen", 0.9f * logoSize, offset: new Vector2(0.5f, 0.5f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.9f);

            AddEntity(new Entity(this, EntityType.UI, Vector2.Zero, pressStartText, vignetteComponent, logoComponent));
            Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn)));


            var inputEntity = new Entity(this, EntityType.LayerIndependent,
                                         new InputComponent(0, new InputMapping(f => InputFunctions.KeyboardMenuStart(f), StartPressed))
                                         );

            for (int i = 0; i < 4; i++)
            {
                inputEntity.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuStart(f), StartPressed)));
            }
            AddEntity(inputEntity);

            AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)));

            this.TransitionIn();
        }
Exemplo n.º 21
0
        public override void LoadContent()
        {
            base.LoadContent();

            // we create them to preload everything
            new BoarEntity(this, Vector2.Zero);
            new ChickenEntity(this, Vector2.Zero, 0); // normal chicken
            new ChickenEntity(this, Vector2.Zero, 1); // yellow chicken

            player        = playerEntities[0];
            startPosition = player.Body.Position;

            // Trees
            AddEntity(new Entity(this, EntityType.Game, new Vector2(2.4f, 2f), 0.4f,
                                 new SpriteComponent("tree1", new Vector2(5.25f, 6.02f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(new Vertices(GameConstants.BoundingTree1), 1))
                                 ));
            AddEntity(new Entity(this, EntityType.Game, new Vector2(-2.8f, -3.5f), 1.4f,
                                 new SpriteComponent("tree1", new Vector2(5.25f * 1.1f, 6.02f * 1.1f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(new Vertices(GameConstants.BoundingTree1.Select(v => v * 1.1f)), 1))
                                 ));


            // UI
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.95f), welcome = new HUDTextComponent(MainFont, 0.08f, "Welcome to VACAMOLE.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 playerAndBarn = new HUDTextComponent(MainFont, 0.08f, "This is your player and your barn.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 moveWithStick = new HUDTextComponent(MainFont, 0.08f, "Try to move with the left stick of your controller.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 dash1 = new HUDTextComponent(MainFont, 0.08f, "Good. Now press the right bumper to dash.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 dash2 = new HUDTextComponent(MainFont, 0.08f, "Try to dash multiple times.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 lure = new HUDTextComponent(MainFont, 0.08f, "Press A to lure animals towards you!", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 shout = new HUDTextComponent(MainFont, 0.08f, "Press B to shout. The animals will run!", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            }
                                 ));
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.9f), dizzy = new HUDTextComponent(MainFont, 0.08f, "If you dash too often or into a something, you get dizzy.\nHowever, if you hit another player you can make them dizzy.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 fetchAnimal = new HUDTextComponent(MainFont, 0.08f, "Now use luring (B) and shouting (A) to bring animals into your barn.\nBoars give 3 points, chicken 1 point.", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            },
                                 pressStartToLeave = new HUDTextComponent(MainFont, 0.08f, "Well done! Press START to continue!\nGrab your friends - VACAMOLE is enjoyed best with 4 players!", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            }));

            bool isKeyboard   = Game.CurrentGameMode.PlayerInfos.First().IsKeyboardPlayer;
            int  gamepadIndex = Game.CurrentGameMode.PlayerInfos.First().GamepadIndex;

            AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(gamepadIndex,
                                                                                       new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuStart(f) : InputFunctions.MenuStart(f), f =>
            {
                if (currentState == TutorialState.PressStartToLeaveTutorial && !IsTransitioning)
                {
                    Settings <GameSettings> .Value.ShowTutorial = false;
                    Settings <GameSettings> .Save();
                    Pause();
                    this.TransitionOutAndSwitchScene(navigateBackToMainMenu ? (Scene) new MainMenuScene(Game) : new GameModeScene(Game));
                }
            }))));
        }
Exemplo n.º 22
0
        private InputComponent MakeInput(bool isKeyboard, int gamepadIndex)
        {
            return(new InputComponent(gamepadIndex,
                                      new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuStart(f) : InputFunctions.MenuStart(f), f => StartIfReady()),
                                      new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuSelect(f) : InputFunctions.MenuSelect(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);

                if (player != null)
                {
                    PlayerIsReady(player);
                }
                else
                {
                    JoinPlayer(isKeyboard, gamepadIndex);
                }
            }), new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuBack(f) : InputFunctions.MenuBack(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);

                if (player != null)
                {
                    if (player.CurrentState == JoinState.State.Joined)
                    {
                        NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                        Game.CurrentGameMode.RemovePlayer(gamepadIndex, isKeyboard);
                        RemoveEntity(player.HUD);
                        RemoveEntity(player.Player);
                        players.Remove(player);
                        numJoinedPlayer--;

                        if (numJoinedPlayer < 4)
                        {
                            Dispatcher.AddAnimation(Animation.Get(joinComponent.Opacity, 1, 0.2f, false, (val) =>
                            {
                                joinComponent.Opacity = val;
                                joinTextComponent.Opacity = val;
                            }, EasingFunctions.QuadIn));
                        }
                    }
                    else if (player.CurrentState == JoinState.State.Ready)
                    {
                        NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                        player.Back();

                        // Animate text
                        var textChooser = player.HUD.GetComponentByName <HUDTextComponent>("nameTextchooser");
                        Dispatcher.AddAnimation(Animation.Get(textChooser.Opacity, 1f, 1f, false, (o) => textChooser.Opacity = o, EasingFunctions.QuadIn));
                        var boardChooser = player.HUD.GetComponentByName <HUDComponent>("namechooser");
                        Dispatcher.AddAnimation(Animation.Get(boardChooser.Opacity, 1f, 1f, false, (o) => boardChooser.Opacity = o, EasingFunctions.QuadIn));

                        var text = player.HUD.GetComponentByName <HUDTextComponent>("nameText");
                        Dispatcher.AddAnimation(Animation.Get(text.Opacity, 0f, 1f, false, (o) => text.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
                        var board = player.HUD.GetComponentByName <HUDComponent>("name");
                        Dispatcher.AddAnimation(Animation.Get(board.Opacity, 0f, 1f, false, (o) => board.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));

                        player.Player.Freeze();

                        if (players.Count(j => j.CurrentState == JoinState.State.Ready) >= (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? 4 : 1))
                        {
                            pressStartToStartAnimation.IsRunning = false;
                            Dispatcher.AddAnimation(Animation.Get(pressStartToStart.Opacity, 0f, 0.3f, false, (o) => pressStartToStart.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
                        }
                    }
                }
                else if (!players.Any())
                {
                    this.TransitionOutAndSwitchScene(new GameModeScene(Game));
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuRandom(f)
                        : InputFunctions.MenuRandom(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetRandomName(player);
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuLeft(f) || InputFunctions.KeyboardMenuUp(f)
                        : InputFunctions.MenuLeft(f) || InputFunctions.MenuUp(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetNextOrPreviousName(player, 1);
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuRight(f) || InputFunctions.KeyboardMenuDown(f)
                        : InputFunctions.MenuRight(f) || InputFunctions.MenuDown(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetNextOrPreviousName(player, -1);
                }
            })
                                      ));
        }
Exemplo n.º 23
0
        // Update is called once per frame
        private void Update()
        {
            // RIGIDBODIES
            foreach (var f in m_furnituresData)
            {
                if (f != m_currentFurniture)
                {
                    //if (f.associated3DObject == null) { return; }
                    var rb = f.associated3DObject.GetComponent <Rigidbody>();

                    // Freeze all except if its current selected furniture
                    if (SelectedObjectManager.Instance.currentFurnitureData.Count == 1 &&
                        SelectedObjectManager.Instance.currentFurnitureData[0] == f)
                    {
                        if (f.IsOnWall)
                        {
                            rb.constraints = RigidbodyConstraints.FreezeRotation;
                            rb.useGravity  = false;
                        }
                        else
                        {
                            if (f.CanBePutOnFurniture)
                            {
                                rb.constraints = RigidbodyConstraints.FreezeRotation;
                            }
                            else
                            {
                                rb.constraints = RigidbodyConstraints.FreezeRotation |
                                                 RigidbodyConstraints.FreezePositionY;
                            }
                        }
                    }
                    else
                    {
                        rb.constraints = RigidbodyConstraints.FreezeAll;
                    }

                    // update 2D position if moving
                    if (f.associated3DObject?.GetComponent <Rigidbody>().velocity.magnitude > 0 && f.associated3DObject.activeSelf) //activeSelf Evite de deplacer l'objet 2D quand la 3d est masquer
                    {
                        f.Position = f.associated3DObject.transform.position;
                        f.associated2DObject.transform.position =
                            VectorFunctions.GetExactPositionFrom3DObject(f.associated2DObject, f.associated3DObject,
                                                                         f.Position);
                        //VectorFunctions.Switch3D2D(f.Position);
                        rb.velocity *= 0.5f;
                    }

                    f.text2D.transform.position = f.associated2DObject.transform.position;
                }
            }

            // In creation -> check view then position it
            if (m_currentFurniture != null)
            {
                m_currentFurniture.Move(InputFunctions.GetWorldPoint(GlobalManager.Instance.GetActiveCamera()));
            }
            // Validate
            if (Input.GetMouseButtonDown(0) && m_currentFurniture != null)
            {
                m_currentFurniture.Position = m_currentFurniture3D.transform.position;
                m_currentFurniture          = null;

                if (m_currentFurniScript)
                {
                    Destroy(m_currentFurniScript.gameObject);
                    m_currentFurniScript = null;
                }

                //m_currentFurniture3D.GetComponent<MeshCollider>().enabled = true;
            }

            // in creation -> rotation
            //if (Input.GetMouseButtonDown(1)) { //m_currentFurniture.Rotation = Vector3.Angle(m_currentFurniture.Position,Input.mousePosition); };

            if (Input.GetButtonDown("Cancel"))
            {
                CancelFurniture();
            }
        }
Exemplo n.º 24
0
        public override void LoadContent()
        {
            base.LoadContent();

            Game.EngineComponents.Get <AudioManager>().PreloadSoundEffects("Audio/countDownLong", "Audio/countDownShort");

            Game.CurrentGameMode.ClearScore();

            AddPlayersWithBarns(locs, rotations);

            // Border trees
            Entity border;

            AddEntity(border = new Entity(this, EntityType.Game, new Vector2(0, 0),
                                          new SpriteComponent("joinscreen_outerBorder", new Vector2(screenWidth, screenWidth / 3.84f * 2.245f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f)
                                          ));

            var triangulated = Triangulate.ConvexPartition(GameConstants.BoundingGameFieldTop, TriangulationAlgorithm.Earclip);

            triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldRight, TriangulationAlgorithm.Earclip));
            triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldBottom, TriangulationAlgorithm.Earclip));
            triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldLeft, TriangulationAlgorithm.Earclip));
            var fixtureList = FixtureFactory.AttachCompoundPolygon(triangulated, 1, border.Body);

            border.AddComponent(new PhysicsComponent(fixtureList[0].Shape));

            // Background
            AddEntity(new Entity(this, EntityType.Game, new Vector2(0, 0),
                                 // src image 6000x3508
                                 new SpriteComponent("background", new Vector2(screenWidth, screenWidth / 3.84f * 2.245f), new Vector2(0.5f, 0.5f), layerDepth: -1.0f)
                                 ));


            // HUD
            // src image 1365x460
            if (spawnAnyUI)
            {
                timeComponentBackground = new HUDComponent("timer_bg", new Vector2(1.365f / 0.46f * 0.1f, 1f * 0.1f), new Vector2(0.5f, 0f));

                this.timeComponent100 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor,
                                                             offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.35f, 0.5f)),
                                                             origin: new Vector2(0.5f, 0.5f)
                                                             );
                this.timeComponent10 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor,
                                                            offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.425f, 0.5f)),
                                                            origin: new Vector2(0.5f, 0.5f)
                                                            );
                this.timeComponent1 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor,
                                                           offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)),
                                                           origin: new Vector2(0.5f, 0.5f)
                                                           );
                AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0f),
                                     timeComponentBackground, timeComponent100, timeComponent10, timeComponent1
                                     ));

                if (!IsCountdownRunning)
                {
                    timeComponentBackground.Opacity    =
                        timeComponent100.Opacity       =
                            timeComponent10.Opacity    =
                                timeComponent1.Opacity = 0f;
                }

                UpdateCountdown(0);

                // Add pause overlay
                AddEntity(new Entity(this, EntityType.UI, pauseOverlayComponents.AddAndReturn(new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0.99f)
                {
                    Color = Color.Black,
                    MaintainAspectRation = false,
                    OnVirtualUIScreen    = false,
                })));

                AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.25f),
                                     pauseTextOverlayComponents.AddAndReturn(new HUDTextComponent(MainFont, 0.2f, "Game Paused", origin: new Vector2(0.5f, 0.5f), layerDepth: 1f))));

                pauseTextOverlayComponents.AddRange(
                    AddEntity(pauseMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.5f), layerDepth: 1f,
                                                                menuEntries: new[] { new HUDListEntity.ListEntry("Resume", TogglePause), new HUDListEntity.ListEntry("Rejoin", BackToJoinScreen)
                                                                                     , new HUDListEntity.ListEntry("Back to main menu", BackToMainMenu) })
                {
                    Enabled = false
                })
                    .GetAllComponents <HUDTextComponent>().ToList());

                // make overlay invisible
                // [FOREACH PERFORMANCE] Should not allocate garbage
                pauseOverlayComponents.ForEach(c => c.Opacity = 0f);
                // [FOREACH PERFORMANCE] Should not allocate garbage
                pauseTextOverlayComponents.ForEach(c => c.Opacity = 0f);

                // Add pause controls
                // [FOREACH PERFORMANCE] Should not allocate garbage
                foreach (var playerInfo in Game.CurrentGameMode.PlayerInfos)
                {
                    if (playerInfo.IsKeyboardPlayer)
                    {
                        AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(new InputMapping(i => InputFunctions.KeyboardPause(i), (f) => TogglePause(null)))));
                    }
                    else
                    {
                        AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(playerInfo.GamepadIndex,
                                                                                                   new InputMapping(i => InputFunctions.Pause(i), (f) => TogglePause(null)),
                                                                                                   new InputMapping(i => InputFunctions.StartCountdown(i), (f) => StartCountown())
                                                                                                   )));
                    }
                }

                var playerInfos = Game.CurrentGameMode.PlayerInfos;
                var colors      = ((PlayerColors[])Enum.GetValues(typeof(PlayerColors)));

                initialCountdownComponent = new HUDTextComponent(MainFont, 0.25f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "vs" : "free4all", origin: new Vector2(0.5f, 0.5f));
                playerName1Component      = new HUDTextComponent(MainFont, 0.15f, playerInfos[0].Name, color: colors[0].GetColor(), origin: new Vector2(0f, 0.5f), offset: new Vector2(-0.25f, -0.25f));
                playerName2Component      = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 1 ? playerInfos[1].Name : "name2", color: colors[1].GetColor(), origin: new Vector2(0f, 0.5f), offset: new Vector2(-0.25f, 0.25f));
                playerName3Component      = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 2 ? playerInfos[2].Name : "name3", color: colors[2].GetColor(), origin: new Vector2(1f, 0.5f), offset: new Vector2(0.25f, -0.25f));
                playerName4Component      = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 3 ? playerInfos[3].Name : "name4", color: colors[3].GetColor(), origin: new Vector2(1f, 0.5f), offset: new Vector2(0.25f, 0.25f));
                separatorTeam1Component   = new HUDTextComponent(MainFont, 0.15f, "&", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0f, -0.25f));
                separatorTeam2Component   = new HUDTextComponent(MainFont, 0.15f, "&", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0f, 0.25f));
                Entity countdownEntity;
                AddEntity(countdownEntity = new Entity(this, EntityType.UI, new Vector2(0.5f, 0.5f), initialCountdownComponent));

                if (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo)
                {
                    countdownEntity.AddComponent(playerName1Component);
                    countdownEntity.AddComponent(playerName2Component);
                    countdownEntity.AddComponent(playerName3Component);
                    countdownEntity.AddComponent(playerName4Component);
                    countdownEntity.AddComponent(separatorTeam1Component);
                    countdownEntity.AddComponent(separatorTeam2Component);
                }
            }
            // Camera director
            AddEntity(new Entity(this, EntityType.LayerIndependent, new CameraDirectorComponent(playerEntities, Game.Camera)));
        }
Exemplo n.º 25
0
        // Update is called once per frame
        private void Update()
        {
            /////////////////


            cotationTM.color = Color.black;

            if (myElement == null && !isUp && !isDown && !isLeft && !isRight && !isMeasure)
            {
                Destroy(gameObject);
            }

            if (!cotationField)
            {
                foreach (var inf in FindObjectsOfType <InputField>())
                {
                    // ceinture bretelles
                    if (inf.name == "CotationField" || inf.tag == "Cotation")
                    {
                        cotationField = inf;
                    }
                }
            }

            if (!is3D)
            {
                start.z = -0.05f;
                end.z   = -0.05f;
            }

            var show = Length > 0.005 && Length != float.PositiveInfinity && !IsExterior;

            /*start != Vector3.positiveInfinity && end != Vector3.positiveInfinity && */

            arrow1.gameObject.SetActive(show);
            arrow2.gameObject.SetActive(show);
            middle1.gameObject.SetActive(show);
            middle2.gameObject.SetActive(show);
            cotationTM.gameObject.SetActive(show);
            if (!show)
            {
                return;
            }


            var approxDist = Mathf.Floor(Vector3.Distance(start, end) * 100f);
            var offset     = approxDist > 999 ? 0.4f : 0.3f;

            var dir = (end - start).normalized;

            transform.position = (start + end) / 2f;

            transform.rotation = Quaternion.FromToRotation(Vector3.up, dir);

            arrow1.position = start;
            arrow2.position = end;

            var mid     = (arrow1.position + arrow2.position) / 2f;
            var dist    = Vector3.Distance(arrow1.position, arrow2.position);
            var midSize = new Vector2(0.025f, dist / 2f - offset);

            middle1.transform.position = (arrow1.position + mid) / 2f - dir * offset / 4f;
            middle1.size = midSize;

            middle2.transform.position = (arrow2.position + mid) / 2f + dir * offset / 4f;
            middle2.size = midSize;

            cotationTM.transform.position = mid + textOffset + Perp * decalTextOffset;

            if (!is3D)
            {
                cotationTM.transform.localEulerAngles = -transform.localEulerAngles;
            }

            //cotationTM.characterSize = 0.4f;
            cotationTM.text = approxDist + "";

            if (!isMeasure)
            {
                if (is3D)
                {
                    cotationTM.GetComponent <BoxCollider>().size =
                        new Vector3(Mathf.Clamp(Mathf.Log10(approxDist) * 0.13f, 0f, 2f), 0.18f, 0.1f);
                }
                //cotationTM.transform.Translate(cotationTM.)
                else
                {
                    cotationTM.GetComponent <BoxCollider2D>().size =
                        new Vector2(Mathf.Clamp(Mathf.Log10(approxDist) * 0.1f, 0f, 2f), 0.18f);
                }
            }

            // Scale in function of cam Z in 2D
            if (!is3D)
            {
                cotationTM.transform.localScale =
                    Vector3.one * Mathf.Abs(GlobalManager.Instance.cam2DTop.transform.position.z / 10f);
            }

            // Show cotations ? (from room params)
            if (myElement is Wall)
            {
                var r = WallFunctions.GetRoomsFromWall(myElement as Wall, WallsCreator.Instance.GetRooms());
                if (r.Count > 0)
                {
                    for (var i = 0; i < transform.childCount; i++)
                    {
                        transform.GetChild(i).gameObject
                        .SetActive(transform.GetChild(i).gameObject.activeInHierarchy&& r[0].ShowCotations);
                    }
                }
            }

            // Live Update
            if (Input.GetMouseButtonDown(0))
            {
                GameObject go;
                if (is3D)
                {
                    go = InputFunctions.GetHoveredObject(GlobalManager.Instance.cam3D.GetComponent <Camera>());
                }
                else
                {
                    go = InputFunctions.GetHoveredObject2D(GlobalManager.Instance.cam2DTop.GetComponent <Camera>());
                }
                if (go)
                {
                    if (go == cotationTM.gameObject)
                    {
                        SelectedObjectManager.Instance.SetCurrentCotation(this);
                    }
                }
            }

            // Rotation measure
            if (isMeasure)
            {
                Transform camTrans = GlobalManager.Instance.GetActiveCamera().transform;

                List <Transform> transformList = new List <Transform> {
                    middle1.transform, middle2.transform
                };
                foreach (var _transform in transformList)
                {
                    _transform.LookAt(camTrans);
                    _transform.localEulerAngles = new Vector3(0, _transform.localEulerAngles.y, 180);
                }
            }
        }
Exemplo n.º 26
0
        private void ClickArrow()
        {
            // Press on arrow = select arrow
            if (Input.GetMouseButtonDown(0))
            {
                var go = InputFunctions.GetHoveredObject2D(GlobalManager.Instance.GetActiveCamera());
                if (!go || go.tag != "WallArrow")
                {
                    isMoving = false;
                    return;
                }

                currentArrow = go;
            }

            // Release = no arrow
            if (Input.GetMouseButtonUp(0) && currentArrow != null)
            {
                OperationsBufferScript.Instance.AddAutoSave("Mise à jour mur");
                currentArrow = null;
            }

            // if arrow
            if (currentArrow)
            {
                var proj     = Vector3.zero;
                var mousePos = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());
                if (m_prevPos == mousePos)
                {
                    return;
                }
                switch (currentArrow.name)
                {
                case "P1":
                    if (Input.GetAxis("LibrePoint") > 0)
                    {
                        WallsCreator.Instance.UpdateWallPoint(w, mousePos + w.Direction * m_arrowOffset, true);
                    }
                    else
                    {
                        proj = (Vector3.Project(mousePos - w.P1, w.Direction) + w.P1);
                        WallsCreator.Instance.UpdateWallPoint(w, proj + w.Direction * m_arrowOffset, true);
                    }
                    break;

                case "P2":
                    if (Input.GetAxis("LibrePoint") > 0)
                    {
                        WallsCreator.Instance.UpdateWallPoint(w, mousePos - w.Direction * m_arrowOffset, false);
                    }
                    else
                    {
                        proj = Vector3.Project(mousePos - w.P2, -w.Direction) + w.P2;
                        WallsCreator.Instance.UpdateWallPoint(w, proj - w.Direction * m_arrowOffset, false);
                    }
                    break;

                case "UpPerp":
                    proj        = Vector3.Project(mousePos - w.Center, -w.Perpendicular) + w.Center;
                    w.Thickness = Vector3.Distance(proj, w.Center) * 2f;
                    WallsCreator.Instance.AdjustAllWalls();
                    WallPropPanelScript.Instance.UpdateWallProperties();
                    break;

                case "DownPerp":
                    proj        = Vector3.Project(mousePos - w.Center, w.Perpendicular) + w.Center;
                    w.Thickness = Vector3.Distance(proj, w.Center) * 2f;
                    WallsCreator.Instance.AdjustAllWalls();
                    WallPropPanelScript.Instance.UpdateWallProperties();
                    break;
                }

                currentArrow.transform.position = proj + m_decal;
                isMoving  = true;
                m_prevPos = mousePos;
            }
            else
            {
                isMoving = false;
            }
        }
Exemplo n.º 27
0
        /// <summary>
        ///     Move function. The starting pos is where the users starts clicking,
        ///     so its a kind of offset so the element does not "teleport" its position into mouse but moves smoothly
        /// </summary>
        /// <param name="startingPos">where the users starts clicking</param>
        public virtual void Move(Vector3 startingPos)
        {
            InitVar();

            List <string> tags = new List <string> {
                ""
            };

            if (IsOnWall)
            {
                tags.Add("Wall");
            }
            else
            {
                tags.Add("Ground");
            }
            if (CanBePutOnFurniture)
            {
                tags.Add("Furniture");
            }
            tags.Add("WorkPlane");

            switch (cam.gameObject.layer)
            {
            case (int)ErgoLayers.Top:
                Vector3 pos2D       = InputFunctions.GetWorldPoint(cam);
                Vector3 closestProj = pos2D;

                // If on wall then stick to wall
                if (IsOnWall)
                {
                    //Debug.Log("Sticking...");
                    Wall closestWall = null;
                    // Seek closest projection for a wall
                    foreach (Wall wd in WallsCreator.Instance.GetWalls())
                    {
                        if (closestWall == null)
                        {
                            closestWall = wd;
                            closestProj = Math3d.ProjectPointOnLineSegment(wd.P1, wd.P2, pos2D);
                        }
                        else
                        {
                            Vector3 proj = Math3d.ProjectPointOnLineSegment(wd.P1, wd.P2, pos2D);
                            if (Vector2.Distance(pos2D, proj) < Vector2.Distance(pos2D, closestProj))
                            {
                                closestWall = wd;
                                closestProj = proj;
                            }
                        }
                    }

                    AssociatedElement = closestWall;
                    Vector3 pos33D = VectorFunctions.Switch2D3D(closestProj - closestWall.Thickness * (closestProj - pos2D).normalized) + Position.y * Vector3.up;
                    // Repeat the 3D algo and readapt 2D
                    AdjustCurrentFurnitureWallPos3D(pos33D, closestWall.associated3DObject, startingPos);
                }
                else
                {
                    associated2DObject.transform.position += pos2D - startingPos;

                    if (associated3DObject)
                    {
                        float y = 0;
                        if (CanBePutOnFurniture)
                        {
                            GameObject potentialFurniture = InputFunctions.GetHoveredObject2D
                                                            (
                                cam2d,
                                associated2DObject.name,
                                true
                                                            );

                            if (potentialFurniture)
                            {
                                Furniture f = FurnitureCreator.Instance.GetFurnitureFromGameObject(potentialFurniture);
                                if (f != null)
                                {
                                    y = f.Position.y + f.Size.y;
                                }
                            }
                        }

                        associated2DObject.transform.position = new Vector3
                                                                (
                            associated2DObject.transform.position.x,
                            associated2DObject.transform.position.y, -y / 5f
                                                                );

                        associated3DObject.transform.position = VectorFunctions.Switch2D3D(associated2DObject.transform.position, y);
                    }
                }

                if (text2D)
                {
                    text2D.transform.position = associated2DObject.transform.position;
                }
                break;

            case (int)ErgoLayers.ThreeD:
                Vector3    pos3D         = InputFunctions.GetWorldPoint(cam);
                Vector3    closestProj3D = pos3D;
                GameObject go;

                if (IsOnWall)
                {
                    Vector3 pos33D = InputFunctions.GetWorldPoint(out go, cam, associated3DObject, tags.ToArray());
                    AdjustCurrentFurnitureWallPos3D(pos33D, go, startingPos);
                }
                else
                {
                    if (associated3DObject == null)
                    {
                        return;
                    }

                    //Fix a l'etage l'objet
                    float tmpY = associated3DObject.transform.position.y;
                    associated3DObject.transform.position += pos3D - startingPos;

                    if (associated3DObject)
                    {
                        float y = 0;
                        if (CanBePutOnFurniture)
                        {
                            var potentialFurniture = InputFunctions.GetHoveredObject2D(
                                GlobalManager.Instance.cam2DTop.GetComponent <Camera>(), associated2DObject.name,
                                true);
                            if (potentialFurniture)
                            {
                                var f = FurnitureCreator.Instance.GetFurnitureFromGameObject(potentialFurniture);
                                y = f.Position.y + f.Size.y;
                            }
                        }

                        associated3DObject.transform.position = associated3DObject.transform.position;

                        associated3DObject.transform.position = new Vector3(associated3DObject.transform.position.x, tmpY, associated3DObject.transform.position.z);

                        associated2DObject.transform.position = new Vector3(associated3DObject.transform.position.x, associated3DObject.transform.position.z, associated2DObject.transform.position.z);
                    }
                }
                break;
            }

            if (associated3DObject)
            {
                Position = associated3DObject.transform.position;
            }
            else
            {
                Position = VectorFunctions.Switch2D3D(associated2DObject.transform.position);
            }
        }
Exemplo n.º 28
0
        public override void LoadContent()
        {
            base.LoadContent();

            Game.CurrentGameMode.ClearPlayers();

            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f)));

            //// UI
            //var buttonBackground = new HUDComponent("button_bg", new Vector2(1.2f, 0.2f), offset: new Vector2(0.5f, 0f), origin: new Vector2(0.5f, 0f));

            //AddEntity(new Entity(this, EntityType.UI, buttonBackground,
            //    new HUDTextComponent(MainFont, 0.1f, "Vacamole",
            //        offset: buttonBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)),
            //        origin: new Vector2(0.5f, 0.5f))
            //));

            HUDComponent vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: -0.1f)
            {
                MaintainAspectRation = false,
                OnVirtualUIScreen    = false,
                Color = Color.FromNonPremultiplied(22, 59, 59, 163)
            };
            Vector2      logoSize      = new Vector2(1, 0.7684f);
            HUDComponent logoComponent = new HUDComponent("titleScreen", 0.8f * logoSize, offset: new Vector2(0.5f, 0.1f), origin: new Vector2(0.5f, 0f), layerDepth: -0.1f);

            AddEntity(new Entity(this, EntityType.UI, Vector2.Zero, vignetteComponent, logoComponent));

            mainMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.8f), elementSize: 0.1f, allowAllControllers: true, isHorizontal: true, menuEntries: new[] {
                new HUDListEntity.ListEntry("New Game", OnNewGame),
                new HUDListEntity.ListEntry("Options", (i) => GoToMenuState(MenuState.Options)),
                new HUDListEntity.ListEntry("Controls", (i) => GoToMenuState(MenuState.Controls)),
                new HUDListEntity.ListEntry("Tutorial", OnGoToTutorial),
                new HUDListEntity.ListEntry("Credits", (i) => GoToMenuState(MenuState.Credits)),
                new HUDListEntity.ListEntry("Exit", OnExit)
            })
            {
                Enabled = false, Opacity = 0
            };

            optionsList = new HUDListEntity(this, new Vector2(0.5f, 0.8f), elementSize: 0.15f, allowAllControllers: true, isHorizontal: true, menuEntries: new[] {
                new HUDListEntity.ListEntry($"Master: {GetPercentage(Settings<GameSettings>.Value.MasterVolume)}%", OnMasterVolume),
                new HUDListEntity.ListEntry($"Sound: {GetPercentage(Settings<GameSettings>.Value.SoundVolume)}%", OnSoundVolume),
                new HUDListEntity.ListEntry($"Music: {GetPercentage(Settings<GameSettings>.Value.MusicVolume)}%", OnMusicVolume),
                new HUDListEntity.ListEntry("Back", SaveAndBack)
            })
            {
                Enabled = false, Opacity = 0
            };

            controlInstructionsBackground = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, origin: new Vector2(0.5f, 0.5f), layerDepth: -0.1f)
            {
                MaintainAspectRation = false,
                OnVirtualUIScreen    = false,
                Color   = Color.FromNonPremultiplied(0, 0, 0, 160),
                Opacity = 0
            };
            controlInstructions = new HUDComponent("controls", new Vector2(0.85f, 0.4f), origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0, MaintainAspectRation = true
            };
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.5f), controlInstructionsBackground, controlInstructions));
            AddEntity(mainMenuList);
            AddEntity(optionsList);

            GoToMenuState(MenuState.MainMenu);

            var layerIndependent = new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera));


            // Add controls to hide the controls overlay or the credits overlay (later version)
            for (int i = 0; i < 4; i++)
            {
                layerIndependent.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuSelect(f) || InputFunctions.MenuBack(f), HideControls)));
            }
            layerIndependent.AddComponent(new InputComponent(new InputMapping(f => InputFunctions.KeyboardMenuSelect(f) || InputFunctions.KeyboardMenuBack(f), HideControls)));


            AddEntity(layerIndependent);

            creditsScene = new[] {
                new HUDTextComponent(MainFont, 0.03f, "Credits",
                                     offset: new Vector2(0.5f, 0.1f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
                new HUDTextComponent(MainFont, 0.04f, "Programming",
                                     offset: new Vector2(0.5f, 0.25f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
                new HUDTextComponent(MainFont, 0.06f, "Alexander Kayed\nMoritz Zilian\nFlorian Zinggeler",
                                     offset: new Vector2(0.5f, 0.4f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
                new HUDTextComponent(MainFont, 0.04f, "Art",
                                     offset: new Vector2(0.5f, 0.6f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
                new HUDTextComponent(MainFont, 0.06f, "Sonja Böckler",
                                     offset: new Vector2(0.5f, 0.675f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
                new HUDTextComponent(MainFont, 0.035f, "This game was created during the\nETH Game Programming Laboratory course\nin collaboration with ZHdK",
                                     offset: new Vector2(0.5f, 0.85f),
                                     origin: new Vector2(0.5f, 0.5f))
                {
                    Opacity = 0
                },
            };
            AddEntity(new Entity(this, EntityType.UI, creditsScene));



            this.TransitionIn();
        }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        MCCDAQwrap.flashLED();
        MCCDAQwrap.writeVolts(1, 0.0f);  // Set all voltages to zero
        //Using Random Class
        rndGen = new System.Random();

        xPos   = 0.0f;
        deltaX = 0.0f;

        Counter    = 0;
        daqInput   = 0.0f;
        pertSignal = 0.0f;

        // ******************************* Scene ***********************************
        SceneName = SceneManager.GetActiveScene().name;

        // *******************************    EXPERIMENTS SETUP   *****************************

        bool bVRgui = false;

        if (bVRgui)
        {
            //Load the GUI and wait until its finished
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.WorkingDirectory = "VR_GUI";
            startInfo.FileName         = "VR_GUI.exe";
            Process.Start(startInfo).WaitForExit();

            StreamReader csv_file = new StreamReader(@"VR_GUI\\ExpParams.csv");
            string       legends  = csv_file.ReadLine();
            string       Params   = csv_file.ReadLine();
            csv_file.Close();
            string[] ParamsList = Params.Split(',');

            flagExpNum  = (int)float.Parse(ParamsList[0]); // 0: Normal VR  1: Randomized Half Sinusoidal  2:PRTS    3:TrapZ    4:TrapV   5: Sum of Sins   6: PRBS
            P2P_Amp     = float.Parse(ParamsList[1]);      //deg
            Vel_max     = float.Parse(ParamsList[2]);      //dps
            minDeltaSec = float.Parse(ParamsList[3]);      //Wait Time this is minDelta. delta = minDelta + rand(0, minDelta)
            minWSec     = float.Parse(ParamsList[4]);      //Pulse Width, this is w. W = w + rand(0, w)
            NumPulses   = (int)float.Parse(ParamsList[5]); // or Periods

            Time_0  = float.Parse(ParamsList[6]);          //Start perturbations after this time seconds
            T_total = float.Parse(ParamsList[7]);

            PRTS_dt = float.Parse(ParamsList[8]); //sec

            TrapV_ta = float.Parse(ParamsList[9]);
            TrapV_tv = float.Parse(ParamsList[10]);
            TrapV_tx = float.Parse(ParamsList[11]);

            SOS_minFreq      = float.Parse(ParamsList[12]);
            SOS_maxFreq      = float.Parse(ParamsList[13]);
            SOS_freqCount    = (int)float.Parse(ParamsList[14]);
            Random_Direction = (int)float.Parse(ParamsList[15]);
            dtVR             = Time.fixedDeltaTime; //Time resolution (time per frame) measured for VR device with FixedUpdate() method
        }
        else
        {
            flagExpNum = 4;                    // 0: Normal VR  1: Randomized Half Sinusoidal  2:PRTS    3:TrapZ    4:TrapV   5: Sum of Sins   6: PRBS

            Time_0      = 4.0f;                //Start perturbations after this time seconds
            dtVR        = Time.fixedDeltaTime; //Time resolution (time per frame) measured for VR device with FixedUpdate() method
            P2P_Amp     = 0.14f;               //meter
            Vel_max     = 0.14f;               // m/s
            minDeltaSec = 2.5f;                //Wait Time this is minDelta. delta = minDelta + rand(0, minDelta)
            minWSec     = 2.5f;                //Pulse Width, this is w. W = w + rand(0, w)
            NumPulses   = 10;                  // or Periods

            PRTS_dt = 0.1f;                    //sec

            TrapV_ta = 0.4f;
            TrapV_tv = 0.6f;
            TrapV_tx = 2.5f;

            SOS_minFreq   = 0.05f;
            SOS_maxFreq   = 1.5f;
            SOS_freqCount = 15;
        }

        switch (flagExpNum)
        {
        case 0:     // No purturbation
        {
            logFileName = "Normal";
            PosArray    = new float[(int)Math.Round(T_total / dtVR)];
            Array.Clear(PosArray, 0, PosArray.Length);
            T_total = 200.0f;        //sec
            break;
        }

        case 1:     // *******************  1: Randomized half Sinusoids *********************
        {
            logFileName         = "RandHalfSin";
            RS_RotationVelocity = Mathf.PI / 2;                         // A.Sin(wt) w = Rad per second;  default = pi / 2
            frequency           = RS_RotationVelocity / (2 * Mathf.PI); //v = w/2pi   Hz
            PosArray            = InputFunctions.HalfSin_offline(NumPulses, P2P_Amp, RS_RotationVelocity, minDeltaSec, SceneName, out T_total, dtVR).ToArray();
            P2P_Amp_calc        = P2P_Amp;
            break;
        }

        case 2:     // ***************************  2: PRTS  ********************************
        {
            logFileName  = "PRTS";
            PRTS_dt      = 0.2f;    //sec
            Vel_max      = P2P_Amp / (17.0f * PRTS_dt);
            T_total      = 242 * PRTS_dt * NumPulses;
            PosArray     = InputFunctions.PRTS_offline(NumPulses, PRTS_dt, Vel_max, SceneName, out T_total, dtVR).ToArray();
            P2P_Amp_calc = P2P_Amp;
            Debug.Log(logFileName + " PRTS_dt = " + PRTS_dt + " Seconds");
            break;
        }

        case 3:     // ***************************  2: TrapZ  ********************************
        {
            logFileName  = "TrapZ";
            PosArray     = InputFunctions.TrapZ_offline(NumPulses, P2P_Amp, Vel_max, minDeltaSec, minWSec, SceneName, out T_total, dtVR).ToArray();
            P2P_Amp_calc = P2P_Amp;;
            break;
        }

        case 4:     // *************************   4: TrapV   ********************************
        {
            logFileName  = "TrapV";
            PosArray     = InputFunctions.TrapV_offline(NumPulses, minDeltaSec, TrapV_ta, TrapV_tv, TrapV_tx, Vel_max, SceneName, out T_total, dtVR).ToArray();
            P2P_Amp_calc = Vel_max * (TrapV_ta + TrapV_tv);
            Debug.Log(" TrapV Times: ta = " + TrapV_ta + " t_v = " + TrapV_tv + " t_x = " + TrapV_tx);
            break;
        }

        case 5:     // *************************  5: SumOfSin  *******************************
        {
            logFileName   = "SumOfSin";
            SOS_minFreq   = 0.05f;
            SOS_maxFreq   = 0.15f;
            SOS_freqCount = 1;
            PosArray      = InputFunctions.SumOfSin_offline(NumPulses, P2P_Amp, SOS_minFreq, SOS_maxFreq, SOS_freqCount, SceneName, out T_total, dtVR).ToArray();
            P2P_Amp_calc  = P2P_Amp;;
            break;
        }

        case 6:     // *************************  5: PRBS  *******************************
        {
            logFileName  = "PRBS";
            T_total      = 10.0f;    //seconds
            PosArray     = InputFunctions.PRBS_offline(P2P_Amp, 0.5f, T_total, SceneName, dtVR).ToArray();
            P2P_Amp_calc = P2P_Amp;;
            break;
        }
        }

        Time_F  = Time_0 + T_total;
        Pos_max = PosArray.Max();
        Pos_min = PosArray.Min();

        Debug.Log(logFileName + " P2P_Amp_calc = " + P2P_Amp_calc + " meters");
        Debug.Log(logFileName + " Vel_max = " + Vel_max + " mps");
        Debug.Log(logFileName + " Time Total = " + T_total + " seconds");


        // *******************   Write to file   *******************
        dt         = DateTime.Now;
        dateString = dt.ToString("dd-MM-yyyy");
        timeString = dt.ToString("HH-mm");
        string logDir     = "log/Online/" + dateString + "/" + SceneName + "/" + logFileName;
        string currentDir = Directory.GetCurrentDirectory();
        string logPath    = Path.Combine(currentDir, logDir);

        Directory.CreateDirectory(logPath);
        dataLogger    = new StreamWriter(logPath + "/VR_" + logFileName + '_' + timeString + ".txt");
        timeLog       = new StreamWriter(logPath + "/Time_" + logFileName + '_' + timeString + ".txt");
        daqSignal     = new StreamWriter(logPath + "/daq_" + logFileName + '_' + timeString + ".txt");
        headMotionLog = new StreamWriter(logPath + "/HeadMotion_" + logFileName + '_' + timeString + ".txt");
    }
Exemplo n.º 30
0
        /// <summary>
        ///     Main method, called when the users stars dragging one of the buttons
        /// </summary>
        private void ClickArrow()
        {
            var me = SelectedObjectManager.Instance.currentSelectedElements.First() as MovableElement;

            // Press on arrow = select arrow
            if (InputFunctions.IsClickingOutsideUI())
            {
                var go = InputFunctions.GetHoveredObject2D(GlobalManager.Instance.GetActiveCamera());
                // Debug.Log("CLICK ARROW " + go);
                if (!go || go.tag != "ElementArrow")
                {
                    isMoving = false;
                    return;
                }

                currentArrow = go;
            }

            // Release = no arrow
            if (Input.GetMouseButtonUp(0) && currentArrow != null)
            {
                currentArrow = null;
                OperationsBufferScript.Instance.AddAutoSave("Etirement");
            }

            // if arrow
            if (currentArrow)
            {
                var   proj      = Vector3.zero;
                var   dif       = Vector3.zero;
                var   sizeCompo = Vector3.zero;
                float dist      = 0;
                var   direction = Vector3.zero;
                var   mousePos  = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera());
                if (m_prevPos == mousePos)
                {
                    return;
                }
                //Debug.Log("FLECHE " + currentArrow.name);
                switch (currentArrow.name)
                {
                case "Up":
                    direction = me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oUp, direction) + oUp;
                    dif       = proj - oUp;
                    dist      = Vector3.Distance(proj, oUp);
                    sizeCompo = Vector3.up;
                    break;

                case "Down":
                    direction = -me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oDown, direction) + oDown;
                    dif       = proj - oDown;
                    dist      = Vector3.Distance(proj, oDown);
                    sizeCompo = Vector3.up;
                    break;

                case "Left":
                    direction = -me.associated2DObject.transform.right;
                    proj      = Vector3.Project(mousePos - oLeft, direction) + oLeft;
                    dif       = proj - oLeft;
                    dist      = Vector3.Distance(proj, oLeft);
                    sizeCompo = Vector3.right;
                    break;

                case "Right":
                    direction = me.associated2DObject.transform.right;
                    proj      = Vector3.Project(mousePos - oRight, direction) + oRight;
                    dif       = proj - oRight;
                    dist      = Vector3.Distance(proj, oRight);
                    sizeCompo = Vector3.right;
                    break;

                case "UpLeft":
                    direction = -me.associated2DObject.transform.right + me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oUpLeft, direction) + oUpLeft;
                    dif       = proj - oUpLeft;
                    dist      = Vector3.Distance(proj, oUpLeft);
                    sizeCompo = Vector3.up + Vector3.right;
                    break;

                case "UpRight":
                    direction = me.associated2DObject.transform.right + me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oUpRight, direction) + oUpRight;
                    dif       = proj - oUpRight;
                    dist      = Vector3.Distance(proj, oUpRight);
                    sizeCompo = Vector3.up + Vector3.right;
                    break;

                case "DownLeft":
                    direction = -me.associated2DObject.transform.right - me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oDownLeft, direction) + oDownLeft;
                    dif       = proj - oDownLeft;
                    dist      = Vector3.Distance(proj, oDownLeft);
                    sizeCompo = Vector3.up + Vector3.right;
                    break;

                case "DownRight":
                    direction = me.associated2DObject.transform.right - me.associated2DObject.transform.up;
                    proj      = Vector3.Project(mousePos - oDownRight, direction) + oDownRight;
                    dif       = proj - oDownRight;
                    dist      = Vector3.Distance(proj, oDownRight);
                    sizeCompo = Vector3.up + Vector3.right;
                    break;
                }

                SetSizeCompoAndDirection(dif, direction, sizeCompo, out direction, out sizeCompo);
                me.SetPosition(me.Position + VectorFunctions.Switch2D3D(dist * direction / 4f));
                me.SetSize(me.Size + VectorFunctions.Switch2D3D(dist * sizeCompo / 2f));
                if (me is Furniture)
                {
                    (me as Furniture).AdjustSpriteSize();
                }
                currentArrow.transform.position =
                    new Vector3(proj.x, proj.y, me.associated2DObject.transform.position.z);
                isMoving  = true;
                m_prevPos = proj;
                FurniturePropScript.Instance.UpdateFurnitureProperties();
            }
            else
            {
                isMoving = false;
            }
        }