public void ceaseAttack()
 {
     Debug.Log("ceasing");
     attacking = false;
     attackTimer = 0.0f;
     useCase = UseCase.wander;
 }
Esempio n. 2
0
        public ActionResult Create(int projectId, UseCase useCase)
        {
            var project = _projectRepository.GetNullableById(projectId);

            if (project == null)
            {
                Message = string.Format(Messages.NotFound, "Project", projectId);
                return this.RedirectToAction<ProjectController>(a => a.Index());
            }

            // validate access
            var redirect = _accessValidator.CheckReadAccess(CurrentUser.Identity.Name, project);
            if (redirect != null)
            {
                Message = "Not authorized to edit project.";
                return redirect;
            }

            var newUseCase = new UseCase(){Project = project};
            TransferValues(useCase, newUseCase);
            newUseCase.UseCaseId = string.Format("U{0}", project.UseCases.Count + 1);

            if (project.UseCases.Count > 0)
            {
                // set the task id
                // get the highest use case id
                var uid = project.UseCases.Select(a => a.Id).Max();
                var maxId = project.UseCases.Where(a => a.Id == uid).Select(a => a.UseCaseId).FirstOrDefault();
                // parse the int
                var mid = maxId.Substring(1, maxId.Length - 1);
                newUseCase.UseCaseId = string.Format("T{0}", Convert.ToInt32(mid) + 1);
            }
            else
            {
                newUseCase.UseCaseId = "U1";
            }

            ModelState.Clear();
            newUseCase.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _useCaseRepository.EnsurePersistent(newUseCase);

                Message = "UseCase Created Successfully";

                return RedirectToAction("Index", new {id=projectId});
            }

            var viewModel = UseCaseViewModel.Create(Repository, project);
            viewModel.UseCase = useCase;

            return View(viewModel);
        }
Esempio n. 3
0
        private void TransferValues(UseCase src, UseCase dest)
        {
            if (src.UseCaseSteps == null) src.UseCaseSteps = new List<UseCaseStep>();
            if (src.Preconditions == null) src.Preconditions = new List<UseCasePrecondition>();
            if (src.Postconditions == null) src.Postconditions = new List<UseCasePostcondition>();

            // update the values
            AutoMapper.Mapper.Map(src, dest);

            ReconcileSteps(src, dest);

            ReconcilePreconditions(src, dest);

            ReconcilePostconditions(src, dest);
        }
Esempio n. 4
0
        public async Task ItReturnsFoundAsset()
        {
            Asset returnedAsset = await UseCase.Execute(AssetId);

            Assert.True(returnedAsset.Name == AssetName);
        }
Esempio n. 5
0
        private void ReconcilePreconditions(UseCase src, UseCase dest)
        {
            // delete any use cases that are no more
            var deletes = dest.Preconditions.Where(a => !src.Preconditions.Select(b => b.Id).Contains(a.Id)).Select(a => a.Id).ToList();
            foreach (var preconditionId in deletes)
            {
                var precondition = dest.Preconditions.Where(a => a.Id == preconditionId).FirstOrDefault();
                dest.Preconditions.Remove(precondition);
            }

            foreach (var precondition in src.Preconditions)
            {
                if (precondition.Id == 0)
                {
                    dest.AddPrecondition(precondition);
                }
                else
                {
                    var existingPrecondition = dest.Preconditions.Where(a => a.Id == precondition.Id).FirstOrDefault();

                    if (existingPrecondition != null)
                    {
                        existingPrecondition.Description = precondition.Description;
                    }
                }

            }
        }
Esempio n. 6
0
        private void ReconcileSteps(UseCase src, UseCase dest)
        {
            // delete any use cases that are no longer
            var deletes = dest.UseCaseSteps.Where(a => !src.UseCaseSteps.Select(b => b.Id).Contains(a.Id)).Select(a => a.Id).ToList();
            foreach (var stepId in deletes)
            {
                var step = dest.UseCaseSteps.Where(a => a.Id == stepId).FirstOrDefault();
                dest.UseCaseSteps.Remove(step);
            }

            // update the list of steps
            foreach (var step in src.UseCaseSteps)
            {
                // new step
                if (step.Id == 0)
                {
                    dest.AddStep(step);
                }
                // editing an existing step
                else
                {
                    var existingStep = dest.UseCaseSteps.Where(a => a.Id == step.Id).FirstOrDefault();

                    if (existingStep != null)
                    {
                        AutoMapper.Mapper.Map(step, existingStep);
                    }
                }
            }
        }
Esempio n. 7
0
        public ActionResult Delete(int id, UseCase useCase)
        {
            var useCaseToDelete = _useCaseRepository.GetNullableById(id);

            if (useCaseToDelete == null) return RedirectToAction("Index");

            var projectId = useCaseToDelete.Project.Id;

            _useCaseRepository.Remove(useCaseToDelete);

            Message = "UseCase Removed Successfully";

            return this.RedirectToAction(a => a.Index(projectId));
        }
