public async Task <IActionResult> Edit(int id, MainDirection mainDirection)
        {
            if (id != mainDirection.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mainDirection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MainDirectionExists(mainDirection.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainDirection));
        }
Example #2
0
    //Called by the Controls.cs script. When a player presses their movement keys, it calls this function
    //sending over a "y" value, set to either 1 or 0, depending if they are moving forward or backwards.
    public void Move(float y)
    {
        if (rig == null)
        {
            rig = GetComponent <Rigidbody2D>();
            if (rig == null)
            {
                rig = gameObject.AddComponent <Rigidbody2D>();
            }
        }

        rig.velocity = Vector2.zero;

        Vector3 moveVector = Vector3.zero;

        //Vector3 moveVector = direction * y * moveSpeed;

        CheckIfCollidersStillHitting(moveVector);

        if (!(isCollidedTop || isCollidedBot || isCollidedRight || isCollidedLeft))
        {
            transform.position += moveVector;
        }
        else
        {
            MainDirection movementDirection = GetDirection(moveVector);
            moveVector = GetMovementAdjustment(moveVector, movementDirection);

            transform.position += moveVector;
        }
    }
        public async Task <IActionResult> Create(MainDirection mainDirection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mainDirection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainDirection));
        }
 public string Serialize()
 {
     return(Type.ToString() + MainDirection.ToString("d") + SocketUp.ToString("d") +
            SocketRight.ToString("d") + SocketDown.ToString("d") + SocketLeft.ToString("d") +
            Capacity.ToString() + (IsMain ? "1" : "0"));
 }
Example #5
0
 public CreateCone(String path, Vec3 position, int radius, int height, MainDirection AxisDirection) :
     base("createCone('" + path + "', " + position.ToIPhysicsString() + ", " + radius.ToString() + ", " + height.ToString() + ", " + ((int)AxisDirection).ToString() + ")")
 {
 }
Example #6
0
    private Vector3 GetMovementAdjustment(Vector3 moveVector, MainDirection movementDirection)
    {
        Vector3 retVector = moveVector;

        switch (movementDirection)
        {
        case MainDirection.NULL:
            retVector = Vector3.zero;
            break;

        case MainDirection.Top:
            if (isCollidedTop)
            {
                retVector = Vector3.zero;
            }
            break;

        case MainDirection.Bottom:
            if (isCollidedBot)
            {
                retVector = Vector3.zero;
            }
            break;

        case MainDirection.Right:
            if (isCollidedRight)
            {
                retVector = Vector3.zero;
            }
            break;

        case MainDirection.Left:
            if (isCollidedLeft)
            {
                retVector = Vector3.zero;
            }
            break;

        case MainDirection.TopRight:
            if (isCollidedTop && isCollidedRight)
            {
                retVector = Vector3.zero;
            }
            else if (isCollidedTop)
            {
                retVector.y = 0;     // -0; // 0.01f;
            }
            else if (isCollidedRight)
            {
                retVector.x = 0;     // -0; // 0.01f;
            }
            break;

        case MainDirection.TopLeft:
            if (isCollidedTop && isCollidedLeft)
            {
                retVector = Vector3.zero;
            }
            else if (isCollidedTop)
            {
                retVector.y = 0;     // -0; // 0.01f;
            }
            else if (isCollidedLeft)
            {
                retVector.x = 0;     // 0.01f;
            }
            break;

        case MainDirection.BottomRight:
            if (isCollidedBot && isCollidedRight)
            {
                retVector = Vector3.zero;
            }
            else if (isCollidedBot)
            {
                retVector.y = 0;     // 0.01f;
            }
            else if (isCollidedRight)
            {
                retVector.x = 0;     // -0; // 0.01f;
            }
            break;

        case MainDirection.BottomLeft:
            if (isCollidedBot && isCollidedLeft)
            {
                retVector = Vector3.zero;
            }
            else if (isCollidedBot)
            {
                retVector.y = 0;     // 0.01f;
            }
            else if (isCollidedLeft)
            {
                retVector.x = 0;     // 0.01f;
            }
            break;
        }

        /*if (retVector != moveVector)
         *  ResetCollisions();*/

        retVector.z = 0;
        return(retVector);
    }