Beispiel #1
0
        public void ChangeCommandText(Enumerations.Action command)
        {
            switch (commandLine)
            {
            case 1:
                Input1.enabled = true;
                Input1.text    = command.ToString();
                commandLine++;
                break;

            case 2:
                Input2.enabled = true;
                Input2.text    = command.ToString();
                commandLine++;
                break;

            case 3:
                Input3.enabled = true;
                Input3.text    = command.ToString();
                commandLine++;
                break;

            case 4:
                Input4.enabled = true;
                Input4.text    = command.ToString();
                commandLine++;
                break;

            case 5:
                Input5.enabled = true;
                Input5.text    = command.ToString();
                commandLine    = 1;
                break;
            }
        }
Beispiel #2
0
 public void RpcDisplayCommand(Enumerations.Action action)
 {
     if (isLocalPlayer)
     {
         PlayerState.DisplayCommands(action);
     }
 }
Beispiel #3
0
        public void ServerAddActionToList(PlayerMovement playerMovement, Enumerations.Action action)
        {
            if (Actions[playerMovement.Id].Count < 4)
            {
                Actions[playerMovement.Id].Add(action);
                playerMovement.RpcDisplayCommand(action);
            }
            else if (Actions[playerMovement.Id].Count < 5)
            {
                Actions[playerMovement.Id].Add(action);

                ServerPlayerReady(playerMovement.Id);
                playerMovement.RpcDisplayCommand(action);
            }
        }
Beispiel #4
0
        public void RpcAnimate(Enumerations.Action action)
        {
            if (!isLocalPlayer)
            {
                return;
            }

            switch (action)
            {
            case Enumerations.Action.TurnRight:
                _animator.SetInteger("TurnIndex", 2);
                _animator.SetTrigger("Turn");

                GetComponent <NetworkAnimator>().SetTrigger("Turn");
                break;

            case Enumerations.Action.TurnLeft:
                _animator.SetInteger("TurnIndex", 1);
                _animator.SetTrigger("Turn");

                GetComponent <NetworkAnimator>().SetTrigger("Turn");
                break;

            case Enumerations.Action.Reverse:
                transform.Translate(-Vector3.forward);
                break;

            case Enumerations.Action.ShortMove:
                //transform.Translate(Vector3.forward);
                _animator.SetTrigger("WalkForward");
                GetComponent <NetworkAnimator>().SetTrigger("WalkForward");
                break;

            case Enumerations.Action.LongMove:
                //transform.Translate(Vector3.forward * 3);
                _animator.SetTrigger("SprintForward");
                GetComponent <NetworkAnimator>().SetTrigger("SprintForward");
                break;

            case Enumerations.Action.Shoot:
                _animator.SetTrigger("Fire");
                CmdSetNetworkTriggers("Fire");
                break;

            default:
                throw new ArgumentOutOfRangeException("action", action, null);
            }
        }
Beispiel #5
0
        public void RpcResolveCommands(Enumerations.Action action, int numberOfAction)
        {
            if (!isLocalPlayer)
            {
                return;
            }

            if (action == (Enumerations.Action.Shoot))
            {
                CmdFire();
            }
            else if (action != Enumerations.Action.Shoot)
            {
                DoAction(action);
            }

            PlayerState.DisplayActiveCommand(numberOfAction);
        }
 public IActionResult IsAuthorizedToPerformActionOnResource(Guid resourceId, int userId, string actionType)
 {
     try
     {
         Enumerations.Action action = Enum.Parse <Enumerations.Action>(actionType);
         InitializeResources();
         #region Input Validations
         // Check whether resource exists or not
         Resource resource = _resources.Where(x => x.ResourceId == resourceId).FirstOrDefault();
         if (resource == null)
         {
             return(StatusCode(400, "Invalid Resource"));
         }
         // Check whether the user exists or not
         User user = _users.Where(x => x.UserId == userId).FirstOrDefault();
         if (user == null)
         {
             return(StatusCode(400, "Invalid user"));
         }
         #endregion
         // Gets the user role entry for the passed userid and role id
         UserRole rolesForCurrentUser = resource.ResourceUserRoles.Where(x => x.User.UserId == user.UserId).FirstOrDefault();
         if (rolesForCurrentUser == null)
         {
             return(StatusCode(403, "User doesn't have the required roles to perform this action"));
         }
         foreach (var curRole in rolesForCurrentUser.Roles)
         {
             // If any of the user roles contains that action then return authorized
             if (curRole.RoleActions.Contains(action))
             {
                 // User is authorized to perform action
                 return(Ok("Success!"));
             }
         }
         return(StatusCode(403, "User doesn't have the required roles to perform this action"));
     }
     catch (Exception)
     {
         // Log exception
         return(StatusCode(500));
     }
 }
Beispiel #7
0
        public void DoAction(Enumerations.Action action)
        {
            Debug.Log("Player " + Id + " Do action " + action);

            //RpcAnimate(action);

            switch (action)
            {
            case Enumerations.Action.TurnRight:
                //_animator.SetTrigger("Turn");
                //transform.RotateAround(transform.position, transform.up, 90);

                break;

            case Enumerations.Action.TurnLeft:
                //transform.RotateAround(transform.position, transform.up, -90);

                break;

            case Enumerations.Action.Reverse:

                break;

            case Enumerations.Action.ShortMove:

                break;

            case Enumerations.Action.LongMove:

                break;

            case Enumerations.Action.Shoot:
                CmdFire();
                break;

            default:
                throw new ArgumentOutOfRangeException("action", action, null);
            }
        }
Beispiel #8
0
 public void DisplayCommands(Enumerations.Action action)
 {
     UIManager.ChangeCommandText(action);
 }
Beispiel #9
0
 public void CmdAddActionToList(Enumerations.Action action)
 {
     _gameManager.ServerAddActionToList(this, action);
 }