Пример #1
0
    // Use this for initialization
    void Start()
    {
        Debug.LogFormat("OK");
        _moduleId    = _moduleIdCounter++;
        _initialTime = Bomb.GetTime();

        // rule seed init
        var rnd = RuleSeedable.GetRNG();

        rnd.ShuffleFisherYates(_rules);
        rnd.ShuffleFisherYates(_columns);

        // light scaling
        float scalar = transform.lossyScale.x;

        foreach (MeshRenderer light in TopWires)
        {
            light.GetComponentInChildren <Light>().range *= scalar;
        }

        // initialize links activation
        _links = new List <Link>();
        for (int i = 0; i < 12; ++i)
        {
            _links.Add(new Link(_rules[i], _columns[i]));
        }

        for (int i = 0; i < Buttons.Length; ++i)
        {
            int j = i;
            Buttons[i].OnInteract += delegate { buttonPress(j); return(false); };
        }

        // pick the top path
        int startIndex = Rnd.Range(0, 4);

        _startingPoint = (Link.Point)startIndex;
        TopWires[startIndex].GetComponentInChildren <Light>().enabled = true;
        TopWires[startIndex].material = MatWireOn;
        Debug.LogFormat("[Ladder Lottery #{0}] Starting point {1}", _moduleId, _startingPoint.ToString());
    }
Пример #2
0
 void buttonPress(int index)
 {
     Buttons[index].AddInteractionPunch();
     Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
     if (!_isSolved && !_isCoroutineActive)
     {
         Link.Point finalPoint = getRightAnswer();
         if (index == (int)finalPoint)
         {
             Debug.LogFormat("[Ladder Lottery #{0}] Final answer {1} is correct. Module solved.", _moduleId, finalPoint.ToString());
             Module.HandlePass();
             _isSolved = true;
             TopWires[(int)_startingPoint].GetComponentInChildren <Light>().enabled = false;
             TopWires[(int)_startingPoint].material = MatWireOff;
         }
         else
         {
             Debug.LogFormat("[Ladder Lottery #{0}] Strike ! Expected answer {1}. Button {2} pressed.", _moduleId, finalPoint.ToString(), index);
             Module.HandleStrike();
             StartCoroutine(strikeCoroutine(index));
         }
     }
 }