Beispiel #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();
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// Решить головоломку
    /// </summary>
    public override void SolveRiddle()
    {
        base.SolveRiddle();
        IMechanism mech = riddleSolvedMech.GetComponent <IMechanism>();

        if (mech != null)
        {
            mech.ActivateMechanism();
        }
    }
Beispiel #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;
 }
Beispiel #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");
     }
 }
Beispiel #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");
         }
     }
 }
 /// <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();
                 }
             }
         }
     }
 }
Beispiel #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);
         }
     }
 }