Example #1
0
 public override void Interact(IInteractive with)
 {
     if (with is Playground)
     {
         var playground = with as Playground;
         PlaygroundBlock block = playground.FindBlockContaining(CenterPosition);
         if (block is GroundBlock || block is FixedGroundBlock)
         {
             Game.Level.Playground.UpdateGround(true);
             _onPath = false;
         }
         if (block is WaterBlock)
         {
             playground.ReplaceWithPath(block);
             _onPath = true;
         }
         if (block is PathBlock)
         {
             if (playground.Path.Count != 0)
             {
                 PathBlock lastInPath = playground.Path.Last();
                 if (lastInPath != block)
                     Destroy();
             }
         }
     }
 }
        private static void AddToElement(IInteractive element, EventType eventType)
        {
            var win = new ChangeObjVisibilityWindow();
            if (win.ShowDialog() != true) return;

            var action = new ChangeObjectVisibility(eventType, win.ChosenVis, element.ObjectId, win.SelObject.ObjectId);
            element.AddAction(action);

            var mainWin = DesignerMainWindow.GetInstance();
            var currentSlideNr = mainWin.GetCurrentSlideNr();
            mainWin.canMainCanvas.SaveAllSlideData(Practice.GetInstance().GetSlideByPosition(currentSlideNr));
        }
Example #3
0
        private static void AddToElement(IInteractive element, EventType eventType)
        {
            var w = new JumpToSlideWindow();
            if (w.ShowDialog() != true) return;

            var slideId = Practice.GetInstance().GetSlideByPosition(w.SelectedSlideIndex).SlideId;
            var action = new ChangeSlide(eventType, slideId, element.ObjectId);
            element.AddAction(action);

            var mainWin = DesignerMainWindow.GetInstance();
            var currentSlideNr = mainWin.GetCurrentSlideNr();
            mainWin.canMainCanvas.SaveAllSlideData(Practice.GetInstance().GetSlideByPosition(currentSlideNr));
        }
Example #4
0
        public static void AddToElement(IInteractive element, EventType eventType)
        {
            var win = new AddPlayVideoActionWindow();
            if (win.ShowDialog() != true) return;

            Video vid = win.Video;
            var action = new PlayVideo(eventType, element.ObjectId, vid.ObjectId);
            element.AddAction(action);

            DesignerMainWindow mainWin = DesignerMainWindow.GetInstance();
            int currentSlideNr = mainWin.GetCurrentSlideNr();
            mainWin.canMainCanvas.SaveAllSlideData(Practice.GetInstance().GetSlideByPosition(currentSlideNr));
        }
Example #5
0
 public override void Interact(IInteractive with)
 {
     if (with is MainDevice)
     {
         Improve(with as MainDevice);
     }
     else
     {
         if (with is IEnemy)
         {
             Destroy();
         }
     }
 }
Example #6
0
 public override void Interact(IInteractive with)
 {
     var moveable = with as IMoveable;
     if (moveable == null)
         return;
     if (moveable is MainDevice)
     {
         moveable.Stop();
     }
     /*else
     {
         //что-то другое
     }*/
 }
Example #7
0
 public override void Interact(IInteractive with)
 {
     if (with is MainDevice)
         Game.PlayerDevice.Destroy();
     if (Reflected)
         return;
     if (with is PlaygroundBlock && !(with is WaterBlock))
     {
         //Stop();
         Vector2 newDirection = Vector2.Reflect(Direction, (with as PlaygroundBlock).GetNormal(this));
         Vector2 target = newDirection*10000;
         MoveTo(target);
         Reflected = true;
     }
     base.Interact(with);
 }
Example #8
0
        private static void PointerPressed(RoutedEventArgs ev)
        {
            if (ev.Route == RoutingStrategies.Bubble)
            {
                var e = (PointerPressedEventArgs)ev;

                if (e.ClickCount <= 1)
                {
                    s_lastPress = e.Source;
                }
                else if (e.ClickCount == 2 && s_lastPress == e.Source)
                {
                    e.Source.RaiseEvent(new RoutedEventArgs(DoubleTappedEvent));
                }
            }
        }
 public void Down(IInteractive target, MouseButton mouseButton = MouseButton.Left, Point position = default,
                  InputModifiers modifiers = default, int clickCount = 1)
 {
     Down(target, target, mouseButton, position, modifiers, clickCount);
 }
Example #10
0
 public static void AddDoubleTappedHandler(IInteractive element, EventHandler <RoutedEventArgs> handler)
 {
     element.AddHandler(DoubleTappedEvent, handler);
 }
