예제 #1
0
 /// <inheritdoc/>
 void IDragHandler.DragCancelled()
 {
     if (draggedInstance == null)
     {
         return;
     }
     draggedInstance.RemoveFromMap();
     draggedInstance.Dispose();
     draggedInstance = null;
 }
예제 #2
0
        /// <inheritdoc/>
        void IDragHandler.DragStarted()
        {
            var inputManager = ScenarioManager.Instance.GetExtension <InputManager>();

            draggedInstance = GetElementInstance(selectedVariant);
            draggedInstance.transform.SetParent(ScenarioManager.Instance.transform);
            draggedInstance.transform.SetPositionAndRotation(inputManager.MouseRaycastPosition,
                                                             Quaternion.Euler(0.0f, 0.0f, 0.0f));
            ScenarioManager.Instance.SelectedElement = draggedInstance;
            OnDraggedInstanceMove();
        }
예제 #3
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            var originWaypoint = origin.GetComponent <ScenarioWaypoint>();

            if (originWaypoint == null)
            {
                return;
            }
            //Clear triggers object
            LinkedTrigger.Deinitalize();
            LinkedTrigger.Initialize();
            CopyProperties(originWaypoint, true);
        }
예제 #4
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            var originTrigger = origin as ScenarioTrigger;

            if (originTrigger == null)
            {
                ScenarioManager.Instance.logPanel.EnqueueWarning($"Cannot copy properties from {origin.ElementType} to {ElementType}.");
                return;
            }

            TargetAgentType = originTrigger.TargetAgentType;
            ClearEffectors();
            var effectorsAdded = new List <TriggerEffector>();

            foreach (var effectorObject in originTrigger.effectorsObjects)
            {
                if (effectorObject.Value.IsEmpty)
                {
                    continue;
                }
                if (!effectorsObjects.TryGetValue(effectorObject.Key, out var scenarioEffector))
                {
                    var effectorOrigin =
                        originTrigger.Trigger.Effectors.Find(e => e.TypeName == effectorObject.Key);
                    var cloneEffector = effectorOrigin.Clone() as TriggerEffector;
                    scenarioEffector = new ScenarioEffector();
                    effectorsObjects.Add(effectorObject.Key, scenarioEffector);
                    scenarioEffector.Initialize(this, cloneEffector);
                    Trigger.AddEffector(cloneEffector);
                    effectorsAdded.Add(effectorOrigin);
                }

                scenarioEffector.CopyProperties(effectorObject.Value);
            }

            foreach (var effector in originTrigger.Trigger.Effectors)
            {
                if (effectorsAdded.Contains(effector))
                {
                    continue;
                }
                var cloneEffector = effector.Clone() as TriggerEffector;
                Trigger.AddEffector(cloneEffector);
            }
        }
예제 #5
0
        /// <inheritdoc/>
        public override void CopyProperties(ScenarioElement origin)
        {
            var originWithVariant = origin as ScenarioElementWithVariant;

            if (originWithVariant == null)
            {
                throw new ArgumentException(
                          $"Could not cast copied element to {nameof(ScenarioElementWithVariant)} type.");
            }
            source  = originWithVariant.source;
            variant = originWithVariant.variant;
            for (var i = 0; i < transform.childCount; i++)
            {
                var child = transform.GetChild(i);
                if (child.name == modelObjectName)
                {
                    modelInstance = child.gameObject;
                }
            }
        }
예제 #6
0
 /// <inheritdoc/>
 void IDragHandler.DragFinished()
 {
     ScenarioManager.Instance.GetExtension <ScenarioUndoManager>()
     .RegisterRecord(new UndoAddElement(draggedInstance));
     draggedInstance = null;
 }