예제 #1
0
    /// <summary>
    /// Method responsible for checking if the sequence added by the players
    /// is equal with the expected one
    /// </summary>
    /// <param name="osh">The ObjectStateHandler just added to the list</param>
    private void CheckCompatibility(ObjectStateHandler osh)
    {
        bool test = true;

        if (wantedStates.Count != sequence.Count)
        {
            test = false;
        }

        if (test)
        {
            for (int i = 0; i < wantedStates.Count; i++)
            {
                if (wantedStates[i] != sequence?[i])
                {
                    test = false;
                }
            }
        }


        if (test)
        {
            ProcessResult();
        }
        else
        {
            if (wantedStates.Count == sequence.Count)
            {
                ResetList();
            }
        }
    }
예제 #2
0
    private void RotateObject(ObjectStateHandler osh, short state)
    {
        if (clockWise || counterClockWise)
        {
            osh.State = previous;
            return;
        }

        if ((previous == 0) && (state == osh.MaxStates - 1))
        {
            counterClockWise = true;
        }
        else if ((previous == osh.MaxStates - 1) && (state == 0))
        {
            clockWise = true;
        }
        else if (previous > state)
        {
            counterClockWise = true;
        }
        else if (previous < state)
        {
            clockWise = true;
        }

        previous = state;
    }
예제 #3
0
    /// <summary>
    /// Method responsible for instatiating the object
    /// </summary>
    /// <param name="oSH"></param>
    /// <param name="state"></param>
    public void Instatiate(ObjectStateHandler oSH, short state)
    {
        GameObject _item;

        _item = Instantiate(item, transform.position + positionOffset, item.transform.rotation);
        _item.transform.SetParent(gameObject.transform.GetChild(1));
    }
예제 #4
0
    private void Awake()
    {
        ObjectStateHandler osh = GetComponent <ObjectStateHandler>();

        previous           = osh.State;
        osh.OnChangeState += RotateObject;
    }
예제 #5
0
 /// <summary>
 /// Method responsible for changing the dialogue of the npc
 /// </summary>
 /// <param name="oSH">ObjectStateHandler that just changed states</param>
 /// <param name="state">State the StateHandler changed to</param>
 public void Change(ObjectStateHandler oSH, short state)
 {
     if (state == this.state)
     {
         npc.Dialogue = script;
     }
 }
예제 #6
0
    /// <summary>
    /// Method responsible for handling what happens when the trigger
    /// StateHandler changes state
    /// </summary>
    /// <param name="osh">ObjectStateHandler that changed its state</param>
    /// <param name="state">New state of the ObjectStateHandler</param>
    public void Activate(ObjectStateHandler osh, short state)
    {
        short it = (short)Mathf.Clamp(setter.State, 0, iterationList.Length - 1);

        iteration = iterationList[it];
        ProcessResult();
    }
예제 #7
0
 /// <summary>
 /// Method called when the scene starts
 /// </summary>
 public void Awake()
 {
     osh = GetComponent <ObjectStateHandler>();
     if (osh != null)
     {
         osh.OnChangeState += Instatiate;
     }
 }
예제 #8
0
 /// <summary>
 /// Method called before the first frame update
 /// </summary>
 void Start()
 {
     osh = GetComponent <ObjectStateHandler>();
     if (osh != null)
     {
         osh.OnChangeState += Change;
     }
 }
예제 #9
0
 /// <summary>
 /// Method responsible for handling what happens when one of the
 /// StateHandlers associated with this Interactor changes states
 /// </summary>
 /// <param name="osh">ObjectStateHandler that changed its state</param>
 /// <param name="state">New state of the ObjectStateHandler</param>
 private void UpdateState(ObjectStateHandler osh, short state)
 {
     if (currentStates.ContainsKey(osh))
     {
         currentStates[osh] = state;
     }
     CheckCompatibility(osh);
 }
예제 #10
0
 /// <summary>
 /// Method responsible for clearing the sequence list
 /// </summary>
 public void ResetList()
 {
     for (int i = 0; i < sequence.Count; i++)
     {
         ObjectStateHandler o = sequence[i];
         o.ChangeToState(0);
     }
     sequence.Clear();
 }
예제 #11
0
 /// <summary>
 /// Methos responsible for updating the state of the Interactor
 /// </summary>
 /// <param name="osh">ObjectStateHandler that changed its state</param>
 /// <param name="state">New state of the ObjectStateHandler</param>
 private void UpdateState(ObjectStateHandler osh, short state)
 {
     if (state == 0)
     {
         return;
     }
     sequence.Add(osh);
     CheckCompatibility(osh);
 }
예제 #12
0
    /// <summary>
    /// Method responsible for checking if the the ObjectStateHandler chanaged
    /// states to the appropriate state
    /// </summary>
    /// <param name="osh">ObjectStateHandler that just changed states</param>
    private void CheckCompatibility(ObjectStateHandler osh)
    {
        short it = 0;

        foreach (StateO o in wantedStates)
        {
            if (o.Osh.State >= 1)
            {
                ProcessResult(o.State);
                it++;
            }
        }
    }
예제 #13
0
 /// <summary>
 /// Method responsible for loading the scene specified
 /// </summary>
 /// <param name="oSH">Object state Handler attached to this object</param>
 /// <param name="state">State of the OSH attached</param>
 public void Next(ObjectStateHandler oSH, short state)
 {
     try
     {
         StratumManager.instance.SceneString = sceneName;
         // Change to index later
         SceneManager.LoadScene("Loading");
     }
     catch (Exception)
     {
         print("Scene name invalid!");
     }
 }
예제 #14
0
    /// <summary>
    /// Check if the all ObjectStateHandlers in wantedStates have the correct state
    /// </summary>
    /// <param name="osh">ObjectStateHandler that changed its state</param>
    private void CheckCompatibility(ObjectStateHandler osh)
    {
        bool compatible = true;

        foreach (StateO o in wantedStates)
        {
            //Scuffed
            if (osh == o.Osh)
            {
                if (o.Any)
                {
                    ProcessResult();
                    return;
                }
            }


            if (o.State != currentStates[o.Osh])
            {
                compatible = false;
            }
        }

        if (compatible)
        {
            ProcessResult();
            wasTriggered = true;
        }
        else
        {
            if (wasTriggered)
            {
                if (!persistance)
                {
                    ProcessResult(0);
                }

                wasTriggered = false;
            }
        }
    }
예제 #15
0
 /// <summary>
 /// Method responsible for handling what happens when one of
 /// StateHandlers in the list changes states
 /// </summary>
 /// <param name="osh">ObjectStateHandler that changed its state</param>
 /// <param name="state">New state of the ObjectStateHandler</param>
 private void UpdateState(ObjectStateHandler osh, short state)
 {
     CheckCompatibility(osh);
 }