Example #11
0
        public bool OnMouseMove(MouseEventArgs e)
        {
            bool handled = false;
            int  deltaX  = e.X - m_LastMousePosition.X;
            int  deltaY  = e.Y - m_LastMousePosition.Y;

            if (isResizingTop || isResizingUL || isResizingUR)
            {
                m_Location.Y  += deltaY;
                m_Size.Height -= deltaY;
            }
            else if (isResizingBottom || isResizingLL || isResizingLR)
            {
                m_Size.Height += deltaY;
            }
            else if (isResizingRight || isResizingUR || isResizingLR)
            {
                m_Size.Width += deltaX;
            }
            else if (isResizingLeft || isResizingUL || isResizingLL)
            {
                m_Location.X += deltaX;
                m_Size.Width -= deltaX;
            }
            else if (m_IsDragging)
            {
                m_Location.X += deltaX;
                m_Location.Y += deltaY;

                if (m_Location.X < 0)
                {
                    m_Location.X = 0;
                }
                if (m_Location.Y < 0)
                {
                    m_Location.Y = 0;
                }
                if (m_Location.Y + m_Size.Height
                    > DrawArgs.StaticParentControl.Height)
                {
                    m_Location.Y = DrawArgs.StaticParentControl.Height - m_Size.Height;
                }
                if (m_Location.X + m_Size.Width
                    > DrawArgs.StaticParentControl.Width)
                {
                    m_Location.X = DrawArgs.StaticParentControl.Width - m_Size.Width;
                }

                handled = true;
            }

            if (m_Size.Width
                < minSize.Width)
            {
                m_Size.Width = minSize.Width;
            }

            if (m_Size.Height
                < minSize.Height)
            {
                m_Size.Height = minSize.Height;
            }

            m_LastMousePosition = new Point(e.X, e.Y);

            for (int i = 0; i < m_ChildWidgets.Count; i++)
            {
                if (m_ChildWidgets[i] is IInteractive)
                {
                    IInteractive currentInteractive = m_ChildWidgets[i] as IInteractive;
                    handled = currentInteractive.OnMouseMove(e);
                }
            }

            bool inClientArea = false;

            if (e.X >= m_Location.X && e.X <= m_Location.X + m_Size.Width && e.Y >= m_Location.Y &&
                e.Y <= m_Location.Y + m_Size.Height)
            {
                inClientArea = true;
            }

            if (!handled && inClientArea)
            {
                handled = true;
            }
            return(handled);
        }
 public virtual bool Intersects(IInteractive with)
 {
     return BoundingShape.Intersects(with.BoundingShape);
 }
Example #13
0
 public RoutedEventArgs(RoutedEvent routedEvent, IInteractive source)
 {
     this.RoutedEvent = routedEvent;
     this.Source = this.OriginalSource = source;
 }
Example #14
0
 public static void AddToElement(IInteractive element, EventType eventType)
 {
     throw new NotImplementedException();
 }
 private void InteractiveBB84Closed(IInteractive interactive)
 {
     channelClassicExplorer.Close();
     channelQuantumExplorer.Close();
 }
Example #16
0
        public Vector2 GetNormal(IInteractive obj)
        {
            var corners = new Vector2[4];
            corners[0] = Position;
            corners[1] = Position + new Vector2(Width, 0);
            corners[2] = Position + new Vector2(Width, Height);
            corners[3] = Position + new Vector2(0, Height);

            var distances = new double[4];
            BoundingShape boundingShape = obj.BoundingShape;
            Vector2 direction = GameObjectHelper.GetDirection((IDrawable) this, (IDrawable) obj);
            if (boundingShape.Intersects(_boundingRectangle))
                while (boundingShape.Intersects(_boundingRectangle))
                    obj.Position -= direction;
            distances[0] = ((corners[0] - obj.CenterPosition).Length() + (corners[1] - obj.CenterPosition).Length())/
                           (double) 2;
            distances[1] = ((corners[1] - obj.CenterPosition).Length() + (corners[2] - obj.CenterPosition).Length())/
                           (double) 2;
            distances[2] = ((corners[2] - obj.CenterPosition).Length() + (corners[3] - obj.CenterPosition).Length())/
                           (double) 2;
            distances[3] = ((corners[3] - obj.CenterPosition).Length() + (corners[0] - obj.CenterPosition).Length())/
                           (double) 2;
            double minValue = double.MaxValue;
            int minIndex = 0;
            for (int i = 0; i < distances.Length; i++)
            {
                if (distances[i] < minValue)
                {
                    minValue = distances[i];
                    minIndex = i;
                }
            }
            switch (minIndex)
            {
                case 0:
                    return new Vector2(0, -1);
                case 1:
                    return new Vector2(1, 0);
                case 2:
                    return new Vector2(0, 1);
                case 3:
                    return new Vector2(-1, 0);
            }
            throw new InvalidOperationException();
        }
Example #17
0
 public virtual void HandlerPointerClick(IInteractive interactive, InputData data)
 {
 }
Example #18
0
 public FullscreenModeChangeEventArgs(IInteractive source, bool fullscreen)
     : base(CustomWebView.FullscreenEvent, source)
 {
     this.Fullscreen = fullscreen;
 }
Example #19
0
 private void OnInterationFinished(IInteractive obj)
 {
     _interactingWith = null;
     _target          = null;
 }
Example #20
0
 public void SetTarget(IInteractive target)
 {
     UnityEngine.Debug.Log("Target -> " + target?.Transform.name);
     _target = target;
 }
Example #21
0
 void OnTriggerExit(Collider other)
 {
     if(other.CompareTag("Interactive")){
         CurInteract = null;
     }else if(other.CompareTag("Trigger")){
         ITrigger it = other.GetComponent<ITrigger>();
         if(it != null){
             it.OnExitTrigger(gameObject);
         }
     }
 }
 public void Move(IInteractive target, IInteractive source, in Point position, InputModifiers modifiers = default)
