Beispiel #1
0
        protected override void HandleLoadedProperty(JsonTextReader reader, string propertyName, object readValue)
        {
            base.HandleLoadedProperty(reader, propertyName, readValue);
            switch (propertyName)
            {
            case "SpawnPoint":
                spawnPoint = LoadManager.LoadVector3d(reader);
                break;

            case "RallyPoint":
                rallyPoint = LoadManager.LoadVector3d(reader);
                break;

            case "FlagState":
                _flagState = WorkManager.GetFlagState((string)readValue);
                break;

            case "BuildProgress":
                currentSpawnProgress = (long)readValue;
                break;

            case "BuildQueue":
                buildQueue = new Queue <string>(LoadManager.LoadStringArray(reader));
                break;

            default: break;
            }
        }
 public NodeFlagChangedEventArgs(Node node, NodeFlag flag, FlagState oldState, FlagState newState)
 {
     _node = node;
     _flag = flag;
     _oldState = oldState;
     _newState = newState;
 }
Beispiel #3
0
        public void SetFlagState(TFlag flag, FlagState state)
        {
            if (_flags == null)
            {
                if (state == FlagState.Unknown)
                {
                    return;
                }
                _flags             = new Dictionary <TFlag, Dirtyable <bool> >();
                _flagEventTriggers = new Dictionary <TEvent, List <TriggerableEventTrigger <TIdentifier, TEvent, TFlag, TFlag, TProperty> > >();
            }
            FlagState oldState = GetFlagState(flag);

            if (state == FlagState.Unknown)
            {
                UnwireFlagEventTriggers(flag);
                _flags.Remove(flag);
            }
            else
            {
                if (!_flags.ContainsKey(flag))
                {
                    WireFlagEventTriggers(flag);
                }
                _flags[flag] = new Dirtyable <bool>(state == FlagState.Enabled);
            }

            if (oldState != state)
            {
                flag.RaiseFlagChanged((TObject)this, oldState, state);
            }
        }
Beispiel #4
0
 public NodeFlagChangedEventArgs(Node node, NodeFlag flag, FlagState oldState, FlagState newState)
 {
     _node     = node;
     _flag     = flag;
     _oldState = oldState;
     _newState = newState;
 }
 private void SetupFlag()
 {
     flagState = FlagState.Collected;
     flag.parentEntity.Set(carrier);
     flag.transform.localPosition = new Vector3(0, 1.5f, 0);
     flag.UpdateNetworkGroup();
     flag.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
 }
Beispiel #6
0
 public void ResetToHomePosition()
 {
     this.newParent = home;
     this.gameObject.transform.position = newParent.transform.position; //set the position to that of the parent's position
     this.gameObject.transform.rotation = newParent.transform.rotation; //set the rotation to that of the parent's rotation
     this.gameObject.transform.parent   = newParent.transform;          //set the transforms parent to the new parent's
     enemyCarrier = null;
     _flagState   = FlagState.AtHome;
     ActivateCollider();
 }
Beispiel #7
0
 /// <summary>
 /// this method deactivates the collider of this game object and sets the flag position according to its new parent
 /// </summary>
 /// <param name="newParent"></param>
 public void PickupFlag(GameObject newParent)
 {
     DeactivateCollider();
     this.newParent = newParent;
     this.gameObject.transform.position = newParent.transform.position; //set the position to that of the parent's position
     this.gameObject.transform.rotation = newParent.transform.rotation; //set the rotation to that of the parent's rotation
     this.gameObject.transform.parent   = newParent.transform;          //set the transforms parent to the new parent's
     enemyCarrier = newParent.transform.parent.gameObject;
     _flagState   = FlagState.Taken;
     //notify the tagger
 }
 public void DropFlag(Vector3 position)
 {
     carrier = null;
     flag.parentEntity.Set(null);
     flag.transform.localPosition = Vector3.zero;
     flag.transform.position      = position;
     flag.UpdateNetworkGroup();
     flag.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
     flagState = FlagState.Stationary;
     Invoke("AutoRestore", 30f);
 }
Beispiel #9
0
 private void WriteFlagState(string key, FlagState state)
 {
     if (state.Value)             //skip it if it's not set
     {
         Writer.WriteStartElement("trait");
         Writer.WriteAttributeString("name", key);
         Writer.WriteAttributeString("value", "set");
         //this attr required by lift schema, though we don't use it
         Writer.WriteEndElement();
     }
 }
