/// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement selectedElement)
        {
            if (agentWaypoints != null)
            {
                agentWaypoints.IsActiveChanged -= AgentWaypointsOnIsActiveChanged;
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                agentWaypoints = selectedAgent.GetExtension <AgentWaypoints>();
                if (agentWaypoints == null)
                {
                    Hide();
                }
                else
                {
                    agentWaypoints.IsActiveChanged += AgentWaypointsOnIsActiveChanged;
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement selectedElement)
        {
            //Detach from current agent events
            if (selectedAgent != null)
            {
                selectedAgent.VariantChanged -= SelectedAgentOnVariantChanged;
                if (sensorsConfiguration != null)
                {
                    sensorsConfiguration.SensorsConfigurationIdChanged -= SelectedAgentOnSensorsConfigurationIdChanged;
                }
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                sensorsConfiguration = selectedAgent.GetExtension <AgentSensorsConfiguration>();
                if (sensorsConfiguration == null)
                {
                    Hide();
                }
                else
                {
                    selectedAgent.VariantChanged += SelectedAgentOnVariantChanged;
                    sensorsConfiguration.SensorsConfigurationIdChanged += SelectedAgentOnSensorsConfigurationIdChanged;
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement selectedElement)
        {
            //Detach from current agent events
            if (selectedAgent != null)
            {
                //Hide destination point if agent is deselected and something else is selected
                if (destinationPointExtension != null && selectedElement != destinationPointExtension.DestinationPoint)
                {
                    destinationPointExtension.DestinationPoint.SetVisibility(false);
                }
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                destinationPointExtension = selectedAgent.GetExtension <AgentDestinationPoint>();
                if (destinationPointExtension == null)
                {
                    Hide();
                }
                else
                {
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
Beispiel #4
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.RightArrow)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            tokens.MoveNext();

            //  子要素 img命令が0回以上続く
            var image = new Image();

            for (; image.IsSyntax(tokens);)
            {
                var tag = new Tag();
                result.AddChild(tag.Build(tokens, now, scenarioData));
            }


            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="previousElement">Scenario element that has been deselected</param>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement previousElement, ScenarioElement selectedElement)
        {
            //Detach from current agent events
            if (colorExtension != null)
            {
                colorExtension.ColorChanged -= SelectedAgentOnColorChanged;
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                colorExtension = selectedAgent.GetExtension <AgentColorExtension>();
                if (colorExtension == null)
                {
                    Hide();
                }
                else
                {
                    colorExtension.ColorChanged += SelectedAgentOnColorChanged;
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement selectedElement)
        {
            //Detach from current agent events
            if (behaviourExtension != null)
            {
                behaviourExtension.BehaviourChanged -= BehaviourExtensionOnBehaviourChanged;
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                behaviourExtension = selectedAgent.GetExtension <AgentBehaviour>();
                if (behaviourExtension == null)
                {
                    Hide();
                }
                else
                {
                    behaviourExtension.BehaviourChanged += BehaviourExtensionOnBehaviourChanged;
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="previousElement">Scenario element that has been deselected</param>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement previousElement, ScenarioElement selectedElement)
        {
            //Detach from current agent events
            if (destinationPointExtension != null && selectedAgent == previousElement)
            {
                //Hide destination point if something else than the destination point is selected
                if (!(selectedElement is ScenarioDestinationPoint ||
                      selectedElement is ScenarioDestinationPointWaypoint) &&
                    destinationPointExtension.DestinationPoint != null)
                {
                    destinationPointExtension.DestinationPoint.SetVisibility(false);
                }
                destinationPointExtension = null;
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                destinationPointExtension = selectedAgent.GetExtension <AgentDestinationPoint>();
                if (destinationPointExtension == null)
                {
                    Hide();
                }
                else
                {
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
Beispiel #8
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            TransformToMove.localPosition = origin.TransformToMove.localPosition;
            var originPoint = (ScenarioDestinationPoint)origin;

            SetActive(originPoint.IsActive);
            SetVisibility(false);
        }
    private void CreateElement(ScenarioInfo info)
    {
        ScenarioElement element = Instantiate(this.elementPrefab);

        element.SetScenarioInfo(info);
        element.transform.SetParent(targetTransform);
        element.transform.localScale = new Vector3(1, 1, 1);
    }
Beispiel #10
0
 /// <inheritdoc/>
 public void Initialize(ScenarioElement parentElement)
 {
     ParentAgent = (ScenarioAgent)parentElement;
     if (ParentAgent.Variant is EgoAgentVariant egoAgentVariant && egoAgentVariant.SensorsConfigurations.Count > 0)
     {
         ChangeSensorsConfigurationId(egoAgentVariant.SensorsConfigurations[0].Id, false);
     }
     ParentAgent.VariantChanged += ParentAgentOnVariantChanged;
 }
 /// <summary>
 /// Changes the currently selected waypoint speed
 /// </summary>
 /// <param name="changedElement">Scenario element which speed has been changed</param>
 /// <param name="mpsSpeed">Speed value in meters per second</param>
 private void ChangeWaypointSpeed(ScenarioElement changedElement, float mpsSpeed)
 {
     if (!(changedElement is ScenarioAgentWaypoint changedWaypoint))
     {
         return;
     }
     ScenarioManager.Instance.IsScenarioDirty = true;
     changedWaypoint.DestinationSpeed         = mpsSpeed;
 }
 /// <summary>
 /// Changes the currently selected waypoint acceleration
 /// </summary>
 /// <param name="changedElement">Scenario element which acceleration has been changed</param>
 /// <param name="mps2Acceleration">Acceleration value in meters per square second</param>
 private void ChangeWaypointAcceleration(ScenarioElement changedElement, float mps2Acceleration)
 {
     if (!(changedElement is ScenarioAgentWaypoint changedWaypoint))
     {
         return;
     }
     ScenarioManager.Instance.IsScenarioDirty = true;
     changedWaypoint.Acceleration             = mps2Acceleration;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="scenarioElement">Scenario element that was removed from the map</param>
        public UndoRemoveElement(ScenarioElement scenarioElement)
        {
            this.scenarioElement = scenarioElement;
            GameObject gameObject;

            (gameObject = scenarioElement.gameObject).SetActive(false);
            previousParent = gameObject.transform.parent;
            scenarioElement.transform.SetParent(ScenarioManager.Instance.GetExtension <ScenarioUndoManager>().transform);
        }
    public ScenarioElementController(ScenarioElement prefab, float posX, float posY, float rotation, int hp, bool breakable)
    {
        this.ElementPrefab = prefab;
        this.posX          = posX;
        this.posY          = posY;
        this.rotation      = rotation;

        ElementPrefab.setInitValues(hp, breakable);
    }
Beispiel #15
0
 /// <inheritdoc/>
 public override void CopyProperties(ScenarioElement origin)
 {
     base.CopyProperties(origin);
     if (origin is ScenarioControllable originControllable)
     {
         Policy.Clear();
         Policy.AddRange(originControllable.Policy);
     }
     ScenarioManager.Instance.GetExtension <ScenarioControllablesManager>().RegisterControllable(this);
 }
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            base.CopyProperties(origin);
            var originWaypoint = origin.GetComponent <ScenarioDestinationPointWaypoint>();

            if (originWaypoint == null)
            {
                return;
            }
        }
Beispiel #17
0
        /// <inheritdoc/>
        public void CopyProperties(ScenarioElement originElement)
        {
            var scenarioAgent = (ScenarioAgent)originElement;
            var origin        = scenarioAgent.GetExtension <AgentSensorsConfiguration>();

            if (origin == null)
            {
                return;
            }
            SensorsConfigurationId = origin.SensorsConfigurationId;
        }
Beispiel #18
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement(
                new executor.Say()
                );

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.RightArrow)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            tokens.MoveNext();


            //  子要素
            //  0回以上NewLine or WaitNext or テキストが続く
            while (true)
            {
                var textBuilder = new Text();
                if (textBuilder.IsSyntax(tokens))
                {
                    result.AddChild(textBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var newLineBuilder = new NewLine();
                if (newLineBuilder.IsSyntax(tokens))
                {
                    result.AddChild(newLineBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var waitNextBuilder = new WaitNext();
                if (waitNextBuilder.IsSyntax(tokens))
                {
                    result.AddChild(waitNextBuilder.Build(tokens, result, scenarioData));
                    continue;
                }

                var comment = new Comment();
                if (comment.IsSyntax(tokens))
                {
                    var tag = new Tag();
                    result.AddChild(tag.Build(tokens, result, scenarioData));

                    continue;
                }

                break;
            }
            return(result);
        }
Beispiel #19
0
        /// <inheritdoc/>
        public void CopyProperties(ScenarioElement originElement)
        {
            var originAgent = (ScenarioAgent)originElement;
            var origin      = originAgent.GetExtension <AgentBehaviour>();

            if (origin == null)
            {
                return;
            }
            Behaviour           = origin.Behaviour;
            BehaviourParameters = JSON.Parse(origin.BehaviourParameters.ToString()) as JSONObject;
        }
 /// <summary>
 /// Method called when another scenario element has been selected
 /// </summary>
 /// <param name="selectedElement">Scenario element that has been selected</param>
 private void SelectedOtherElement(ScenarioElement selectedElement)
 {
     element = selectedElement;
     if (element == null)
     {
         Hide();
     }
     else
     {
         Show();
     }
 }
Beispiel #21
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  attribute解析
            while (tokens.Current.GetType() != parser.token.TokenType.Slash)
            {
                var attribute = new Attribute();
                result.AddAttribute(attribute.Build(tokens, result, scenarioData));
            }

            return(result);
        }
Beispiel #22
0
 /// <inheritdoc/>
 public override void Show()
 {
     selectedElement = ScenarioManager.Instance.SelectedElement;
     ScenarioManager.Instance.SelectedElement = null;
     ScenarioManager.Instance.GetExtension <InputManager>().ElementSelectingSemaphore.Lock();
     didLockSemaphore          = true;
     duration                  = 0.0f;
     precachePlaybackCoroutine = PrecachePlayback();
     State = PlaybackState.Precaching;
     controlPanel.SetActive(false);
     precachingPanel.SetActive(true);
     gameObject.SetActive(true);
     StartCoroutine(precachePlaybackCoroutine);
 }
Beispiel #23
0
 /// <summary>
 /// Changes the value of this input field without calling the callback
 /// </summary>
 /// <param name="baseValue">New value in the base unit type</param>
 /// <param name="context">Scenario element which indicates the edit input context</param>
 /// <param name="invokeApply">Should this method call invoke value apply callback</param>
 public void ExternalValueChange(float baseValue, ScenarioElement context, bool invokeApply)
 {
     if (Mathf.Approximately(currentValue, baseValue))
     {
         return;
     }
     currentValue = baseValue;
     UnityInputField.SetTextWithoutNotify(ConvertFromBase(currentValue, currentUnit)
                                          .ToString(CultureInfo.CurrentCulture));
     if (invokeApply)
     {
         valueApply?.Invoke(context, currentValue);
     }
 }
Beispiel #24
0
        /// <inheritdoc/>
        public override void Initialize(ScenarioElement parentElement)
        {
            base.Initialize(parentElement);
            ParentAgent = (ScenarioAgent)parentElement;
            SetStartEndElements(parentElement, null);
            ParentAgent.ExtensionAdded   += ParentAgentOnExtensionAdded;
            ParentAgent.ExtensionRemoved += ParentAgentOnExtensionRemoved;
            var behaviourExtension = ParentAgent.GetExtension <AgentBehaviour>();

            if (behaviourExtension != null)
            {
                behaviourExtension.BehaviourChanged += ParentAgentOnBehaviourChanged;
            }
        }
Beispiel #25
0
        public IScenarioNode Build(IEnumerator <parser.token.ITokenable> tokens, IScenarioNode now, ScenarioData scenarioData)
        {
            var result = new ScenarioElement();

            //  コメント解析
            while (tokens.Current.GetType() != parser.token.TokenType.Word || tokens.Current.GetToken() != "--" || tokens.Current.Next.GetType() != parser.token.TokenType.RightArrow)
            {
                tokens.MoveNext();
            }

            tokens.MoveNext();

            return(result);
        }
Beispiel #26
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            if (!(origin is ScenarioNavOrigin originNav))
            {
                return;
            }

            if (NavOrigin == null)
            {
                Setup(GetComponent <NavOrigin>(), false);
            }
            NavOrigin.OriginX  = originNav.NavOrigin.OriginX;
            NavOrigin.OriginY  = originNav.NavOrigin.OriginY;
            NavOrigin.Rotation = originNav.NavOrigin.Rotation;
        }
 /// <inheritdoc/>
 public override void Hide()
 {
     Stop();
     for (var i = 0; i < controllers.Count; i++)
     {
         controllers[i].Deinitialize();
     }
     gameObject.SetActive(false);
     if (didLockSemaphore)
     {
         ScenarioManager.Instance.GetExtension <InputManager>().ElementSelectingSemaphore.Unlock();
     }
     didLockSemaphore = false;
     ScenarioManager.Instance.SelectedElement = selectedElement;
     selectedElement = null;
 }
Beispiel #28
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            base.CopyProperties(origin);
            var originWaypoint = origin.GetComponent <ScenarioAgentWaypoint>();

            if (originWaypoint == null)
            {
                return;
            }

            //Clear triggers object
            LinkedTrigger.Deinitalize();
            LinkedTrigger.Initialize();
            WaitTime = originWaypoint.WaitTime;
            LinkedTrigger.CopyProperties(originWaypoint.LinkedTrigger);
        }
Beispiel #29
0
        /// <inheritdoc/>
        public void CopyProperties(ScenarioElement originElement)
        {
            var originAgent = (ScenarioAgent)originElement;
            var origin      = originAgent.GetExtension <AgentDestinationPoint>();

            if (origin == null)
            {
                return;
            }
            var destinationPoint = ParentAgent.GetComponentInChildren <ScenarioDestinationPoint>(true);

            if (destinationPoint != null)
            {
                destinationPoint.AttachToAgent(ParentAgent, false);
            }
        }
Beispiel #30
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            var originAgent = origin as ScenarioAgent;

            if (originAgent == null)
            {
                throw new ArgumentException(
                          $"Invalid origin scenario element type ({origin.GetType().Name}) when cloning {GetType().Name}.");
            }
            base.CopyProperties(origin);
            foreach (var originExtension in originAgent.Extensions)
            {
                var extension = GetOrAddExtension(originExtension.Value.GetType());
                extension.CopyProperties(originAgent);
            }
            ScenarioManager.Instance.GetExtension <ScenarioAgentsManager>().RegisterAgent(this);
        }
Beispiel #31
0
 public void del(ScenarioElement t)
 {
     //scenario.Remove(t);
 }