Example #23
0
 public List<PlaygroundBlock> BlocksIntersects(IInteractive interactive)
 {
     //todo: ужс
     _forIntersectionsBuffer.Clear();
     Vector2 position = interactive.BoundingShape.Position;
     float width = interactive.BoundingShape.Width;
     float height = interactive.BoundingShape.Height;
     float widthBlocksNumber = width/Settings.Instance.PlaygroundBlockWidth + 1;
     float heightBlockNumber = height/Settings.Instance.PlaygroundBlockHeight + 1;
     int n = (int) (position.Y - _position.Y)/Settings.Instance.PlaygroundBlockHeight;
     int m = (int) (position.X - _position.X)/Settings.Instance.PlaygroundBlockWidth;
     if (n < 0) n = 0;
     if (n > _height) n = _height;
     if (m < 0) m = 0;
     if (m > _width) m = _width;
     float rowNumber = n + heightBlockNumber > _height ? _height : n + heightBlockNumber;
     float colNumber = m + widthBlocksNumber > _width ? _width : m + widthBlocksNumber;
     for (int i = n; i < rowNumber; i++)
     {
         for (int j = m; j < colNumber; j++)
         {
             if (_blocks[i, j].Intersects(interactive))
                 _forIntersectionsBuffer.Add(_blocks[i, j]);
         }
     }
     return _forIntersectionsBuffer;
 }
Example #24
0
 /// <summary>
 /// sets PropertyDescriptor
 /// </summary>
 /// <param name="routedEvent"></param>
 /// <param name="source"></param>
 /// <param name="propertyDescriptor"></param>
 public PropertyEditingEventArgs(RoutedEvent routedEvent, IInteractive source, PropertyDescriptor propertyDescriptor)
     : base(routedEvent, source)
 {
     PropertyDescriptor = propertyDescriptor;
 }
Example #25
0
 public override void Interact(IInteractive with)
 {
     if (with is IEnemy && ((IEnemy) with).CanWalkOnWater)
         Game.Level.Playground.StartDeadPath(this);
 }
Example #26
0
 public override void Interact(IInteractive with)
 {
     if (Reflected)
         return;
     if (with is Ball && !(with is IBonus))
     {
         var ball = with as Ball;
         Vector2 penetrationDirection = (CenterPosition - ball.CenterPosition);
         penetrationDirection.Normalize();
         Stop();
         MoveTo(penetrationDirection*1000);
         ball.Stop();
         ball.MoveTo(-penetrationDirection*1000);
         //Reflected = true;
         //ball.Reflected = true;
     }
 }
Example #27
0
        // Update is called once per frame
        void Update()
        {
            if (!isLocalPlayer)
                return;

            // Search for interactive objects
            InteractiveObject = null;

            RaycastHit hit;

            if (Physics.Raycast(fpsCamera.transform.position, fpsCamera.transform.TransformDirection(Vector3.forward), out hit, 4))
            {
                InteractiveObject = hit.collider.gameObject.GetComponent(typeof(IInteractive)) as IInteractive;

                if (InteractiveObject != null && InteractiveObject.IsActive == false)
                    InteractiveObject = null;
            }

            if ((InteractiveObject != null) && (InputController.Use))
            {
                InteractiveObject.Interact(this);
            }

            // Mana regeneration;
            //if (Time.time - manaRegenerationTime > baseManaRegeenrationDeleay - (baseManaRegeenrationDeleay * 0.05 * experience.Mind))
            //{
            //    Mana++;
            //    manaRegenerationTime = Time.time;
            //}
        }
Example #28
0
    /// <summary>
    /// Event Handler for DetectLookedAtInteractive.LookedAtInteractiveChanged
    /// </summary>
    /// <param name="newLookedAtInteractive">Reference to the new IInteractive that the player is looking at.</param>

    private void OnLookedAtInteractiveChanged(IInteractive newLookedAtInteractive)
    {
        lookedAtInteractive = newLookedAtInteractive;
    }
Example #29
0
 /// <summary>
 /// Adds a handler for the <see cref="PdfPrintFinished"/> attached event.
 /// </summary>
 /// <param name="element">An object that raise the <see cref="PdfPrintFinished"/> routed event.</param>
 /// <param name="handler">The handler.</param>
 public static void AddStatusTextChangedHandler(IInteractive element, EventHandler <EventArgs> handler)
 {
     element?.AddHandler(PdfPrintFinishedEvent, handler);
 }
Example #30
0
 public FullscreenModeChangeEventArgs(IInteractive source, bool fullscreen) : base(WebViewBase.FullscreenEvent, source)
 {
     Fullscreen = fullscreen;
 }
Example #31
0
        public bool OnMouseUp(MouseEventArgs e)
        {
            bool handled = false;

            if (e.Button
                == MouseButtons.Left)
            {
                if (m_IsDragging)
                {
                    m_IsDragging = false;
                }
            }

            bool inClientArea = false;

            if (e.X >= m_Location.X && e.X <= m_Location.X + m_Size.Width && e.Y >= m_Location.Y &&
                e.Y <= m_Location.Y + m_Size.Height)
            {
                inClientArea = true;
            }

            if (inClientArea)
            {
                if (isPointInCloseBox(new Point(e.X, e.Y)))
                {
                    Visible = false;
                    handled = true;
                }
            }

            for (int i = 0; i < m_ChildWidgets.Count; i++)
            {
                if (m_ChildWidgets[i] is IInteractive)
                {
                    IInteractive currentInteractive = m_ChildWidgets[i] as IInteractive;
                    handled = currentInteractive.OnMouseUp(e);
                }
            }

            if (!handled && inClientArea)
            {
                handled = true;
            }

            if (isResizingTop)
            {
                isResizingTop = false;
            }
            if (isResizingBottom)
            {
                isResizingBottom = false;
            }
            if (isResizingLeft)
            {
                isResizingLeft = false;
            }
            if (isResizingRight)
            {
                isResizingRight = false;
            }
            if (isResizingUL)
            {
                isResizingUL = false;
            }
            if (isResizingUR)
            {
                isResizingUR = false;
            }
            if (isResizingLL)
            {
                isResizingLL = false;
            }
            if (isResizingLR)
            {
                isResizingLR = false;
            }

            return(handled);
        }