Esempio n. 8
0
        public ActionResult Edit(int id, UseCase useCase)
        {
            var useCaseToEdit = _useCaseRepository.GetNullableById(id);

            if (useCaseToEdit == null) return RedirectToAction("Index");

            // validate access
            var redirect = _accessValidator.CheckReadAccess(CurrentUser.Identity.Name, useCaseToEdit.Project);
            if (redirect != null)
            {
                Message = "Not authorized to edit project.";
                return redirect;
            }

            TransferValues(useCase, useCaseToEdit);

            ModelState.Clear();
            useCaseToEdit.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _useCaseRepository.EnsurePersistent(useCaseToEdit);

                Message = "UseCase Edited Successfully";

                return this.RedirectToAction(a => a.Index(useCaseToEdit.Project.Id));
            }

            var viewModel = UseCaseViewModel.Create(Repository, useCaseToEdit.Project);
            viewModel.UseCase = useCase;

            return View(viewModel);
        }
    // Update is called once per frame
    void Update()
    {
        if (attacking) {
            //Debug.Log(attacking);
            //updateAttack();
            if (attackTimer == 0.0f) {
                animator.SetTrigger("attack");
                Debug.Log("attack");
                // decrease player health
                PlayerController.takeDamage(1);
            }
            Debug.Log(attackTimer);
            if (attackTimer < attackDelay) attackTimer += Time.deltaTime;
            if (attackTimer >= attackDelay) attackTimer = 0.0f;
        }
        else {
            if (useCase == UseCase.wander
                && (Mathf.Abs(transform.position.x - player.transform.position.x) < seekRadius)
                && Mathf.Abs(transform.position.y - player.transform.position.y) < 1f)  {
                useCase = UseCase.seek;
            }else{
                useCase = UseCase.wander;
            }
            updateMovement();
        }

        // Will randomly play animal's sound effect
        int randomValue = rand.Next(100);
        if (randomValue < 1) {
            if (!source.isPlaying){
                source.Play();
            }
        }
    }
Esempio n. 10
0
 /// <summary>
 /// Clears the graph view
 /// </summary>
 public void ClearGraph()
 {
     this.useCase = null;
 }
Esempio n. 11
0
 async Task Setup()
 {
     await UseCase.Execute(AssetId);
 }
Esempio n. 12
0
        private PdfPCell BuildUseCaseTable(UseCase useCase)
        {
            // set variables for current cells in this table
            var padding = 5;
            var border = 0;

            // table for each of the use cases now
            var useCaseTable = new PdfPTable(1);
            useCaseTable.TotalWidth = _pageWidth;
            useCaseTable.LockedWidth = true;
            useCaseTable.KeepTogether = true;
            useCaseTable.SplitLate = false;

            var nameCell = CreateCell(chunk: new Chunk(string.Format("{0} ({1})",useCase.Name, useCase.UseCaseId), _sectionHeaderFont), paddingAll: padding, borderBottom:1);
            nameCell.BorderColorBottom = _baseColor;

            var descriptionCell = CreateCell(paddingAll: padding, borderAll: border);
            descriptionCell.AddElement(new Paragraph("Description", _sectionHeaderFont));
            descriptionCell.AddElement(new Paragraph(useCase.Description, _font));

            var rolesCell = CreateCell(paddingAll: padding, borderAll: border);
            rolesCell.AddElement(new Paragraph("Roles", _sectionHeaderFont));
            rolesCell.AddElement(new Paragraph(useCase.Roles, _font));

            // preconditions
            var preconditions = new List<HtmlElement>();
            preconditions.Add(new HtmlElement("ul", true));

            foreach (var a in useCase.Preconditions)
            {
                // opening li
                preconditions.Add(new HtmlElement("li", true));

                // put in the txt
                preconditions.Add(new HtmlElement(a.Description));

                // closing li
                preconditions.Add(new HtmlElement("li", true, true));
            }

            // close the list
            preconditions.Add(new HtmlElement("ul", true, true));

            // create the cell
            var preconditionCell = CreateCell(paddingAll: padding, borderAll: border);
            preconditionCell.AddElement(new Paragraph("Preconditions", _sectionHeaderFont));
            BuildListObject(preconditions, "ul", preconditionCell);

            // postconditions
            var postconditions = new List<HtmlElement>();
            postconditions.Add(new HtmlElement("ul", true));

            foreach (var a in useCase.Postconditions)
            {
                // opening li
                postconditions.Add(new HtmlElement("li", true));

                // put in the txt
                postconditions.Add(new HtmlElement(a.Description));

                // closing li
                postconditions.Add(new HtmlElement("li", true, true));
            }

            // close the list
            postconditions.Add(new HtmlElement("ul", true, true));

            // create the cell
            var postconditionCell = CreateCell(paddingAll: padding, borderAll: border);
            postconditionCell.AddElement(new Paragraph("Postconditions", _sectionHeaderFont));
            BuildListObject(postconditions, "ul", postconditionCell);

            // steps
            var steps = new List<HtmlElement>();
            steps.Add(new HtmlElement("ol", true));

            foreach (var a in useCase.UseCaseSteps.OrderBy(b => b.Order))
            {
                steps.Add(new HtmlElement("li", true));

                if (a.Optional)
                {
                    steps.Add(new HtmlElement(string.Format("{0}*", a.Description)));
                }
                else
                {
                    steps.Add(new HtmlElement(a.Description));
                }

                steps.Add(new HtmlElement("li", true, true));
            }

            // close the list
            steps.Add(new HtmlElement("ol", true, true));

            // create the cell
            var stepsCell = CreateCell(paddingAll: padding, borderAll: border);
            stepsCell.AddElement(new Paragraph("Steps", _sectionHeaderFont));
            BuildListObject(steps, "ol", stepsCell);
            stepsCell.PaddingBottom = 15;

            useCaseTable.AddCell(nameCell);
            useCaseTable.AddCell(descriptionCell);
            useCaseTable.AddCell(rolesCell);
            useCaseTable.AddCell(preconditionCell);
            useCaseTable.AddCell(postconditionCell);
            useCaseTable.AddCell(stepsCell);

            var cell = CreateCell();
            cell.AddElement(useCaseTable);
            return cell;
        }
 static public LedgerUseCases UseCaseInteractor()
 {
     return(UseCase.CreateInstance <LedgerUseCases>());
 }