Beispiel #10
0
 public FlagSet(FlagState initialiseAs = FlagState.UNDEFINED)
 {
     // Construct a flag set with all flags equal to $intialiseAs
     Carry     = initialiseAs;
     Auxiliary = initialiseAs;
     Overflow  = initialiseAs;
     Zero      = initialiseAs;
     Sign      = initialiseAs;
     Parity    = initialiseAs;
     Direction = initialiseAs;
     Interrupt = initialiseAs;
 }
Beispiel #11
0
        protected Control MakeCheckBoxWidget(PalasoDataObject target, Field field)
        {
            FlagState boxState = target.GetOrCreateProperty <FlagState>(field.FieldName);

            CheckBoxControl control = new CheckBoxControl(boxState.Value,
                                                          field.DisplayName,
                                                          field.FieldName);
            SimpleBinding <bool> binding = new SimpleBinding <bool>(boxState, control);

            binding.CurrentItemChanged += _detailList.OnBinding_ChangeOfWhichItemIsInFocus;
            return(control);
        }
Beispiel #12
0
        public void FeatureFlag_FeatureIsConfiguredToBeOff_ReturnsOff()
        {
            // Arrange
            const bool FlagState = false;

            Environment.SetEnvironmentVariable("PROMITOR_FEATURE_TestFlag", FlagState.ToString());

            // Act
            var flagStatus = FeatureFlag.IsActive("TestFlag");

            // Assert
            Assert.False(flagStatus);
        }
            private void OnDestroy()
            {
                CancelInvoke();

                carrier = null;
                flag.parentEntity.Set(null);
                flag.transform.localPosition = Vector3.zero;
                flag.transform.position      = homePos;
                flag.UpdateNetworkGroup();
                flag.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                flagState = FlagState.Stationary;

                (flag as BaseCombatEntity).DieInstantly();
            }
Beispiel #14
0
        protected override void OnFlagChanged <THost>(THost host, FlagState oldState, FlagState newState)
        {
            NodeFlagChangedEventArgs e = new NodeFlagChangedEventArgs(host as Node, this, oldState, newState);

            host.RaiseEvent(_changedEvent, e);
            if (newState == FlagState.Enabled)
            {
                host.RaiseEvent(_enabledEvent, e);
            }
            else if (oldState == FlagState.Enabled)
            {
                host.RaiseEvent(_noLongerEnabledEvent, e);
            }
        }
Beispiel #15
0
        public void ClearFlag(TFlag flag)
        {
            if (_flags == null)
            {
                return;
            }
            FlagState oldState = GetFlagState(flag);

            UnwireFlagEventTriggers(flag);
            _flags.Remove(flag);

            if (oldState != FlagState.Unknown)
            {
                flag.RaiseFlagChanged((TObject)this, oldState, FlagState.Unknown);
            }
        }
        public void FlagState_SerializeAndDeserialize_ShouldNotThrowException()
        {
            using var stream = new MemoryStream();
            var state = new FlagState();

            try
            {
                StateSerializer.Serialize(stream, state, true, true);
                stream.Position = 0;
                StateSerializer.Deserialize <FlagState>(stream);
            }
            catch (Exception ex)
            {
                Assert.Fail($"Exception of type ({ex.GetType().Name}) thrown: {ex.Message}");
            }
        }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            GameMaster.gm.ResetFlagsExcept(gameObject);
            State = FlagState.GREEN;
            GameMaster.gm.SpawnPoint = this.gameObject;

            if (OnRespawnFlagStay != null)
            {
                OnRespawnFlagStay(true);
            }

            GameMaster.gm.LastMainSoundStr = AudioManager.instance.MainSound.name;
        }
    }
        /// <summary>
        /// Converts a value.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted value. If the method returns null, the valid null value is used.
        /// </returns>
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            FlagState flag = (FlagState)value;
            string    key  = flag.ToString();

            if ((parameter != null) && (flag == FlagState.NotFlagged))
            {
                return(null);
            }

            if (!this.iconDict.ContainsKey(key))
            {
                this.iconDict[key] = new BitmapImage(new Uri("pack://application:,,,/UnclutteringYourInbox;component/Icons/" + key + ".png"));
            }

            return(this.iconDict[key]);
        }