Example #32
0
 private KeyEventArgs CreateKeyDownEvent(Key key, IInteractive source = null)
 {
     return(new KeyEventArgs {
         RoutedEvent = InputElement.KeyDownEvent, Key = key, Source = source
     });
 }
 private void FixedUpdate()
 {
     LookedAtInteractive = GetLookedAtInteractive();
 }
Example #34
0
        public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            if (m_visible)
            {
                // if we're in the client area
                if (e.X >= this.AbsoluteLocation.X &&
                    e.X <= this.AbsoluteLocation.X + ClientSize.Width &&
                    e.Y >= this.AbsoluteLocation.Y &&
                    e.Y <= this.AbsoluteLocation.Y + NODE_HEIGHT)
                {
                    if (m_isMouseDown)
                    {
                        // if we're in the expand arrow region
                        if ((e.X > this.AbsoluteLocation.X + m_xOffset) &&
                            (e.X < this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE))
                        {
                            this.Expanded = !this.Expanded;

                            // call helper routine if it exists
                            if (m_expandClickAction != null)
                            {
                                m_expandClickAction(e);
                            }
                        }
                        // else if we're supposed to use checkmark and we're in the activate/deactivate region
                        else if (m_enableCheck &&
                                 (e.X > this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE) &&
                                 (e.X < this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE + NODE_CHECKBOX_SIZE))
                        {
                            this.Enabled = !this.Enabled;

                            // call helper routine if it exists
                            if (m_checkClickAction != null)
                            {
                                m_checkClickAction(e);
                            }
                        }
                        // Otherwise perform general LMB, RMB action
                        else if ((e.Button == System.Windows.Forms.MouseButtons.Left) && (m_leftClickAction != null))
                        {
                            m_leftClickAction(e);
                        }
                        else if ((e.Button == System.Windows.Forms.MouseButtons.Right) && (m_rightClickAction != null))
                        {
                            m_rightClickAction(e);
                        }

                        handled = true;
                    }
                }
            }

            // if mouse isn't over us, let the children try as we should be inside the top form client area
            if (!handled)
            {
                for (int i = 0; i < m_subNodes.Count; i++)
                {
                    if (m_subNodes[i] is IInteractive)
                    {
                        IInteractive currentInteractive = m_subNodes[i] as IInteractive;
                        bool         subHandled         = currentInteractive.OnMouseUp(e);
                        if (subHandled)
                        {
                            handled = true;
                        }
                    }

                    // if anyone has handled this, we're done
                    //if (handled)
                    //	break;
                }
            }

            // regardless reset mousedown point
            m_isMouseDown = false;

            return(handled);
        }
Example #35
0
 public static void RemoveRightTappedHandler(IInteractive element, EventHandler <RoutedEventArgs> handler)
 {
     element.RemoveHandler(RightTappedEvent, handler);
 }
 private bool ElemHasOnlyDropAct(IInteractive element)
 {
     return element.Actions.All(act => act.Type == ActionType.dropObject);
 }
 public void Move(IInteractive target, in Point position, InputModifiers modifiers = default) => Move(target, target, position, modifiers);
Example #38
0
 /// <summary>
 /// Gets the route for tunneling events from the specified interactive.
 /// </summary>
 /// <param name="interactive">The interactive.</param>
 /// <returns>The event route.</returns>
 public static IEnumerable <IInteractive> GetTunnelEventRoute(this IInteractive interactive)
 {
     return(interactive.GetBubbleEventRoute().Reverse());
 }
Example #39
0
 /// <summary>
 /// Event handler for DetectLookedAtInteractive.LookedAtInteractiveChanged
 /// </summary>
 /// <param name="newLookedAtInteractive">Reference to the new Interactive the player is looking at.</param>
 private void OnLookedAtInteractiveChanged(IInteractive newLookedAtInteractive)
 {
     lookedAtInteractive = newLookedAtInteractive;
     UpdateDisplayText();
 }
Example #40
0
 /// <summary>
 /// Removes a handler for the <see cref="PdfPrintFinished"/> attached event.
 /// </summary>
 /// <param name="element">An object that raise the <see cref="PdfPrintFinished"/> routed event.</param>
 /// <param name="handler">The handler.</param>
 public static void RemovePdfPrintFinishedHandler(IInteractive element, EventHandler <PdfPrintFinishedRoutedEventArgs> handler)
 {
     element?.RemoveHandler(PdfPrintFinishedEvent, handler);
 }
