public void InteractionHappened(StepObject obj)
    {
        for (int i = 0; i < activeRecipes.Length; i++)
        {
            Recipe currentRecipe     = activeRecipesClones[i];
            Step   currentRecipeStep = currentRecipe.steps[currentRecipe.currentStep - 1];

            print("currentRecipeStep" + currentRecipe.currentStep);
            bool currentRecipeStepSuccessful =
                StepHandler.Instance.PlacedStepObjectSuccesfully
                    (obj, currentRecipeStep);

            if (currentRecipeStepSuccessful)
            {
                print("did it");
                RecipeTemplateHandler.Instance.stepAnimators[i].SetStepIsFinished(true, currentRecipe.currentStep - 1);
                currentRecipe.currentStep++;
            }
            if (currentRecipe.currentStep > currentRecipe.steps.Length)
            {
                currentRecipe.isFinished = true;
            }

            if (currentRecipe.isFinished)
            {
                print("swapping");
                SwapWithNew(i, obj.gameObject);
            }
        }
    }
Example #2
0
        public long UpdateStep(StepObject step)
        {
            try
            {
                if (step == null)
                {
                    return(-2);
                }

                var stepEntity = ModelMapper.Map <StepObject, Step>(step);
                if (stepEntity == null || stepEntity.Id < 1)
                {
                    return(-2);
                }

                using (var db = new ImportPermitEntities())
                {
                    db.Steps.Attach(stepEntity);
                    db.Entry(stepEntity).State = EntityState.Modified;
                    db.SaveChanges();
                    return(step.Id);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        StepObject myTarget = (StepObject)target;

        //get all the steps
        List <string> stepsName = new List <string>(Utility.getProgressionSteps().getSteps());

        stepsName.Add("Add new step");

        //display all the steps and let the player select one
        int tmpSelect = EditorGUILayout.Popup("Listened step", Utility.getProgressionSteps().getSteps().IndexOf(myTarget.getListenedStep()), stepsName.ToArray());

        //if "Add new step" is selected
        if (tmpSelect == stepsName.Count - 1)
        {
            AddStepWindow.showWindow();
        }
        else
        {
            //set the listenedStep depending on the selectedIndex
            myTarget.setListenedStep(Utility.getProgressionSteps().getSteps()[tmpSelect]);
            Undo.RegisterUndo(myTarget, "Change listened step");
        }
    }
Example #4
0
        public ActionResult EditStep(StepObject step)
        {
            var gVal = new GenericValidator();

            try
            {
                //if (!ModelState.IsValid)
                //{
                //    gVal.Code = -1;
                //    gVal.Error = "Plese provide all required fields and try again.";
                //    return Json(gVal, JsonRequestBehavior.AllowGet);
                //}

                if (string.IsNullOrEmpty(step.Name.Trim()))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide Step.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_Step"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldStep = Session["_Step"] as StepObject;

                if (oldStep == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                oldStep.Name = step.Name.Trim();

                var docStatus = new StepServices().UpdateStep(oldStep);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Step information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldStep.Id;
                gVal.Error = "Step information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Step information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Example #5
0
    // Start is called before the first frame update
    void Start()
    {
        StepObject obj  = GameObject.Find("Screwdriver").GetComponent <StepObject>();
        StepObject obj2 = GameObject.Find("Wire").GetComponent <StepObject>();
        StepObject obj3 = GameObject.Find("Hairdrier").GetComponent <StepObject>();


        StepHandler.Instance.PlacedStepObjectSuccesfully(obj, testRecipe.firstStep);
        StepHandler.Instance.PlacedStepObjectSuccesfully(obj2, testRecipe.firstStep);
        StepHandler.Instance.PlacedStepObjectSuccesfully(obj3, testRecipe.firstStep);
    }
Example #6
0
 public long UpdateStep(StepObject step)
 {
     try
     {
         return(_stepManager.UpdateStep(step));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Example #7
0
        /// <summary>
        /// 随机音效
        /// </summary>
        /// <param name="footStepObject"></param>
        public void PlayRamdom(StepObject StepObject = null)
        {
            if (audioClips == null || audioClips.Count == 0)
            {
                return;
            }
            GameObject audioObject = null;

            if (audioSource != null)
            {
                if (StepObject != null)
                {
                    audioObject = GameObject.Instantiate(audioSource.gameObject, StepObject.sender.position, Quaternion.identity) as GameObject;
                }
                else
                {
                    audioObject = GameObject.Instantiate(audioSource.gameObject) as GameObject;
                }
            }
            else
            {
                audioObject = new GameObject("AudioSource");
                if (StepObject != null)
                {
                    audioObject.transform.position = StepObject.sender.position;
                }
            }

            var source = audioObject.AddComponent <AudioControl>();

            if (audioMixerGroup != null)
            {
                source.SetAudioMixerGroup = audioMixerGroup;
            }

            if (particleObject != null && particleObject.Count > 0)
            {
                for (int i = 0; i < particleObject.Count; ++i)
                {
                    var particle = GameObject.Instantiate(particleObject[i], StepObject.sender.position, Quaternion.identity) as GameObject;
                }
            }

            int randomIndex = fisherRandom.GetRandomNumber(audioClips.Count);

            source.PlayOneShot(audioClips[randomIndex]);
        }
Example #8
0
    void generateSteps()
    {
        stepObjects = new StepObject[numberOfSteps];

        for (int index = 0; index < stepObjects.Length; index++)
        {
            GameObject step = new GameObject();

            StepObject stepObject = step.AddComponent <StepObject>();
            stepObject.numberOfParts = numberOfStepParts;
            stepObject.crashingTime  = partsCrashingTime;
            stepObject.partSize      = partSize;

            setStepPosition(stepObject, index);

            stepObject.name             = "stepNumber" + index.ToString();
            stepObject.delegateStairway = this;

            stepObjects[index] = stepObject;
        }
    }
Example #9
0
 public bool PlacedStepObjectSuccesfully(StepObject objectPlaced, Step step)
 {
     print(step.currentStepObjectIndex);
     if (objectPlaced.gameObject.GetComponent <StepObject>().GetDefaultImage() == step.stepObjects[step.currentStepObjectIndex].GetComponent <StepObject>().GetDefaultImage())
     {
         step.currentStepObjectIndex++;
         if (step.currentStepObjectIndex == step.stepObjects.Length)
         {
             return(FinishStep(step));
         }
         else
         {
             print("Correct object added, add the next one!");
         }
     }
     else
     {
         step.currentStepObjectIndex = 0;
     }
     return(false);
 }
Example #10
0
        public ActionResult AddStep(StepObject step)
        {
            var gVal = new GenericValidator();

            try
            {
                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var validationResult = ValidateStep(step);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var appStatus = new StepServices().AddStep(step);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "Step upload failed. Please try again." : "The Step Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = appStatus;
                gVal.Error = "Step was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "Step steping failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Example #11
0
        private GenericValidator ValidateStep(StepObject step)
        {
            var gVal = new GenericValidator();

            try
            {
                if (string.IsNullOrEmpty(step.Name))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please select provide Step.";
                    return(gVal);
                }


                gVal.Code = 5;
                return(gVal);
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Step Validation failed. Please provide all required fields and try again.";
                return(gVal);
            }
        }
Example #12
0
 public void ReloadStep(StepObject stepObject)
 {
     setStepPosition(stepObject, _lastStep++);
     startCrashingNext();
     generateObstcalesAtStepIndex(_lastStep - 1);
 }
Example #13
0
 void setStepPosition(StepObject stepObject, int index)
 {
     stepObject.transform.position = new Vector3(0, index * stepObject.partSize.y, stepObject.partSize.z * index);
 }
Example #14
0
        public long AddStep(StepObject step)
        {
            try
            {
                if (step == null)
                {
                    return(-2);
                }



                using (var db = new ImportPermitEntities())
                {
                    var steps = db.Steps.Where(s => s.Process.ImportStage.Id == step.ImportStageId).ToList();

                    var count   = steps.Count();
                    var counter = count + 1;

                    var previousStepSequence = step.PreviousStepSequence;
                    if (count == 0)
                    {
                        step.SequenceNumber = 1;
                        var stepEntity = ModelMapper.Map <StepObject, Step>(step);
                        if (stepEntity == null || string.IsNullOrEmpty(stepEntity.Name))
                        {
                            return(-2);
                        }

                        var returnStatus = db.Steps.Add(stepEntity);
                        db.SaveChanges();
                        return(returnStatus.Id);
                    }
                    else
                    {
                        foreach (var item in steps)
                        {
                            if (item.SequenceNumber > previousStepSequence)
                            {
                                item.SequenceNumber  = item.SequenceNumber + 1;
                                db.Entry(item).State = EntityState.Modified;
                            }
                        }

                        step.SequenceNumber = previousStepSequence + 1;
                        var stepEntity = ModelMapper.Map <StepObject, Step>(step);
                        if (stepEntity == null || string.IsNullOrEmpty(stepEntity.Name))
                        {
                            return(-2);
                        }
                        db.Steps.Add(stepEntity);



                        db.SaveChanges();
                        return(1);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Example #15
0
 void setStepPosition(StepObject stepObject , int index)
 {
     stepObject.transform.position = new Vector3( 0, index * stepObject.partSize.y, stepObject.partSize.z * index );
 }
Example #16
0
 public void ReloadStep(StepObject stepObject)
 {
     setStepPosition (stepObject, _lastStep++);
     startCrashingNext ();
     generateObstcalesAtStepIndex(_lastStep - 1);
 }