예제 #1
0
    // handles the event if the player clicks on an item
    void OnItemClick(GameObject go)
    {
        string placeholderName = go.name;
        Item   item            = stepVM.GetItem(placeholderName);

        item.IsPicked = true;

        // if the items onpicked attribute is set then
        // initialize the next step
        if (item.OnPicked != null && item.OnPicked != "")
        {
            StepVM svm = levelVM.GetStepVM(item.OnPicked);
            InitStep(svm);
        }
        // check if the step is complete after clicking an item
        // since some steps will be set to complete if all the items
        // inside the step is picked up
        else if (stepVM.StepComplete)
        {
            StepVM svm = levelVM.GetStepVM(stepVM.Step.OnComplete);
            InitStep(svm);
        }
        if (OnItemPicked != null)
        {
            OnItemPicked(item);
        }

        go.collider.enabled = false;
        UISprite sprite = go.GetComponent <UISprite>();

        sprite.alpha = 0;
    }
예제 #2
0
        public ActionResult Edit(StepVM model)
        {
            int id = stepProcessor.Update(mapper.Map <StepDTO>(model));

            return(RedirectToAction(nameof(Index),
                                    new { id }));
        }
예제 #3
0
    // handles the event if the player clicks the quest game object
    void OnQuestClick(GameObject go)
    {
        string placeholderName = go.name;
        Quest  quest           = stepVM.GetQuest(placeholderName);

        quest.IsSolved = true;

        // quest is solved. go to the quest.OnSolved step
        if (quest.OnSolved != null || quest.OnSolved != "")
        {
            StepVM svm = levelVM.GetStepVM(quest.OnSolved);
            InitStep(svm);
        }
    }
예제 #4
0
 public void Init(LevelVM lVM, StepVM svm = null)
 {
     levelVM  = lVM;
     currStep = 0;
     if (svm == null)
     {
         // if no step view model is passed in to the init method
         // the game will start the first step of the level
         InitStep(levelVM.GetFirstStepVM());
     }
     else
     {
         // if a step view model is passed into the Init method
         // then the given step will be initialized.
         InitStep(svm);
     }
 }
예제 #5
0
 public IActionResult PostStep(StepVM stepVM)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (stepVM.Id == null)
     {
         db.Steps.Add(mapper.Map <Step>(stepVM));
     }
     else
     {
         db.Steps.Update(mapper.Map <Step>(stepVM));
     }
     db.Save();
     return(NoContent());
 }
예제 #6
0
    // the player loads a saved game
    void OnPlayerStatusModelChanged()
    {
        inventoryVM.ItemsIdList = playerStatusModel.Items;

        Level   level   = gameModel.GetLevel(playerStatusModel.Level);
        LevelVM levelVM = new LevelVM(level);
        StepVM  stepVM  = levelVM.GetStepVM(playerStatusModel.Step);

        stepVM.ItemIdsListFilter = inventoryVM.ItemsIdList;

        gameComponent.ShowLoadingPrefab();

        // give the game a bit time to destroy the current content
        // before loading the new one

        // this is a Workaround since NGUI seems to have a problem
        // get the game objects if the the game os loaded
        // in the same step as it were saved
        StartCoroutine(DelayInit(levelVM, stepVM));
    }
예제 #7
0
    // intialize a new step level
    void InitStep(StepVM svm)
    {
        // remove the current step view from the tree
        if (currStepGO != null)
        {
            Destroy(currStepGO);
        }

        stepVM = svm;

        CurrentStep = stepVM.Step.Id;

        // load the step prefab and display it
        string     prefab = stepVM.Step.Prefab;
        GameObject go     = (GameObject)Instantiate(Resources.Load(prefab));


        go.transform.parent        = transform;
        go.transform.localScale    = Vector3.one;
        go.transform.localPosition = Vector3.zero;

        // init the quests of teh level step
        if (stepVM.Step.QuestList != null)
        {
            InitStepQuests();
        }

        // init the items of the level step
        if (stepVM.Step.ItemList != null)
        {
            InitStepItems();
        }

        currStepGO = go;

        // fire the event to notify that a new step has been initialized
        if (OnStepStart != null)
        {
            OnStepStart(stepVM.Step);
        }
    }
예제 #8
0
    // handles the event after the player drops an item into the quest game object
    void OnQuestDrop(GameObject questPlaceholder, GameObject droppedItem)
    {
        // Workaround since Unity always adds the "(Clone)" string to the game objects name
        string droppedItemRefID = droppedItem.name.Replace("(Clone)", "");

        if (stepVM.IsAcceptedByQuest(questPlaceholder.name, droppedItemRefID))
        {
            Quest quest = stepVM.GetQuest(questPlaceholder.name);
            quest.IsSolved = true;

            if (OnItemAcceptedByQuest != null)
            {
                OnItemAcceptedByQuest(droppedItemRefID);
            }

            // quest is solved. go to the quest.OnSolved step
            if (quest.OnSolved != null || quest.OnSolved != "")
            {
                StepVM svm = levelVM.GetStepVM(quest.OnSolved);
                InitStep(svm);
            }
        }
    }
예제 #9
0
    IEnumerator DelayInit(LevelVM lvm, StepVM svm)
    {
        yield return(new WaitForSeconds(.5f));

        gameComponent.Init(lvm, svm);
    }
예제 #10
0
 public ActionResult Create(StepVM model)
 {
     stepProcessor.Create(mapper.Map <StepDTO>(model));
     return(RedirectToAction(nameof(Index),
                             new { id = model.Recipe_Id }));
 }