Example #41
0
 public override void Interact(IInteractive with)
 {
     Debug.Assert(Intersects(with));
     if (!_rectangle.Intersects(with.BoundingShape)) return;
     List<PlaygroundBlock> blocks = BlocksIntersects(with);
     foreach (PlaygroundBlock playgroundBlock in blocks)
     {
         playgroundBlock.Interact(with);
         with.Interact(playgroundBlock);
     }
 }
Example #42
0
 /// <summary>
 /// Removes a handler for the <see cref="StatusTextChanged"/> attached event.
 /// </summary>
 /// <param name="element">An object that raise the <see cref="StatusTextChanged"/> routed event.</param>
 /// <param name="handler">The handler.</param>
 public static void RemoveStatusTextChangedHandler(IInteractive element, EventHandler <EventArgs> handler)
 {
     element?.RemoveHandler(StatusTextChangedEvent, handler);
 }
 public virtual void Interact(IInteractive with)
 {
 }
Example #44
0
 /// <summary>
 /// Removes a handler for the <see cref="ScriptDialogOpening"/> attached event.
 /// </summary>
 /// <param name="element">An object that raise the <see cref="ScriptDialogOpening"/> routed event.</param>
 /// <param name="handler">The handler.</param>
 public static void RemoveScriptDialogOpeningHandler(IInteractive element, EventHandler <ScriptDialogOpeningRoutedEventArgs> handler)
 {
     element?.RemoveHandler(ScriptDialogOpeningEvent, handler);
 }
Example #45
0
 public override void Interact(IInteractive with)
 {
     if (with is HardBall)
         Playground.ReplaceWithWater(this);
 }