Esempio n. 14
0
 public async Task <ActionResult <UseCaseResult <JobModel> > > Post([FromBody] RequestQuote request)
 {
     return(Ok(await UseCase.Execute(request)));
 }
Esempio n. 15
0
 /// <summary>
 /// Adds a graph layout constraint
 /// </summary>
 /// <param name="n1">id node 1</param>
 /// <param name="n2">id node 2</param>
 /// <param name="node1">node object 1</param>
 /// <param name="node2">node object 2</param>
 /// <param name="graph">graph object</param>
 /// <param name="useCase">use case object</param>
 private void AddLayerConstraint(int n1, int n2, Microsoft.Msagl.Drawing.Node node1, Microsoft.Msagl.Drawing.Node node2, Microsoft.Msagl.Drawing.Graph graph, UseCase useCase)
 {
     if (useCase.Nodes[n1].Identifier.Id == useCase.Nodes[n2].Identifier.Id &&
         useCase.Nodes[n1].Identifier.Type == FlowType.Basic &&
         useCase.Nodes[n2].Identifier.Type == FlowType.Basic &&
         n1 < n2)
     {
         graph.LayerConstraints.AddSequenceOfUpDownVerticalConstraint(node1, node2);
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Displays the edge condition
 /// </summary>
 /// <param name="n1">id node 1</param>
 /// <param name="n2">id node 2</param>
 /// <param name="node1">node object 1</param>
 /// <param name="node2">node object 2</param>
 /// <param name="edge">edge object</param>
 /// <param name="useCase">use case object</param>
 private void DisplayEdgeCondition(int n1, int n2, Microsoft.Msagl.Drawing.Node node1, Microsoft.Msagl.Drawing.Node node2, Microsoft.Msagl.Drawing.Edge edge, UseCase useCase)
 {
     UseCaseCore.UcIntern.Condition condition = useCase.ConditionMatrix[n1, n2] ?? new UseCaseCore.UcIntern.Condition();
     if (this.displayGraphConditions && condition.ConditionText != null)
     {
         edge.LabelText       = condition.ConditionText + " is " + condition.ConditionState;
         edge.Label.FontSize  = node1.Label.FontSize / 2;
         edge.Label.FontColor = node1.Attr.FillColor;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// returns true if both nodes are connected
 /// </summary>
 /// <param name="nodeId1">the id of node 1</param>
 /// <param name="nodeId2">the id of node 2</param>
 /// <param name="useCase">the use case object</param>
 /// <returns>true, if both nodes are connected</returns>
 private static bool IsConnected(int nodeId1, int nodeId2, UseCase useCase)
 {
     return(useCase.EdgeMatrix[nodeId1, nodeId2]);
 }
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     animator = GetComponent<Animator>();
     facingLeft = true;
     startPos = transform.position;
     attacking = false;
     useCase = UseCase.wander;
     source = GetComponent<AudioSource>();
 }
Esempio n. 19
0
 public InvoiceController(UseCase <GetInvoiceByCodeRequest, GetInvoiceByCodeResponse> getByCodeUseCase)
 {
     _getByCodeUseCase = getByCodeUseCase;
 }
 public async Task <ActionResult <UseCaseResult <IEnumerable <BusinessServiceModel> > > > Get()
 {
     return(Ok(await UseCase.Execute(new GetBusinessServicesList())));
 }
Esempio n. 21
0
 public IUseCasesSetup AddUseCase(UseCase <UseCaseRequestMessage, UseCaseResponseMessage> useCase, IUseCaseOptions useCaseOptions)
 {
     _useCaseConfiguration.Add(useCase.GetType().FullName, useCaseOptions);
     return(this);
 }