Beispiel #19
0
 public void SetRallyPoint(Vector3d position)
 {
     rallyPoint = position;
     if (PlayerManager.MainController.Commander && Agent.IsSelected)
     {
         RallyPoint flag = PlayerManager.MainController.Commander.GetComponentInChildren <RallyPoint>();
         if (flag)
         {
             if (!flag.ActiveStatus)
             {
                 flag.Enable();
             }
             flag.transform.localPosition = rallyPoint.ToVector3();
             _flagState = FlagState.FlagSet;
         }
     }
 }
            public void RestoreFlag(string name = null)
            {
                if (string.IsNullOrEmpty(name))
                {
                    ctf.SendMessage($"{ctf.configData.Messaging.MainColor}{ctf.GetTeamName(team)}'s</color>{ctf.configData.Messaging.MSGColor} {msg("flag has been returned to base!")}</color>");
                }
                else
                {
                    ctf.SendMessage($"{ctf.configData.Messaging.MainColor}{name}</color>{ctf.configData.Messaging.MSGColor} {msg("has returned")} </color>{ctf.configData.Messaging.MainColor}{ctf.GetTeamName(team)}'s</color>{ctf.configData.Messaging.MSGColor} {msg("flag to base")}!</color>");
                }

                carrier = null;
                flag.parentEntity.Set(null);
                flag.transform.localPosition = Vector3.zero;
                flag.transform.position      = homePos;
                flag.UpdateNetworkGroup();
                flag.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                flagState = FlagState.Stationary;
            }
Beispiel #21
0
        public void DisableFlag(TFlag flag)
        {
            if (_flags == null)
            {
                _flags             = new Dictionary <TFlag, Dirtyable <bool> >();
                _flagEventTriggers = new Dictionary <TEvent, List <TriggerableEventTrigger <TIdentifier, TEvent, TFlag, TFlag, TProperty> > >();
            }
            FlagState oldState = GetFlagState(flag);

            if (!_flags.ContainsKey(flag))
            {
                WireFlagEventTriggers(flag);
            }
            _flags[flag] = new Dirtyable <bool>(false);

            if (oldState != FlagState.Disabled)
            {
                flag.RaiseFlagChanged((TObject)this, oldState, FlagState.Disabled);
            }
        }
        protected override void HandleLoadedProperty(JsonTextReader reader, string propertyName, object readValue)
        {
            base.HandleLoadedProperty(reader, propertyName, readValue);
            switch (propertyName)
            {
            case "SpawnPoint":
                spawnPoint = LoadManager.LoadVector(reader);
                break;

            case "RallyPoint":
                rallyPoint = LoadManager.LoadVector(reader);
                break;

            case "FlagState":
                _flagState = WorkManager.GetFlagState((string)readValue);
                break;

            default: break;
            }
        }
 public void SetRallyPoint(Vector3 position)
 {
     rallyPoint = position;
     if (Agent.GetCommander() && Agent.IsSelected)
     {
         RallyPoint flag = Agent.GetCommander().GetComponentInChildren <RallyPoint>();
         if (flag)
         {
             if (!flag.ActiveStatus)
             {
                 flag.Enable();
             }
             flag.transform.localPosition = rallyPoint;
             _flagState = FlagState.FlagSet;
             Agent.Controller.GetCommanderHUD().SetCursorLock(false);
             Agent.Controller.GetCommanderHUD().SetCursorState(CursorState.Select);
             SelectionManager.SetSelectionLock(false);
         }
     }
 }