Example #46
0
    /// <summary>
    /// Загрузка игры
    /// </summary>
    public void LoadGame()
    {
        SavesInfo savesInfo = Serializator.DeXmlSavesInfo(savesInfoPath);

        if (!Serializator.HasSavesInfo(savesInfoPath))
        {
            return;
        }
        if (savesInfo == null)
        {
            return;
        }
        if (!savesInfo.saves[profileNumber].hasData)
        {
            return;
        }
        GameData gData = Serializator.DeXml(datapath + profileNumber.ToString() + ".xml");

        if (gData == null)
        {
            return;
        }
        savesInfo.saves[profileNumber].loadSceneName = SceneManager.GetActiveScene().name;

        GameGeneralData gGData = gData.gGData;
        LevelData       lData  = gData.lData;
        GameStatistics  gStats = GetComponent <GameStatistics>();

        #region GeneralLoad

        if (lData == null? true: !lData.active)//Произошёл переход на новый уровень и нужно учесть только данные, необходимые на протяжении всей игры
        {
            if (gGData != null)
            {
                startCheckpointNumber = gGData.firstCheckpointNumber;
                HeroController hero = SpecialFunctions.player.GetComponent <HeroController>();

                //Сначала переместим главного героя к последнему чекпоинту
                CheckpointController currentCheckpoint = checkpoints.Find(x => (x.checkpointNumb == startCheckpointNumber));
                if (currentCheckpoint != null)
                {
                    SpecialFunctions.MoveToCheckpoint(currentCheckpoint);
                }

                #region heroEquipment

                EquipmentInfo eInfo = gGData.eInfo;
                if (eInfo != null && gStats != null)
                {
                    if (gStats.WeaponDict.ContainsKey(eInfo.weapon))
                    {
                        hero.SetItem(gStats.WeaponDict[eInfo.weapon], true);
                    }
                    foreach (string itemName in eInfo.bagItems)
                    {
                        hero.Bag.Clear();
                        if (gStats.ItemDict.ContainsKey(itemName))
                        {
                            hero.Bag.Add(gStats.ItemDict[itemName]);
                        }
                    }
                }

                GetComponent <GameStatistics>().ResetStatistics();

                #endregion //heroEquipment
            }
        }

        #endregion //GeneralLoad

        #region LevelLoad

        else//Если игрок сохранился на чекпоинте, то у него есть прогресс на уровне и именно его мы и загружаем
        {
            HeroController hero = SpecialFunctions.player.GetComponent <HeroController>();

            //Сначала переместим главного героя к последнему чекпоинту
            CheckpointController currentCheckpoint = checkpoints.Find(x => (x.checkpointNumb == lData.checkpointNumber));
            if (currentCheckpoint != null)
            {
                SpecialFunctions.MoveToCheckpoint(currentCheckpoint);
            }

            #region heroEquipment

            EquipmentInfo eInfo = lData.eInfo;
            if (eInfo != null && gStats != null)
            {
                if (gStats.WeaponDict.ContainsKey(eInfo.weapon))
                {
                    hero.SetItem(gStats.WeaponDict[eInfo.weapon], true);
                }
                foreach (string itemName in eInfo.bagItems)
                {
                    hero.Bag.Clear();
                    if (gStats.ItemDict.ContainsKey(itemName))
                    {
                        hero.Bag.Add(gStats.ItemDict[itemName]);
                    }
                }
            }

            #endregion //heroEquipment

            GameHistory gHistory = GetComponent <GameHistory>();
            History     history  = gHistory != null? gHistory.history:null;

            #region Quests&Story

            QuestInfo qInfo = lData.qInfo;
            StoryInfo sInfo = lData.sInfo;
            if (qInfo != null && sInfo != null && history != null)
            {
                history.LoadHistory(sInfo, qInfo);
            }

            #endregion //Quests&Story

            #region levelStatistics

            LevelStatsData lStatsInfo = lData.lStatsInfo;
            if (lStatsInfo != null && gStats != null)
            {
                gStats.LoadStaticstics(lStatsInfo);
                gStats.InitializeAllStatistics();
            }

            #endregion //levelStatistics

            #region Drop

            DropData dropInfo = lData.dropInfo;

            //Сначала надо уничтожить все объекты типа drop на уровне
            GameObject[] drops = GameObject.FindGameObjectsWithTag("drop");
            for (int i = drops.Length - 1; i >= 0; i--)
            {
                DestroyImmediate(drops[i]);
            }
            drops = GameObject.FindGameObjectsWithTag("heartDrop");
            for (int i = drops.Length - 1; i >= 0; i--)
            {
                DestroyImmediate(drops[i]);
            }

            //А затем заново их создать
            if (dropInfo != null && gStats != null)
            {
                foreach (DropInfo _dInfo in dropInfo.drops)
                {
                    if (gStats.DropDict.ContainsKey(_dInfo.itemName) && !_dInfo.customDrop)
                    {
                        Instantiate(gStats.DropDict[_dInfo.itemName], _dInfo.position, Quaternion.identity);
                    }
                    else if (gStats.WeaponDict.ContainsKey(_dInfo.itemName))
                    {
                        GameObject newDrop = Instantiate(gStats.itemBase.customDrop, _dInfo.position, Quaternion.identity) as GameObject;
                        newDrop.GetComponent <DropClass>().item = gStats.WeaponDict[_dInfo.itemName];
                    }
                    else if (gStats.ItemDict.ContainsKey(_dInfo.itemName))
                    {
                        GameObject newDrop = Instantiate(gStats.itemBase.customDrop, _dInfo.position, Quaternion.identity) as GameObject;
                        newDrop.GetComponent <DropClass>().item = gStats.ItemDict[_dInfo.itemName];
                    }
                }
            }

            #endregion //Drop

            #region Enemies

            List <EnemyData> enInfo = lData.enInfo;

            if (enInfo != null && monsters != null)
            {
                foreach (EnemyData enData in enInfo)
                {
                    int objId = enData.objId;
                    if (objId < monsters.Count? monsters[objId] != null:false)
                    {
                        monsters[objId].SetAIData(enData);
                        monsters[objId] = null;
                    }
                }
                for (int i = 0; i < monsters.Count; i++)
                {
                    if (monsters[i] != null)
                    {
                        DestroyImmediate(monsters[i].gameObject);
                    }
                }
            }

            #endregion //Enemies

            #region InteractiveObjects

            List <InterObjData> intInfo = lData.intInfo;

            if (intInfo != null && intObjects != null)
            {
                foreach (InterObjData interData in intInfo)
                {
                    int objId = interData.objId;
                    if (objId < intObjects.Count ? intObjects[objId] != null : false)
                    {
                        IInteractive iInter = intObjects[objId].GetComponent <IInteractive>();
                        IMechanism   iMech  = intObjects[objId].GetComponent <IMechanism>();
                        IDamageable  iDmg   = intObjects[objId].GetComponent <IDamageable>();
                        if (iInter != null)
                        {
                            iInter.SetData(interData);
                        }
                        else if (iMech != null)
                        {
                            iMech.SetData(interData);
                        }
                        else if (iDmg != null)
                        {
                            iDmg.SetData(interData);
                        }
                        intObjects[objId] = null;
                    }
                }
                for (int i = 0; i < intObjects.Count; i++)
                {
                    if (intObjects[i] != null)
                    {
                        ChestController      chest      = intObjects[i].GetComponent <ChestController>();
                        CheckpointController checkpoint = intObjects[i].GetComponent <CheckpointController>();
                        if (chest != null)
                        {
                            chest.DestroyClosedChest();
                        }
                        else if (checkpoint != null)
                        {
                            checkpoint.DestroyCheckpoint();
                        }
                        else
                        {
                            DestroyImmediate(intObjects[i]);
                        }
                    }
                }
            }

            #endregion //InteractiveObjects

            #region NPCs

            List <NPCData> npcInfo = lData.npcInfo;

            if (npcInfo != null && NPCs != null)
            {
                foreach (NPCData npcData in npcInfo)
                {
                    int objId = npcData.objId;
                    if (objId < NPCs.Count ? NPCs[objId] != null : false)
                    {
                        NPCs[objId].SetData(npcData);
                        NPCs[objId] = null;
                    }
                }
                for (int i = 0; i < NPCs.Count; i++)
                {
                    if (NPCs[i] != null)
                    {
                        DestroyImmediate(NPCs[i].gameObject);
                    }
                }
            }

            #endregion //NPCs
        }

        #endregion //LevelLoad

        /*
         * //Сначала переместим главного героя к последнему чекпоинту
         * CheckpointController currentCheckpoint = checkpoints.Find(x => (x.checkpointNumb == PlayerPrefs.GetInt("Checkpoint Number")));
         * if (currentCheckpoint != null)
         *  SpecialFunctions.MoveToCheckpoint(currentCheckpoint);
         */
    }
Example #47
0
 public RoutedEventArgs(RoutedEvent routedEvent, IInteractive source)
 {
     RoutedEvent = routedEvent;
     Source = source;
 }
