Example #1
0
    public void Hack(byte index, ActiveControls controlValue)
    {
        if (isLocalPlayer == true)
        {
            hackedControls[index] = controlValue;

            // Update the controls
            ActiveControls disabledControls = ActiveControls.All;
            if (hackedControls[0] != ActiveControls.None)
            {
                disabledControls ^= hackedControls[0];
            }
            if ((hackedControls[1] != ActiveControls.None) && (hackedControls[0] != hackedControls[1]))
            {
                disabledControls ^= hackedControls[1];
            }

            CmdSetOpponentsControls((int)disabledControls, uniquePlayerIdName);

            // Run event
            if (HackChanged != null)
            {
                HackChanged(this);
            }
        }
    }
Example #2
0
    public override void OnStartLocalPlayer()
    {
        base.OnStartLocalPlayer();
        ClientSetup();
        SetName();

        // Reset control variables
        lastFramesControls = CurrentActiveControls;
    }
Example #3
0
 private void UpdateControlsHud()
 {
     if (lastFramesControls != CurrentActiveControls)
     {
         // Update controls
         foreach (KeyValuePair <ActiveControls, Animator> pair in disableGraphics)
         {
             pair.Value.SetBool(EnabledBool, IsControlActive(pair.Key));
         }
         hudAnimations.SetBool(RadarBool, IsControlActive(ActiveControls.Radar));
         hackedSound.Play();
         lastFramesControls = CurrentActiveControls;
     }
 }
Example #4
0
 public void PressControls(ActiveControls control, bool pressed)
 {
     if (isLocalPlayer == true)
     {
         Animator temp = null;
         if (disableGraphics.TryGetValue(control, out temp) == true)
         {
             //if(DebugControl == control)
             //{
             //    Debug.Log("Animationbool: " + temp.GetBool(PressedTriger) + ", Set To: " + pressed);
             //}
             if ((temp.gameObject.activeInHierarchy == true) && (temp.GetBool(PressedTriger) != pressed))
             {
                 // Check if button is disabled
                 if ((pressed == true) && (IsControlActive(control) == false))
                 {
                     disabledSound.Play();
                 }
                 temp.SetBool(PressedTriger, pressed);
             }
         }
     }
 }
Example #5
0
 public bool IsControlActive(ActiveControls control)
 {
     return((control & CurrentActiveControls) != 0);
 }
Example #6
0
        public MainWindow()
        {
            InitializeComponent();

            activeControls = new ActiveControls(canvas);
        }
Example #7
0
        public void GetJavaScript(StringBuilder sb, Dictionary <string, bool> list)
        {
            sb.Append("//");
            sb.AppendLine(Name);
            sb.AppendLine("var activeControls = new Array();");
            if (ActiveControls != null)
            {
                foreach (var clientID in ActiveControls.SelectMany(r => r.ClientIDs))
                {
                    sb.AppendFormat("Array.add(activeControls, $get('{0}'));", clientID);
                    sb.AppendLine();
                }
            }

            sb.AppendLine();

            #region инициализация колекций values, rightValues

            switch (CompareOperator)
            {
            case ControllerCompareOperator.NotEqual:
            case ControllerCompareOperator.Equal:
            case ControllerCompareOperator.GreaterThan:
            case ControllerCompareOperator.GreaterThanEqual:
            case ControllerCompareOperator.LessThan:
            case ControllerCompareOperator.LessThanEqual:
                GetJavaScript_AddGetValues(sb, list);
                GetJavaScript_AddGetRightValues(sb, list);
                break;

            case ControllerCompareOperator.IsEmpty:
            case ControllerCompareOperator.IsNotEmpty:
                GetJavaScript_AddGetValues(sb, list);
                sb.AppendLine("var rightValues = new Array();");
                sb.AppendLine("Array.add(rightValues,'');");
                break;

            case ControllerCompareOperator.Or:
                //todo: реализовать ControllerCompareOperator.Or
                break;

            case ControllerCompareOperator.And:
                //todo: реализовать ControllerCompareOperator.And
                break;

            case ControllerCompareOperator.IsEnabled:
                break;

            case ControllerCompareOperator.IsDisabled:
                break;

            case ControllerCompareOperator.IsHidden:
                break;

            case ControllerCompareOperator.IsShown:
                break;

            case ControllerCompareOperator.IsReadOnly:
                break;

            case ControllerCompareOperator.IsNotReadOnly:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            #endregion

            #region получение оператора сравнения opStr

            var opStr = "";
            switch (CompareOperator)
            {
            case ControllerCompareOperator.Equal:
                opStr = "==";
                break;

            case ControllerCompareOperator.NotEqual:
                opStr = "!=";
                break;

            case ControllerCompareOperator.GreaterThan:
                opStr = ">";
                break;

            case ControllerCompareOperator.GreaterThanEqual:
                opStr = ">=";
                break;

            case ControllerCompareOperator.LessThan:
                opStr = "<";
                break;

            case ControllerCompareOperator.LessThanEqual:
                opStr = "<";
                break;

            case ControllerCompareOperator.IsEmpty:
                opStr = "==";
                break;

            case ControllerCompareOperator.IsNotEmpty:
                opStr = "!=";
                break;

            case ControllerCompareOperator.Or:
                opStr = "||";
                break;

            case ControllerCompareOperator.And:
                opStr = "&&";
                break;

            case ControllerCompareOperator.IsEnabled:
                break;

            case ControllerCompareOperator.IsDisabled:
                break;

            case ControllerCompareOperator.IsHidden:
                break;

            case ControllerCompareOperator.IsShown:
                break;

            case ControllerCompareOperator.IsReadOnly:
                break;

            case ControllerCompareOperator.IsNotReadOnly:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            #endregion

            sb.AppendFormat("var result = checkArray(values, rightValues, {0}, '{1}');", JoinResultsAsOr.ToString().ToLower(), opStr);
            sb.AppendLine();
            sb.AppendFormat("if (result == null) result = {0};", DefaultResult.ToString().ToLower());
            sb.AppendLine();

            foreach (ControllerActiveType activeType in Enum.GetValues(typeof(ControllerActiveType)))
            {
                if (activeType == ControllerActiveType.None || (ActiveType & activeType) != activeType)
                {
                    continue;
                }
                switch (activeType)
                {
                case ControllerActiveType.None:
                    break;

                case ControllerActiveType.Enabled:
                    sb.AppendLine("setValuesToArray(activeControls, 'disabled', !result);");
                    break;

                case ControllerActiveType.ReadOnly:
                    sb.AppendLine("setValuesToArray(activeControls, 'readonly', !result);");
                    break;

                case ControllerActiveType.ValidationDisabled:
                    sb.AppendLine("disableValidationToArray(activeControls, !result);");
                    break;

                case ControllerActiveType.Hide:
                    sb.AppendLine("setValuesToArray(activeControls, 'style.display', result ? '\"\"' : '\"none\"');");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                sb.AppendLine();
            }
            sb.AppendLine();
        }