Beispiel #24
0
        public FlagSet(byte[] input)
        {
            // A constructor that can set ZF, SF, PF to what they are defined as in most cases
            Carry     = FlagState.UNDEFINED;
            Auxiliary = FlagState.UNDEFINED;
            Overflow  = FlagState.UNDEFINED;
            Direction = FlagState.UNDEFINED;
            Interrupt = FlagState.UNDEFINED;

            // ZF is set if $input is equal to zero.
            Zero = input.IsZero() ? FlagState.ON : FlagState.OFF;

            // SF is set if $input has a negative sign in twos compliment form.
            Sign = input.IsNegative() ? FlagState.ON : FlagState.OFF;

            // PF is set if the number of bits on in the first byte of $input is even.
            // e,g
            // input[0] == 0b0000 ; PF
            // input[0] == 0b1000 ; NO PF
            // input[0] == 0b1010 ; PF
            Parity = Bitwise.GetParity(input[0]) ? FlagState.ON : FlagState.OFF;
        }
        // This method is defined with internal scope because metadata fields like trackEvents aren't
        // relevant to the main external use case for the builder (testing server-side code)
        internal FeatureFlagsStateBuilder AddFlag(string flagKey, LdValue value, int?variationIndex, EvaluationReason reason,
                                                  int flagVersion, bool flagTrackEvents, UnixMillisecondTime?flagDebugEventsUntilDate)
        {
            var flag = new FlagState
            {
                Value                = value,
                Variation            = variationIndex,
                DebugEventsUntilDate = flagDebugEventsUntilDate
            };

            if (!_detailsOnlyIfTracked || flagTrackEvents || flagDebugEventsUntilDate != null)
            {
                flag.Version = flagVersion;
                flag.Reason  = _withReasons ? reason : (EvaluationReason?)null;
            }
            if (flagTrackEvents)
            {
                flag.TrackEvents = true;
            }
            _flags[flagKey] = flag;
            return(this);
        }
Beispiel #26
0
    // Use this for initialization
    void Start()
    {
        // levelCompleteText.text = "";
        gameOver = false;
        paused   = false;

        GameObject healthUIObject = GameObject.FindGameObjectWithTag("HealthUI");

        // Locates the healthUIObject
        if (healthUIObject != null)
        {
            healthUI = healthUIObject.GetComponent <HealthControl>();
        }
        else
        {
            Debug.Log("Cannot find 'HealthUI' script");
        }



        // Gets pause menu gameobject
        if (!GetChild(this.gameObject, "PauseMenu", out pauseMenu))
        {
            Debug.Log("Could not find \"PauseMenu\" for " + this.name + " game object");
        }

        // Get TimerText
        timerText = timerPanel.GetComponent <Text>();
        if (timerText == null)
        {
            GetChild(timerPanel, "TimerText", out timerPanel, true);
            timerText = timerPanel.GetComponent <Text>();
        }
        currTime    = totalTime;
        timerActive = true;
        timer       = new Timer(currTime);

        freezeFlag = freezeFlagGUI.GetComponent <FlagState>();
    }
Beispiel #27
0
        public static bool SendCTFPickup(int conn_id, Player player, int flag_id, FlagState state, Item item = null)
        {
            var player_id = player.netId;

            lock (CTF.FlagLock) {
                if (CTF.FlagStates[flag_id] == FlagState.PICKEDUP)
                {
                    return(false);
                }

                // Recheck that the object is still there in case another player got the flag first.
                if (!(bool)_Item_ItemIsReachable_Method.Invoke(item, new object[] { player.c_player_ship.c_mesh_collider }))
                {
                    return(false);
                }

                CTF.FlagStates[flag_id] = state;

                if (CTF.PlayerHasFlag.ContainsKey(player_id))
                {
                    return(false);
                }

                if (item.c_go != null)
                {
                    item.m_type = ItemType.NONE;
                    UnityEngine.Object.Destroy(item.c_go);
                }

                CTF.PlayerHasFlag.Add(player_id, flag_id);
                SendToClientOrAll(conn_id, MessageTypes.MsgCTFPickup, new PlayerFlagMessage {
                    m_player_id = player_id, m_flag_id = flag_id, m_flag_state = state
                });
            }

            return(true);
        }
