Esempio n. 1
0
    float GetMovePercent(SwitchBoxSwitch sw)
    {
        var totalDist = (rightAnchor.position - leftAnchor.position).magnitude;
        var swPos     = sw.transform.position;
        var swDist    = (swPos - leftAnchor.position).magnitude;

        return(swDist / totalDist);
    }
Esempio n. 2
0
 void UpdateUpStates()
 {
     curSwitch = GetOneOnSwitch();
     isUp      = curSwitch != null;
     if (curSwitch != null)
     {
         curRodPosPerc = 1 - GetMovePercent(curSwitch);
     }
 }
Esempio n. 3
0
    SwitchBoxSwitch GetOneOnSwitch()
    {
        SwitchBoxSwitch onSwitch = null;

        foreach (var item in switchList)
        {
            if (item.IsSwitchOn())
            {
                onSwitch = item;
            }
        }
        return(onSwitch);
    }
Esempio n. 4
0
 // Start is called before the first frame update
 void Start()
 {
     sw = GetComponent <SwitchBoxSwitch>();
 }