Example #48
0
 public override void Interact(IInteractive with)
 {
     if (with is MainDevice)
         (with as MainDevice).Destroy();
 }
        /// <summary>
        /// Updates the selection based on an event that may have originated in a container that 
        /// belongs to the control.
        /// </summary>
        /// <param name="eventSource">The control that raised the event.</param>
        /// <param name="select">Whether the container should be selected or unselected.</param>
        /// <param name="rangeModifier">Whether the range modifier is enabled (i.e. shift key).</param>
        /// <param name="toggleModifier">Whether the toggle modifier is enabled (i.e. ctrl key).</param>
        /// <returns>
        /// True if the event originated from a container that belongs to the control; otherwise
        /// false.
        /// </returns>
        protected bool UpdateSelectionFromEventSource(
            IInteractive eventSource, 
            bool select = true,
            bool rangeModifier = false,
            bool toggleModifier = false)
        {
            var container = GetContainerFromEventSource(eventSource);

            if (container != null)
            {
                UpdateSelection(container, select, rangeModifier, toggleModifier);
                return true;
            }

            return false;
        }
Example #50
0
        /// <summary>
        /// Tries to set the selection to a container that raised an event.
        /// </summary>
        /// <param name="eventSource">The control that raised the event.</param>
        /// <param name="select">Whether the container should be selected or unselected.</param>
        private void TrySetSelectionFromContainerEvent(IInteractive eventSource, bool select)
        {
            var item = GetContainerFromEvent(eventSource);

            if (item != null)
            {
                var index = ItemContainerGenerator.IndexFromContainer(item);

                if (index != -1)
                {
                    if (select)
                    {
                        SelectedIndex = index;
                    }
                    else
                    {
                        LostSelection();
                    }
                }
            }
        }
Example #51
0
 /// <summary>
 /// Removes a handler for the <see cref="TextFound"/> attached event.
 /// </summary>
 /// <param name="element">An object that raise the <see cref="TextFound"/> routed event.</param>
 /// <param name="handler">The handler.</param>
 public static void RemoveTextFoundHandler(IInteractive element, EventHandler <TextFoundRoutedEventArgs> handler)
 {
     element?.RemoveHandler(TextFoundEvent, handler);
 }
Example #52
0
 public async Task <PolloiResult> RangedAttack(IInteractive objectToAttack)
 {
     return(await ServerConnection.GetConnection().InvokeAsync <PolloiResult>(PolloiActions.RangedAttack, Uid, objectToAttack.Uid));
 }
Example #53
0
        /// <summary>
        /// Tries to get the container that was the source of an event.
        /// </summary>
        /// <param name="eventSource">The control that raised the event.</param>
        /// <returns>The container or null if the event did not originate in a container.</returns>
        protected IControl GetContainerFromEventSource(IInteractive eventSource)
        {
            var item = ((IVisual)eventSource).GetSelfAndVisualAncestors()
                .OfType<TreeViewItem>()
                .FirstOrDefault();

            if (item != null)
            {
                if (item.ItemContainerGenerator.Index == this.ItemContainerGenerator.Index)
                {
                    return item;
                }
            }

            return null;
        }