Beispiel #28
0
        public static void Main()
        {
            talon.ConfigFactoryDefault();
            talon2.ConfigFactoryDefault();

            /* simple counter to print and watch using the debugger */
            int  counter = 0;
            bool on      = false; // boolean to control on or off

            /* loop forever */
            while (true)
            {
                if (counter % 50 == 0) // runs code every 50 iterations
                {
                    if (on)
                    {
                        on = false;                                // set to off
                        talon.Set(ControlMode.PercentOutput, 0.0); // set talon to 0%
                    }
                    else
                    {
                        on = true;                               // set to on
                        talon.Set(ControlMode.PercentOutput, 1); // set talon 100%
                    }
                }
                if (gamepad.GetButton(0)) // is button with id 0 pressed
                {
                    currentFlagState = FlagState.IDLE;
                }
                if (gamepad.GetButton(1))
                {
                    currentFlagState = FlagState.TURN;
                }
                if (gamepad.GetButton(2))
                {
                    currentFlagState = FlagState.TURN_SLOW;
                }
                if (gamepad.GetButton(3))
                {
                    currentFlagState = FlagState.REVERSE;
                }

                if (gamepad.GetButton(4))
                {
                    talon2.Set(ControlMode.PercentOutput, 1.0); // set talon to 100%
                }
                else
                {
                    talon2.Set(ControlMode.PercentOutput, 0.0); // set talon to 0%
                }



                if (currentFlagState != lastFlagState)             // make code not run every update to have faster run time
                {
                    lastFlagState = currentFlagState;              // update the last state for flag spinner
                    switch (currentFlagState)                      // switch on current state for flag spinner
                    {
                    case FlagState.INIT:                           // is it in INIT?
                        talon.Set(ControlMode.PercentOutput, 0.0); // set talon to 0%
                        currentFlagState = FlagState.IDLE;         // set current state to IDLE
                        break;                                     // leave the switch statement

                    case FlagState.IDLE:                           // is is in IDLE?
                        talon.Set(ControlMode.PercentOutput, 0.0); // set talon to 0%
                        break;

                    case FlagState.TURN:
                        talon.Set(ControlMode.PercentOutput, 1);      // set talon 100%
                        break;

                    case FlagState.TURN_SLOW:
                        talon.Set(ControlMode.PercentOutput, 0.2);      // set talon 20%
                        break;

                    case FlagState.REVERSE:
                        talon.Set(ControlMode.PercentOutput, -1);      // set talon 100%
                        break;

                    default:
                        talon.Set(ControlMode.PercentOutput, 0.0); // set talon to 0% to prevent broken behavior
                        currentFlagState = FlagState.IDLE;         // set state to idle to prevent further errors
                        break;
                    }
                }

                /*
                 * the ifs are the equivalent of the case statement
                 * ​
                 *
                 * if (currentIntakeState == IntakeState.INIT)
                 * {
                 * ​
                 * } else if (currentIntakeState == IntakeState.IDLE)
                 * {
                 * ​
                 * } else if (currentIntakeState == IntakeState.IN)
                 * {
                 * ​
                 * } else if (currentIntakeState == IntakeState.IN_SLOW)
                 * {
                 * ​
                 * }
                 * else if (currentIntakeState == IntakeState.REVERSE)
                 * {
                 * ​
                 * } else   // this is the equivalent of the default section.
                 * {
                 * ​
                 * }
                 * ​
                 */
                /* print the three analog inputs as three columns */
                Debug.Print("Counter Value: " + counter);
                /* increment counter */
                ++counter; /* try to land a breakpoint here and hover over 'counter' to see it's current value.  Or add it to the Watch Tab */

                /* wait a bit */
                System.Threading.Thread.Sleep(100);

                // make sure the motors stay on
                CTRE.Phoenix.Watchdog.Feed();
            }
        }
Beispiel #29
0
 public static void init(FlagState f)
 {
     m_state = f;
 }
Beispiel #30
0
 public static void reset(FlagState f)
 {
     m_state &= ~f;
 }
Beispiel #31
0
 public static void init(FlagState f)
 {
     m_state = f;
 }
Beispiel #32
0
 public static bool check(FlagState f)
 {
     return((m_state & f) != 0);
 }
Beispiel #33
0
 public static void reset(FlagState f)
 {
     m_state &= ~f;
 }
 public InputSignalsFlagCondition(NodeFlag flag, FlagState state, CombinationMode mode)
 {
     _flag = flag;
     _state = state;
     _mode = mode;
 }
Beispiel #35
0
 public static void set(FlagState f)
 {
     m_state |= f;
 }
Beispiel #36
0
 public static bool check(FlagState f)
 {
     return ((m_state & f) != 0);
 }
Beispiel #37
0
		private void WriteFlagState(string key, FlagState state)
		{
			if (state.Value) //skip it if it's not set
			{
				Writer.WriteStartElement("trait");
				Writer.WriteAttributeString("name", key);
				Writer.WriteAttributeString("value", "set");
				//this attr required by lift schema, though we don't use it
				Writer.WriteEndElement();
			}
		}