コード例 #1
0
    /// <summary>
    /// Активировать механизм
    /// </summary>
    public override void ActivateMechanism()
    {
        int progress1 = levers.Count;

        if (progress1 != progress)
        {
            for (progress1 = levers.Count; progress1 > progress; progress1--)
            {
                if (levers[progress1 - 1].Activated)
                {
                    break;
                }
            }
            if (progress1 == progress + 1)
            {
                progress++;
                IMechanism mech = mechanisms[progress - 1].GetComponent <IMechanism>();
                if (mech != null)
                {
                    mech.ActivateMechanism();
                }
                if (progress == levers.Count)
                {
                    SolveRiddle();
                }
            }
            else if (progress1 > progress + 1)
            {
                ResetRiddle();
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Решить головоломку
    /// </summary>
    public override void SolveRiddle()
    {
        base.SolveRiddle();
        IMechanism mech = riddleSolvedMech.GetComponent <IMechanism>();

        if (mech != null)
        {
            mech.ActivateMechanism();
        }
    }
コード例 #3
0
 /// <summary>
 /// Сбросить состояние головоломки до начального
 /// </summary>
 public override void ResetRiddle()
 {
     for (int i = 0; i < progress; i++)
     {
         IMechanism mech = mechanisms[i].GetComponent <IMechanism>();
         if (mech != null)
         {
             mech.ActivateMechanism();
         }
     }
     progress = 0;
 }
コード例 #4
0
 public override void Interact()
 {
     foreach (GameObject obj in mechanisms)
     {
         IMechanism mech = obj.GetComponent <IMechanism>();
         if (mech != null)
         {
             mech.ActivateMechanism();
         }
     }
     activated = !activated;
     if (anim != null)
     {
         anim.Play(activated ? "Active" : "Inactive");
     }
 }
コード例 #5
0
 public void ActivateMechanism()
 {
     if (activated)
     {
         foreach (GameObject obj in mechanisms)
         {
             IMechanism mech = obj.GetComponent <IMechanism>();
             if (mech != null)
             {
                 mech.ActivateMechanism();
             }
         }
         activated = false;
         if (anim != null)
         {
             anim.Play("Inactive");
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Игрок нажал на плиту
 /// </summary>
 public virtual void OnTriggerEnter2D(Collider2D other)
 {
     if (!activated)
     {
         if (other.gameObject == SpecialFunctions.player)
         {
             activated = true;
             if (anim != null)
             {
                 anim.Play("Active");
             }
             foreach (GameObject obj in mechanisms)
             {
                 IMechanism mech = obj.GetComponent <IMechanism>();
                 if (mech != null)
                 {
                     mech.ActivateMechanism();
                 }
             }
         }
     }
 }
コード例 #7
0
 /// <summary>
 /// Взаимодействие с рычагом
 /// </summary>
 public virtual void Interact()
 {
     if (!activated)
     {
         foreach (GameObject obj in mechanisms)
         {
             IMechanism mech = obj.GetComponent <IMechanism>();
             if (mech != null)
             {
                 mech.ActivateMechanism();
             }
         }
         activated = !activated;
         if (anim != null)
         {
             anim.Play(activated ? "Active" : "Inactive");
         }
         if (!once)
         {
             once = true;
             SpecialFunctions.statistics.ConsiderStatistics(this);
         }
     }
 }