Example #54
0
 PointerEventArgs CreateSimpleEvent(RoutedEvent ev, ulong timestamp, IInteractive source,
                                    PointerPointProperties properties,
                                    KeyModifiers inputModifiers)
 {
     return(new PointerEventArgs(ev, source, _pointer, null, default,
        /// <summary>
        /// Tries to get the container that was the source of an event.
        /// </summary>
        /// <param name="eventSource">The control that raised the event.</param>
        /// <returns>The container or null if the event did not originate in a container.</returns>
        protected IControl GetContainerFromEventSource(IInteractive eventSource)
        {
            var item = ((IVisual)eventSource).GetSelfAndVisualAncestors()
                .OfType<IControl>()
                .FirstOrDefault(x => x.LogicalParent == this && ItemContainerGenerator?.IndexFromContainer(x) != -1);

            return item as IControl;
        }
Example #56
0
        /// <summary>
        /// Mouse down event handler.
        /// </summary>
        /// <param name="e">Event args</param>
        /// <returns>If this widget handled this event</returns>
        public bool OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            // Whether or not the event was handled
            bool handled = false;

            // Whether or not we're in the form
            bool inClientArea = false;

            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            // if we're in the client area bring to front
            if (e.X >= widgetLeft &&
                e.X <= widgetRight &&
                e.Y >= widgetTop &&
                e.Y <= widgetBottom)
            {
                if (m_parentWidget != null)
                {
                    m_parentWidget.ChildWidgets.BringToFront(this);
                }

                inClientArea = true;
            }

            // if its the left mouse button check for UI actions (resize, drags, etc)
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                #region header dbl click

                // Check for header double click (if its shown)
                if (HeaderEnabled &&
                    e.X >= m_location.X &&
                    e.X <= AbsoluteLocation.X + m_size.Width &&
                    e.Y >= AbsoluteLocation.Y &&
                    e.Y <= AbsoluteLocation.Y + m_currHeaderHeight)
                {
                    if (DateTime.Now > m_LastClickTime.AddSeconds(0.5))
                    {
                        handled = true;
                    }
                    else
                    {
                        m_renderBody = !m_renderBody;
                    }
                    m_LastClickTime = DateTime.Now;
                }

                #endregion
            }

            // Store the current position
            m_LastMousePosition = new System.Drawing.Point(e.X, e.Y);

            // If we aren't handling this then let the children try if they are rendered
            if (!handled && inClientArea && m_renderBody)
            {
                for (int i = 0; i < m_ChildWidgets.Count; i++)
                {
                    if (!handled)
                    {
                        if (m_ChildWidgets[i] is IInteractive)
                        {
                            IInteractive currentInteractive = m_ChildWidgets[i] as IInteractive;
                            handled = currentInteractive.OnMouseDown(e);
                        }
                    }
                }
            }

            // If we resized or inside the form then consider it handled anyway.
            if (inClientArea)
            {
                handled = true;
            }

            return(handled);
        }
Example #57
0
        /// <summary>
        /// Tries to get the container that was the source of an event.
        /// </summary>
        /// <param name="eventSource">The control that raised the event.</param>
        /// <returns>The container or null if the event did not originate in a container.</returns>
        private IControl GetContainerFromEvent(IInteractive eventSource)
        {
            var item = ((IVisual)eventSource).GetSelfAndVisualAncestors()
                .OfType<ILogical>()
                .FirstOrDefault(x => x.LogicalParent == this);

            return item as IControl;
        }
 static PointerEventArgs CreateArgs(RoutedEvent ev, IInteractive source)
 => new PointerEventArgs(ev, source, new FakePointer(), (IVisual)source, default, 0, PointerPointProperties.None, default);
Example #59
0
        public bool OnMouseDown(MouseEventArgs e)
        {
            bool handled = false;

            bool inClientArea = false;

            if (e.X >= m_Location.X && e.X <= m_Location.X + m_Size.Width && e.Y >= m_Location.Y &&
                e.Y <= m_Location.Y + m_Size.Height)
            {
                m_ParentWidget.ChildWidgets.BringToFront(this);
                inClientArea = true;
            }

            if (e.X > AbsoluteLocation.X - resizeBuffer && e.X < AbsoluteLocation.X + resizeBuffer && e.Y > AbsoluteLocation.Y - resizeBuffer &&
                e.Y < AbsoluteLocation.Y + resizeBuffer)
            {
                isResizingUL = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width && e.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width && e.Y > AbsoluteLocation.Y - resizeBuffer &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer)
            {
                isResizingUR = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer && e.X < AbsoluteLocation.X + resizeBuffer && e.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
            {
                isResizingLL = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width && e.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width && e.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
            {
                isResizingLR = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer && e.X < AbsoluteLocation.X + resizeBuffer && e.Y > AbsoluteLocation.Y - resizeBuffer &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
            {
                isResizingLeft = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width && e.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width && e.Y > AbsoluteLocation.Y - resizeBuffer &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
            {
                isResizingRight = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer && e.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width && e.Y > AbsoluteLocation.Y - resizeBuffer &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer)
            {
                isResizingTop = true;
            }
            else if (e.X > AbsoluteLocation.X - resizeBuffer && e.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width && e.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
                     e.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
            {
                isResizingBottom = true;
            }
            else if (e.X >= m_Location.X && e.X <= AbsoluteLocation.X + ClientSize.Width && e.Y >= AbsoluteLocation.Y &&
                     e.Y <= AbsoluteLocation.Y + m_HeaderHeight)
            {
                m_IsDragging = true;
                handled      = true;
            }
            m_LastMousePosition = new Point(e.X, e.Y);

            if (!handled)
            {
                for (int i = 0; i < m_ChildWidgets.Count; i++)
                {
                    if (!handled)
                    {
                        if (m_ChildWidgets[i] is IInteractive)
                        {
                            IInteractive currentInteractive = m_ChildWidgets[i] as IInteractive;
                            handled = currentInteractive.OnMouseDown(e);
                        }
                    }
                }
            }

            if (!handled && inClientArea)
            {
                handled = true;
            }

            return(handled);
        }
Example #60
0
        private XmlElement writeActions(IInteractive o, XmlElement objectDescription, int slideID, XmlDocument doc)
        {
            foreach (ComAction action in o.Actions)
            {
                
                XmlElement actionElement = doc.CreateElement(action.Type.ToString());
                actionElement.SetAttribute("actionID", action.ActionId.ToString());
                actionElement.SetAttribute("event", action.ActionEventType.ToString());
                actionElement.SetAttribute("mandatory", action.Mandatory.ToString());

                switch (action.Type)
                {
                    case ActionType.changeSlide:
                        actionElement = writeChangeSlide(action, actionElement, slideID);
                        break;
                    case ActionType.changeVisibility:
                        actionElement = writeObjectVisibility(action, actionElement);
                        break;
                    case ActionType.playSound:
                        actionElement = writePlaySound(action, actionElement);
                        break;
                    case ActionType.playVideo:
                        actionElement = writePlayVideo(action, actionElement);
                        break;
                    case ActionType.changeFontSize:
                        actionElement = writeChangeFontSize(action, actionElement);
                        break;
                    case ActionType.dropObject:
                        continue;
                    //    actionElement = writeDropObject(action, actionElement);
                    //    break;
                    default:
                        throw new WrongActionTypeException();
                }
                objectDescription.AppendChild(actionElement);
            }
            return objectDescription;
        }