Inheritance: EventDispatcher
Exemplo n.º 1
0
        public Button(DisplayObject upState, string text ="", DisplayObject downState=null, TextFormat format=null)
        {
            //if (upState == null) throw new ErrorEvent("Texture cannot be null");

            mParent = upState.parent;
            mUpState = upState;
            mDownState = downState != null ? downState : upState;
            mBackground = upState;
            mTextFormat = format;

            mScaleWhenDown = 0.9f;
            mAlphaWhenDisabled = 0.5f;
            mEnabled = true;
            mIsDown = false;
            mUseHandCursor = true;
            mTextBounds = new Rectangle(0, 0, upState.width, upState.height);

            mContents = new Sprite();
            mContents.addChild(mBackground);
            addChild(mContents);

            //addEventListener(TouchEvent.TOUCH, onTouch);
            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

            if (text.Length > 0) this.text = text;

            this.x = upState.x;
            this.y = upState.y;
            upState.x = upState.y = 0;

            if(mParent != null)
                (mParent as MovieClip).addChild(this);
        }
Exemplo n.º 2
0
    public DisplayObject addView(DisplayObject view)
    {
        if (stack.IndexOf(view) == -1)
        {
            stack.Add(view);

            srcClip.addChild(view);
        }
        return view;
    }
Exemplo n.º 3
0
    public DisplayObject setView(DisplayObject viewClass, bool disposeOfLast = false)
    {
        removeExistingView(disposeOfLast);

        _view = viewClass;

        removeAll();

        srcClip.addChild(_view);
        return _view;
    }
Exemplo n.º 4
0
 public void removeView(DisplayObject view, bool dispose = false)
 {
     var idx = stack.IndexOf(view);
     if (idx != -1)
     {
         srcClip.removeChild(view);
         stack.RemoveAt(idx);
         if(dispose)
             view = null;
     }
 }
Exemplo n.º 5
0
 public virtual void addChildAt(int index, DisplayObject child)
 {
     if(_childList.IndexOf(child)!=-1){
         return;
     }
     if(child.parent!=null){
         child.parent.removeChild(child);
     }
     _childList.Insert(index,child);
     child.stage			= _stage;
     child.parent		= this;
 }
Exemplo n.º 6
0
        public AimAssistance(Game Game, Cannon SourceObject)
            : base(Game)
        {
            this.SourceObject = SourceObject;

            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Colour = new Color(0, 0, 0, 192);
                Thickness = 3;
                FillColour = new Color(255, 255, 255, 25);
            }
            else if (Game.GraphicsMode == Game.GRAPHICSMODE_BLUEPRINT)
            {
                Colour = new Color(255, 255, 255, 255);
                Thickness = 1;
                FillColour = new Color(255, 255, 255, 15);
            }

            // Reticle
            Reticle = new DisplayObject();
            Reticle.Visible = false;
            AddChild(Reticle);

            UpdateReticle();

            // Aiming Lines
            LineCenter = new RectangleShape(new Vector2f(Utils.Distance(new Vector2f(0, 48), new Vector2f(0, Game.Size.X - 48)), Thickness));
            LineCenter.FillColor = Colour;
            LineCenter.Origin = new Vector2f(0, Thickness / 2);
            LineCenter.Position = new Vector2f(0, 48);
            LineCenter.Rotation = 90;
            AddChild(LineCenter);

            LineLeft = new RectangleShape(new Vector2f(10, Thickness));
            LineLeft.FillColor = Colour;
            LineLeft.Origin = new Vector2f(0, Thickness / 2);
            LineLeft.Position = new Vector2f(11, 43);
            AddChild(LineLeft);

            LineRight = new RectangleShape(new Vector2f(10, Thickness));
            LineRight.FillColor = Colour;
            LineRight.Origin = new Vector2f(0, Thickness / 2);
            LineRight.Position = new Vector2f(-11, 43);
            AddChild(LineRight);

            Fill = new ConvexShape(4);
            Fill.FillColor = FillColour;
            AddChild(Fill);
        }
Exemplo n.º 7
0
    public TapScroller(DisplayObject content, float width, float height)
        : base()
    {
        panelWidth = width;
        panelHeight = height;

        this.clipRect = new Rect(0, 0, width, height);

        _content = content;
        addChild(_content);

        // initialize scrollbar
        _scrollBarV = new Sprite();
        _scrollBarV.x = width - 10;
        addChild(_scrollBarV);

        _scrollBarH = new Sprite();
        _scrollBarH.y = height - 10;
        addChild(_scrollBarH);

        addEventListener( CEvent.ADDED_TO_STAGE, handleAddedToStage);
    }
Exemplo n.º 8
0
 public Texte(Point position, String txt, Font2 font2, Byte coul_A, Byte coul_R, Byte coul_G, Byte coul_B, int epaisseur, bool rempli, DisplayObject objParent)
     : base(position, coul_A, coul_R, coul_G, coul_B, rempli, epaisseur, objParent)
 {
     this.typeFigure = "TEXT";
     this.txt        = txt;
     this.font2      = font2;
 }
Exemplo n.º 9
0
 private void StyleEnterFrame(DisplayObject target, float passedTime)
 {
     ++_eventCount;
 }
Exemplo n.º 10
0
        public virtual void Update()
        {
            if (_isRunning)
            {
                try {
                    /*Animation*/

                    if (_animateIn == true)
                    {
                        if (_inOutTransition.animationType == Transition.InOutAnimations.SCALE)
                        {
                            Vector3 fscale = _displayObject.transform.localScale;
                            Vector3 tscale = new Vector3(_inOutOriginalScale.x,
                                                         _inOutOriginalScale.y,
                                                         _inOutOriginalScale.z);

                            Vector3 nscale = Vector3.Lerp(fscale, tscale, _inOutTransition.animationPercent);
                            _displayObject.transform.localScale = nscale;

                            foreach (KeyValuePair <RawImage, float> entry in _rawImageAlphaValues)
                            {
                                Color ncolor = entry.Key.color;
                                ncolor.a = entry.Value;

                                entry.Key.color = Color.Lerp(entry.Key.color, ncolor, _inOutTransition.animationPercent);
                            }

                            foreach (KeyValuePair <Image, float> entry in _imageAlphaValues)
                            {
                                Color ncolor = entry.Key.color;
                                ncolor.a = entry.Value;

                                entry.Key.color = Color.Lerp(entry.Key.color, ncolor, _inOutTransition.animationPercent);
                            }

                            foreach (KeyValuePair <Text, float> entry in _textAlphaValues)
                            {
                                Color ncolor = entry.Key.color;
                                ncolor.a = entry.Value;

                                entry.Key.color = Color.Lerp(entry.Key.color, ncolor, _inOutTransition.animationPercent);
                            }

                            foreach (KeyValuePair <Shadow, float> entry in _uiShadowValues)
                            {
                                Color ncolor = entry.Key.effectColor;
                                ncolor.a = entry.Value;

                                entry.Key.effectColor = Color.Lerp(entry.Key.effectColor, ncolor, _inOutTransition.animationPercent);
                            }

                            foreach (KeyValuePair <Outline, float> entry in _uiOutlineValues)
                            {
                                Color ncolor = entry.Key.effectColor;
                                ncolor.a = entry.Value;

                                entry.Key.effectColor = Color.Lerp(entry.Key.effectColor, ncolor, _inOutTransition.animationPercent);
                            }

                            if (_inOutTransition.animationPercent <= 1)
                            {
                                _inOutTransition.animationPercent += Time.deltaTime / _inOutTransition.animationDuration;
                            }
                            else
                            {
                                _inOutTransition.animationPercent = 0;
                                _animateIn = false;
                            }
                        }
                        else
                        {
                            _animateIn = false;
                        }
                    }
                    else if (_animateOut == true)
                    {
                        if (_inOutTransition.animationType == Transition.InOutAnimations.SCALE)
                        {
                            Vector3 fscale = _displayObject.transform.localScale;
                            Vector3 tscale = new Vector3(_inOutOriginalScale.x * _inOutTransition.animationDeform,
                                                         _inOutOriginalScale.y * _inOutTransition.animationDeform,
                                                         _inOutOriginalScale.z * _inOutTransition.animationDeform);

                            Vector3 nscale = Vector3.Lerp(fscale, tscale, _inOutTransition.animationPercent);
                            DisplayObject.transform.localScale = nscale;

                            RawImage[] rImgs = DisplayObject.GetComponentsInChildren <RawImage>();

                            Image[] imgs = DisplayObject.GetComponentsInChildren <Image> ();

                            Text[] texts = DisplayObject.GetComponentsInChildren <Text> ();

                            Shadow[] uiShadows = DisplayObject.GetComponentsInChildren <Shadow>();

                            Outline[] uiOutlines = DisplayObject.GetComponentsInChildren <Outline>();

                            Animator[] animators = DisplayObject.GetComponentsInChildren <Animator>();

                            foreach (RawImage rImg in rImgs)
                            {
                                Color32 rncolor = rImg.color;
                                rncolor.a = 0;

                                rImg.color = Color32.Lerp(rImg.color, rncolor, _inOutTransition.animationPercent);
                            }

                            foreach (Image img in imgs)
                            {
                                Color32 ncolor = img.color;
                                ncolor.a = 0;

                                img.color = Color32.Lerp(img.color, ncolor, _inOutTransition.animationPercent);
                            }

                            foreach (Text text in texts)
                            {
                                Color32 tncolor = text.color;
                                tncolor.a = 0;

                                text.color = Color32.Lerp(text.color, tncolor, _inOutTransition.animationPercent);
                            }

                            foreach (Shadow shadow in uiShadows)
                            {
                                Color32 sncolor = shadow.effectColor;
                                sncolor.a = 0;

                                shadow.effectColor = Color32.Lerp(shadow.effectColor, sncolor, _inOutTransition.animationPercent);
                            }

                            foreach (Outline outline in uiOutlines)
                            {
                                Color32 oncolor = outline.effectColor;
                                oncolor.a = 0;

                                outline.effectColor = Color32.Lerp(outline.effectColor, oncolor, _inOutTransition.animationPercent);
                            }

                            // All animator components should be disabled in order to modify alpha values when doing transition out.
                            foreach (Animator animator in animators)
                            {
                                animator.enabled = false;
                            }

                            if (_inOutTransition.animationPercent <= 1)
                            {
                                _inOutTransition.animationPercent += Time.deltaTime / _inOutTransition.animationDuration;
                            }
                            else
                            {
                                _inOutTransition.animationPercent = 0;
                                _animateOut = false;
                                Terminate();
                            }
                        }
                        else
                        {
                            Terminate();
                            _animateOut = false;
                        }
                    }

                    /*En Animation*/

                    ProcessUpdate();
                }
                catch (System.Exception e) {
                    Debug.LogError("Could not Process Update\n" + "Exception Type: " + e.GetType().Name + "\n" + e.Message + "\n" + e.StackTrace);
                }
            }
        }
Exemplo n.º 11
0
Arquivo: Stage.cs Projeto: meekr/Haima
 public override void addChild(DisplayObject child)
 {
     if(_childList.IndexOf(child)!=-1){
         return;
     }
     if(child.parent!=null){
         child.parent.removeChild(child);
     }
     _childList.Add(child);
     child.stage			= this;
     child.parent		= this;
 }
Exemplo n.º 12
0
 public DisplayObject removeChild2(DisplayObject child, bool dispose=false)
 {
     _world.removeChild(child);
     return child;
 }
Exemplo n.º 13
0
        private void onMouseDown(CEvent e)
        {
            MouseEvent mouseEvent = e as MouseEvent;
            Touch touch = mouseEvent.touch;

            if (!mEnabled) return;

            if (touch.phase == TouchPhase.Began && !mIsDown)
            {
                mBackground = mDownState;
                addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
                addEventListener(MouseEvent.MOUSE_LEAVE, onMouseLeave);

                mContents.scaleX = mContents.scaleY = mScaleWhenDown;
                mContents.x = (1.0f - mScaleWhenDown) / 2.0f * mBackground.width;
                mContents.y = (1.0f - mScaleWhenDown) / 2.0f * mBackground.height;
                mIsDown = true;
                //Debug.Log( "mouse down" );
            }
        }
Exemplo n.º 14
0
 public static void FadeIn(this DisplayObject e)
 {
     FadeIn(e, 1000 / 15, 0.1, null);
 }
Exemplo n.º 15
0
        private void HELP_Command(string command)
        {
            MethodInfo method = this.GetType().GetMethod(command.ToUpper());

            if ((method != null) && (method.GetCustomAttributes(typeof(CommandInfo), false).Length > 0))
            {
                CommandInfo cmdInfo        = (CommandInfo)method.GetCustomAttributes(typeof(CommandInfo), false)[0];
                var         cmdArgInfoList = from x in (CommandArgInfo[])method.GetCustomAttributes(typeof(CommandArgInfo), false)
                                             orderby x.SortOrder
                                             select x;
                List <DisplayObject> argDetails = new List <DisplayObject>();
                string argString = "";
                foreach (CommandArgInfo cmdArgInfo in cmdArgInfoList)
                {
                    string parameterInfo = cmdArgInfo.Name + " - ";
                    if (cmdArgInfo.Required)
                    {
                        parameterInfo += "Required parameter. ";
                    }
                    else
                    {
                        parameterInfo += "Optional parameter. ";
                    }
                    parameterInfo += cmdArgInfo.Description;
                    argDetails.Add(new DisplayObject
                    {
                        Style       = "margin-left: 50px;",
                        Text        = parameterInfo,
                        InsertAfter = "<br />"
                    });
                    string openBracket  = " [";
                    string closeBracket = "]";
                    if (cmdArgInfo.Required)
                    {
                        openBracket  = " <";
                        closeBracket = ">";
                    }
                    argString += openBracket + cmdArgInfo.Name + closeBracket;
                }
                result.DisplayArray.Add(DisplayObject.BlankLine);
                result.DisplayArray.Add(new DisplayObject
                {
                    Text        = method.Name + argString + " - " + cmdInfo.Description,
                    InsertAfter = "<br />"
                });
                if (argDetails.Count > 0)
                {
                    result.DisplayArray.AddRange(argDetails);
                }
                else
                {
                    DisplayObject noArgs = DisplayObject.CommandTakesNoArguments;
                    noArgs.Style = "margin-left: 50px;";
                    result.DisplayArray.Add(noArgs);
                }
                result.DisplayArray.Add(DisplayObject.BlankLine);
            }
            else
            {
                result.DisplayArray.Add(DisplayObject.UnknownCommand(command));
            }
        }
Exemplo n.º 16
0
 public bool hasChild(DisplayObject child)
 {
     return(!(_childList.IndexOf(child)==-1));
 }
Exemplo n.º 17
0
 public void init(DisplayObject obj, AssetManagerForm mainForm)
 {
     this.mainForm = mainForm;
     initFromExistingSprite(obj);
 }
Exemplo n.º 18
0
 public Cercle(Point position, int rayon, Color fillColor, Color strokeColor, int epaisseur, bool rempli, DisplayObject objParent)
     : base(position, fillColor, strokeColor, rempli, epaisseur, objParent)
 {
     this.typeFigure = "CIRCLE";
     this.m_nRayon   = rayon;
 }
Exemplo n.º 19
0
 public void SetNativeObject(DisplayObject displayObject)
 {
     _obj.asGraph.SetNativeObject(displayObject);
 }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        //¨ú±o°»´ú½d³ò
        rect = (Rect)(DisplayObject.GetType().GetField("_rect").GetValue(DisplayObject));


        if (rect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
        {
            if (!submit)
            {
                if (Input.GetKey(keyCode))
                {
                    if (EffectObjectWhenPress)
                    {
                        EffectObjectWhenPress.SetActive(true);
                    }
                    if (EffectObjectWhenRelease)
                    {
                        EffectObjectWhenRelease.SetActive(false);
                    }
                    pressDown = true;
                    submit    = true;
                }
            }

            if (pressDown)
            {
                if (Input.GetKeyUp(keyCode))
                {
                    if (Event)
                    {
                        GameObject newGameObject = (GameObject)Instantiate(Event);
                        newGameObject.SetActive(true);
                    }
                    if (EffectObjectWhenPress)
                    {
                        EffectObjectWhenPress.SetActive(false);
                    }
                    if (EffectObjectWhenRelease)
                    {
                        EffectObjectWhenRelease.SetActive(true);
                    }
                    submit = false;
                }
            }
        }
        else
        {
            if (pressDown)
            {
                if (Input.GetKeyUp(keyCode))
                {
                    if (EffectObjectWhenPress)
                    {
                        EffectObjectWhenPress.SetActive(false);
                    }
                    if (EffectObjectWhenRelease)
                    {
                        EffectObjectWhenRelease.SetActive(true);
                    }
                    pressDown = false;
                    submit    = false;
                }
            }
        }
    }
Exemplo n.º 21
0
        // this gets called every frame
        private void StageOnEnterFrameEvent(DisplayObject target, float elapsedtimesecs)
        {
            Random rnd = new Random();
            int    randomY, randomX;

            if (MapFile == "map.txt")
            {
                // process inputs
                if (KeyboardInput.IsKeyPressedThisFrame(Key.W) || KeyboardInput.IsKeyPressedThisFrame(Key.Up))
                {
                    _map.Player.Move(0, -1);
                    _map.Player.Attack(0, -1);
                    if (_map.Dragon.Health > 0)
                    {
                        if (_map.Dragon.DragonBreath(_map.Player))
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.AddChild(fire);
                            }
                        }
                        else
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.RemoveChild(fire);
                            }
                        }
                    }

                    // Update skeleton position
                    foreach (Skeleton skeleton in _map.Skeletons)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        skeleton.Move(randomX, randomY);
                    }

                    // Update ghost position
                    foreach (Ghost ghost in _map.Ghosts)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.S) || KeyboardInput.IsKeyPressedThisFrame(Key.Down))
                {
                    _map.Player.Move(0, 1);
                    _map.Player.Attack(0, 1);
                    _beforeBreathHp = _map.Player.Health;
                    if (_map.Dragon.Health > 0)
                    {
                        if (_map.Dragon.DragonBreath(_map.Player))
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.AddChild(fire);
                            }
                        }
                        else
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.RemoveChild(fire);
                            }
                        }
                    }

                    foreach (Skeleton skeleton in _map.Skeletons)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        skeleton.Move(randomX, randomY);
                    }

                    foreach (Ghost ghost in _map.Ghosts)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.A) || KeyboardInput.IsKeyPressedThisFrame(Key.Left))
                {
                    _map.Player.Move(-1, 0);
                    _map.Player.Attack(-1, 0);
                    _beforeBreathHp = _map.Player.Health;
                    if (_map.Dragon.Health > 0)
                    {
                        if (_map.Dragon.DragonBreath(_map.Player))
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.AddChild(fire);
                            }
                        }
                        else
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.RemoveChild(fire);
                            }
                        }
                    }

                    foreach (Skeleton skeleton in _map.Skeletons)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        skeleton.Move(randomX, randomY);
                    }

                    foreach (Ghost ghost in _map.Ghosts)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.D) || KeyboardInput.IsKeyPressedThisFrame(Key.Right))
                {
                    _map.Player.Move(1, 0);
                    _map.Player.Attack(1, 0);
                    _beforeBreathHp = _map.Player.Health;
                    if (_map.Dragon.Health > 0)
                    {
                        if (_map.Dragon.DragonBreath(_map.Player))
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.AddChild(fire);
                            }
                        }
                        else
                        {
                            foreach (Sprite fire in _dragonFireList)
                            {
                                PerlinApp.Stage.RemoveChild(fire);
                            }
                        }
                    }

                    foreach (Skeleton skeleton in _map.Skeletons)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        skeleton.Move(randomX, randomY);
                    }

                    foreach (Ghost ghost in _map.Ghosts)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                // render changes
                _playerGfx.X          = _map.Player.X * Tiles.TileWidth;
                _playerGfx.Y          = _map.Player.Y * Tiles.TileWidth;
                _healthTextField.Text = "HP: " + _map.Player.Health.ToString();

                if (_map.Player.X == _map.KeyToDoor.X && _map.Player.Y == _map.KeyToDoor.Y && _map.KeyToDoor.Cell.Item != null)
                {
                    //TODO: and if nacisnieto przycisk

                    PerlinApp.Stage.RemoveChild(_keyToDoorGfx);
                    _map.Player.Inventory.AddToInventory("keys");
                    _map.KeyToDoor.PickUp();

                    ClearInventory();
                    InventoryRender();
                }

                if (_map.Player.X == _map.Sword.X && _map.Player.Y == _map.Sword.Y && _map.Sword.Cell.Item != null)
                {
                    PerlinApp.Stage.RemoveChild(_swordGfx);

                    // TODO: and if nacisnieto przycisk
                    _map.Player.Inventory.AddToInventory("swords");
                    _map.Sword.PickUp();

                    ClearInventory();
                    InventoryRender();
                }

                if (_map.Player.X == _map.Door.X && _map.Player.Y == _map.Door.Y && _map.Door.Used)
                {
                    ClearInventory();
                    InventoryRender();
                    PerlinApp.Stage.RemoveChild(_doorGfx);
                    PerlinApp.Stage.AddChild(_openDoorGfx);
                }

                if (_map.Player.X == _map.Stairs.X && _map.Player.Y == _map.Stairs.Y)
                {
                    MapFile = "map2.txt";
                    PerlinApp.Stage.RemoveAllChildren();
                    _map = MapLoader.LoadMap(MapFile);
                    PerlinApp.Stage.EnterFrameEvent -= StageOnEnterFrameEvent;
                    OnStart();
                }

                int countSkeleton = 0;
                foreach (Skeleton skeleton in _map.Skeletons)
                {
                    _skeletonsSpriteList[countSkeleton].X = skeleton.X * Tiles.TileWidth;
                    _skeletonsSpriteList[countSkeleton].Y = skeleton.Y * Tiles.TileWidth;

                    if (skeleton.Health == 0)
                    {
                        PerlinApp.Stage.RemoveChild(_skeletonsSpriteList[countSkeleton]);
                        skeleton.Cell.Actor = null;
                    }

                    countSkeleton++;
                }

                // Render ghost changes
                int countGhost = 0;
                foreach (Ghost ghost in _map.Ghosts)
                {
                    _ghostSpriteList[countGhost].X = ghost.X * Tiles.TileWidth;
                    _ghostSpriteList[countGhost].Y = ghost.Y * Tiles.TileWidth;

                    if (ghost.Health == 0)
                    {
                        PerlinApp.Stage.RemoveChild(_ghostSpriteList[countGhost]);
                        ghost.Cell.Actor = null;
                    }

                    if (_map.Player.Health <= 0)
                    {
                        PerlinApp.Stage.RemoveAllChildren();
                        PerlinApp.Stage.EnterFrameEvent -= StageOnEnterFrameEvent;
                        Console.WriteLine("Game over. You are dead.");
                    }
                }

                // Render dragon changes
                if (MapFile == "map.txt")
                {
                    if (_map.Dragon.Health == 0)
                    {
                        PerlinApp.Stage.RemoveChild(_dragonGfx);
                        foreach (Sprite fire in _dragonFireList)
                        {
                            PerlinApp.Stage.RemoveChild(fire);
                        }

                        _map.Dragon.Cell.Actor = null;
                    }
                }
            }

// second map !!!!!!!!!!!!!!!!!!!!!
            if (MapFile == "map2.txt")
            {
                // process inputs
                if (KeyboardInput.IsKeyPressedThisFrame(Key.W) || KeyboardInput.IsKeyPressedThisFrame(Key.Up))
                {
                    _map.Player.Move(0, -1);
                    _map.Player.Attack(0, -1);

                    // Update ghost position
                    foreach (Ghost ghost in _map.GhostsSecond)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.S) || KeyboardInput.IsKeyPressedThisFrame(Key.Down))
                {
                    _map.Player.Move(0, 1);
                    _map.Player.Attack(0, 1);

                    // Update ghost position
                    foreach (Ghost ghost in _map.GhostsSecond)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.A) || KeyboardInput.IsKeyPressedThisFrame(Key.Left))
                {
                    _map.Player.Move(-1, 0);
                    _map.Player.Attack(-1, 0);

                    // Update ghost position
                    foreach (Ghost ghost in _map.GhostsSecond)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                if (KeyboardInput.IsKeyPressedThisFrame(Key.D) || KeyboardInput.IsKeyPressedThisFrame(Key.Right))
                {
                    _map.Player.Move(1, 0);
                    _map.Player.Attack(1, 0);

                    // Update ghost position
                    foreach (Ghost ghost in _map.GhostsSecond)
                    {
                        randomY = rnd.Next(-1, 2);
                        randomX = rnd.Next(-1, 2);
                        ghost.Move(randomX, randomY);
                    }
                }

                // render changes
                _playerGfx.X          = _map.Player.X * Tiles.TileWidth;
                _playerGfx.Y          = _map.Player.Y * Tiles.TileWidth;
                _healthTextField.Text = "HP: " + _map.Player.Health.ToString();
            }

            // Render ghost changes
            int countGhostSec = 0;

            foreach (Ghost ghost in _map.GhostsSecond)
            {
                _ghostSpriteListSecond[countGhostSec].X = ghost.X * Tiles.TileWidth;
                _ghostSpriteListSecond[countGhostSec].Y = ghost.Y * Tiles.TileWidth;
                countGhostSec++;
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Converts the previous location of a touch to the local coordinate system of a display object.
        /// </summary>
        public Point PreviousLocationInSpace(DisplayObject space)
        {
            Matrix2D transformationMatrix = Target.Stage.GetTransformationMatrix(space);

            return(transformationMatrix.TransformPoint(PreviousGlobalX, PreviousGlobalY));
        }
Exemplo n.º 23
0
 public void removeChild(DisplayObject child)
 {
     _childList.Remove(child);
     child.stage			= null;
     child.parent		= null;
     updateParentBoundRect();
 }
Exemplo n.º 24
0
 public void downState(DisplayObject value)
 {
     if (mDownState != value)
     {
         mDownState = value;
         if (mIsDown) mBackground = value;
     }
 }
Exemplo n.º 25
0
 public void setChildIndex(DisplayObject child,int index)
 {
     _childList.Remove(child);
     _childList.Insert(index,child);
 }
Exemplo n.º 26
0
 private void removeExistingView(bool dispose)
 {
     if (_view != null)
     {
         srcClip.removeChild(_view);
         if(dispose)
             _view = null;
     }
 }
Exemplo n.º 27
0
 public Figure(Point pt, DisplayObject objParent)
 {
     this.m_ptPosition        = pt;
     this.DisplayObjectParent = objParent;
 }
            private void insertColumn(ParameterId parameterId, int vi, DisplayObject obj)
            {
                GridColumn unbColumn = dataView.Columns.AddField(obj.id + "_" + parameterId.id);
                unbColumn.VisibleIndex = vi;
                unbColumn.Caption = obj.name + ":" + parameterId.name;
                unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Object;
                //Allow edit to admin & superuser
                unbColumn.OptionsColumn.AllowEdit = Account.Current.hasPermission(Account.Actions.EditMetrix);
                //unbColumn.AppearanceCell.BackColor = Color.White;

                var s = new Series();
                s.Name = unbColumn.Caption;
                s.ChartType = SeriesChartType.FastLine;
                SortedDictionary<string, object[]> data = obj.getParameterById(parameterId.id).columnData;

                foreach (string time in data.Keys)
                    s.Points.AddXY(time, data[time][2]);

                chartControl.Series.Add(s);

                series.Add(obj.id + "_" + parameterId.id, s);
            }
Exemplo n.º 29
0
        internal void DrawStage()
        {
            _currentItem      = _stage.root;
            _drawOrderCounter = 0;
            _drawOptions.Reset();

            var drawBatch = _stage.sceneBatch;

            drawBatch.Begin(_stage.GetGlobalMatrix());

            while (_currentItem != null)
            {
                if (!_currentItem.visible)
                {
                    GotoNextItem();
                    continue;
                }

                _currentItem.drawOrder = _drawOrderCounter++;

                if (_currentItem.parent != null)
                {
                    _currentItem.colorDirty     = _currentItem.colorDirty || _currentItem.parent.colorDirty;
                    _currentItem.transformDirty = _currentItem.transformDirty || _currentItem.parent.transformDirty;
                }

                if (_currentItem.colorDirty)
                {
                    _currentItem.UpdateColor();
                }

                if (_currentItem.transformDirty)
                {
                    _currentItem.UpdateTransform();
                }

                if (_currentItem.drawOptions != null)
                {
                    ApplyDrawOptions();
                }

                if (_currentItem.drawRect != null)
                {
                    drawBatch.drawRect = _currentItem.drawRect;
                }

                var container = _currentItem as DisplayContainer;
                if (container != null)
                {
                    if (container.numChildren > 0)
                    {
                        _currentItem = container.GetChildAt(0);
                    }
                    else
                    {
                        GotoNextItem();
                    }
                }
                else
                {
                    _currentItem.Draw();
                    GotoNextItem();
                }
            }

            drawBatch.End();
        }
Exemplo n.º 30
0
 private void AddedToStageHandler(DisplayObject target, DisplayObject currentTarget)
 {
     _started    = true;
     _waitFrames = 3;
     AddTestObjects(100);
 }
Exemplo n.º 31
0
 public static void remove_addedToStage(DisplayObject that, Action <Event> value)
 {
     CommonExtensions.RemoveDelegate(that, value, Event.ADDED_TO_STAGE);
 }
Exemplo n.º 32
0
 public Matrix3D getRelativeMatrix3D(DisplayObject relativeTo)
 {
     return null;
 }
Exemplo n.º 33
0
 public static void remove_enterFrame(DisplayObject that, Action <Event> value)
 {
     CommonExtensions.RemoveDelegate(that, value, Event.ENTER_FRAME);
 }
Exemplo n.º 34
0
 public CourbeBezier(Point position, List <Point> tabPoints, Color fillColor, Color strokeColor, int epaisseur, bool rempli, DisplayObject objParent)
     : base(position, fillColor, strokeColor, rempli, epaisseur, objParent)
 {
     this.UserPoints    = tabPoints;
     this.typeFigure    = "CURVE";
     this.PointsOnCurve = 100;
 }
Exemplo n.º 35
0
 public static void add_removed(DisplayObject that, Action <Event> value)
 {
     CommonExtensions.CombineDelegate(that, value, Event.REMOVED);
 }
Exemplo n.º 36
0
 public Texte(Point position, String txt, Font2 font2, Color couleur, int epaisseur, bool rempli, DisplayObject objParent)
     : base(position, couleur, Color.Empty, rempli, epaisseur, objParent)
 {
     this.typeFigure = "TEXT";
     this.txt        = txt;
     this.font2      = font2;
 }
Exemplo n.º 37
0
 public static void remove_removedFromStage(DisplayObject that, Action <Event> value)
 {
     CommonExtensions.RemoveDelegate(that, value, Event.REMOVED_FROM_STAGE);
 }
Exemplo n.º 38
0
 public void WorkFinished()
 {
     agentMemory.Workplace = null;
     agentMemory.UseWorkplaceSecondAccessTile = false;
     DisplayObject.CharacterUsesModule(null);
 }
Exemplo n.º 39
0
 public static void remove_render(DisplayObject that, Action <Event> value)
 {
     CommonExtensions.RemoveDelegate(that, value, Event.RENDER);
 }
Exemplo n.º 40
0
 public void SetProperty(DisplayObject obj, string property)
 {
     _object   = obj;
     _property = property;
     Text.text = property;
 }
Exemplo n.º 41
0
        public override void OnInspectorGUI()
        {
            DisplayObject obj = (target as DisplayObjectInfo).displayObject;

            EditorGUILayout.LabelField(obj.GetType().Name + ": " + obj.id, (GUIStyle)"OL Title");
            EditorGUILayout.Separator();
            EditorGUI.BeginChangeCheck();
            string name = EditorGUILayout.TextField("Name", obj.name);

            if (EditorGUI.EndChangeCheck())
            {
                obj.name = name;
            }
            if (obj is Container)
            {
                EditorGUI.BeginChangeCheck();
                bool fairyBatching = EditorGUILayout.Toggle("FairyBatching", ((Container)obj).fairyBatching);
                if (EditorGUI.EndChangeCheck())
                {
                    ((Container)obj).fairyBatching = fairyBatching;
                }
            }

            GObject gObj = obj.gOwner;

            if (gObj != null)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField(gObj.GetType().Name + ": " + gObj.id, (GUIStyle)"OL Title");
                EditorGUILayout.Separator();

                if (!string.IsNullOrEmpty(gObj.resourceURL))
                {
                    PackageItem pi = UIPackage.GetItemByURL(gObj.resourceURL);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Resource");
                    EditorGUILayout.LabelField(pi.name + "@" + pi.owner.name);
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUI.BeginChangeCheck();
                name = EditorGUILayout.TextField("Name", gObj.name);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.name = name;
                }

                if (gObj.parent != null)
                {
                    string[] options = new string[gObj.parent.numChildren];
                    int[]    values  = new int[options.Length];
                    for (int i = 0; i < options.Length; i++)
                    {
                        options[i] = i.ToString();
                        values[i]  = i;
                    }
                    EditorGUI.BeginChangeCheck();
                    int childIndex = EditorGUILayout.IntPopup("Child Index", gObj.parent.GetChildIndex(gObj), options, values);
                    if (EditorGUI.EndChangeCheck())
                    {
                        gObj.parent.SetChildIndex(gObj, childIndex);
                    }
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Child Index");
                    EditorGUILayout.LabelField("No Parent");
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUI.BeginChangeCheck();
                Vector3 position = EditorGUILayout.Vector3Field("Position", gObj.position);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.position = position;
                }

                EditorGUI.BeginChangeCheck();
                Vector3 rotation = EditorGUILayout.Vector3Field("Rotation", new Vector3(gObj.rotationX, gObj.rotationY, gObj.rotation));
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.rotationX = rotation.x;
                    gObj.rotationY = rotation.y;
                    gObj.rotation  = rotation.z;
                }

                EditorGUI.BeginChangeCheck();
                Vector2 scale = EditorGUILayout.Vector2Field("Scale", gObj.scale);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.scale = scale;
                }

                EditorGUI.BeginChangeCheck();
                Vector2 skew = EditorGUILayout.Vector2Field("Skew", gObj.skew);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.skew = skew;
                }

                EditorGUI.BeginChangeCheck();
                Vector2 size = EditorGUILayout.Vector2Field("Size", gObj.size);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.size = size;
                }

                EditorGUI.BeginChangeCheck();
                Vector2 pivot = EditorGUILayout.Vector2Field("Pivot", gObj.pivot);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.pivot = pivot;
                }

                EditorGUI.BeginChangeCheck();
                string text = EditorGUILayout.TextField("Text", gObj.text);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.text = text;
                }

                EditorGUI.BeginChangeCheck();
                string icon = EditorGUILayout.TextField("Icon", gObj.icon);
                if (EditorGUI.EndChangeCheck())
                {
                    gObj.icon = icon;
                }
            }
        }
Exemplo n.º 42
0
 public void upState(DisplayObject value)
 {
     if (mUpState != value)
     {
         mUpState = value;
         if (!mIsDown) mBackground = value;
     }
 }
Exemplo n.º 43
0
 public get_stage()
 {
     Name = "get_stage";
     IsProperty = true;
     DeclaringType = new DisplayObject();
 }
Exemplo n.º 44
0
        private void resetContents()
        {
            removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            removeEventListener(MouseEvent.MOUSE_LEAVE, onMouseLeave);

            mIsDown = false;
            mBackground = mUpState;
            mContents.x = mContents.y = 0f;
            mContents.scaleX = mContents.scaleY = 1.0f;
        }
Exemplo n.º 45
0
 public Figure(Point pt, Byte coul_A, Byte coul_R, Byte coul_G, Byte coul_B, bool b, int Ep, DisplayObject objParent)
 {
     this.m_ptPosition        = pt;
     this.DisplayObjectParent = objParent;
     m_A               = coul_A;
     m_R               = coul_R;
     m_G               = coul_G;
     m_B               = coul_B;
     this.m_bRempli    = b;
     this.m_nEpaisseur = Ep;
 }
Exemplo n.º 46
0
 public static bool UnregisterDisplayObject(DisplayObject displayObject)
 {
     return(MAP.Remove(displayObject) && DISPLAYOBJECTS.Remove(displayObject));
 }
Exemplo n.º 47
0
        //This is made posible by enabeling the Lua Interface in VLC Player:
        // VLC Preferences -> Show settings: All -> Interfaces -> Main intefaces -> check the "Web" box
        //Then expand "Main interfaces" and go in to "Lua". Type something in the "Lua Interface" field and
        // set a password. Source directory should be *vlc install folder*\lua\http    and Directory index should be checked.
        //
        //
        //If you now open "http://127.0.0.1:8080/requests/status.xml" in your browser while VLC is playing,
        //you should be able to login by entering your password (leave username empty)


        void ParseXml(DisplayObject obj)
        {
            //Console.WriteLine();
            VlcStateItem vlc = new VlcStateItem();

            vlc.Monitor = obj;
            string data = GetWebPage("http://127.0.0.1:8080/requests/status.xml");

            if (data == null)
            {
                tbMonitor.Text   = "No monitor";
                tbStatus.Text    = String.Format("isOpen=False, PlayState={0}, isFullScreen={1}", "null", "False");
                tbTitle.Text     = "No media";
                tbResAndAsp.Text = "0x0 (1:1)";
                tbType.Text      = String.Format("{0} @ {1}", VlcStateItem.VideoType.None.ToString(), Utils.SecToTime(0));

                return;
            }
            XDocument objDoc = XDocument.Parse(data);

            var    root       = objDoc.Element("root");
            var    cat        = root.Element("information").Elements("category");
            long   length     = long.Parse(root.Element("length").Value);
            long   time       = long.Parse(root.Element("time").Value);
            bool   fullScreen = bool.Parse(root.Element("fullscreen").Value.Replace("0", "False").Replace("1", "True"));
            string state      = root.Element("state").Value;

            vlc.State           = state.Replace(state[0].ToString(), state[0].ToString().ToUpper());
            vlc.Length          = length;
            vlc.CurrentPosition = time;
            vlc.isFullScreen    = fullScreen;

            if (length < Utils.tv_long_min)
            {
                vlc.PlaybackType = VlcStateItem.VideoType.TVShort;
            }
            if (length > Utils.tv_long_min && length < Utils.tv_long_max)
            {
                vlc.PlaybackType = VlcStateItem.VideoType.TVLong;
            }

            if (length > Utils.tv_long_max)
            {
                vlc.PlaybackType = VlcStateItem.VideoType.Movie;
            }

            // Console.WriteLine(state);
            foreach (var c in cat)
            {
                var info = c.Elements("info");
                foreach (var i in info)
                {
                    string name = i.Attribute("name").Value;
                    if (name.Equals("title"))
                    {
                        vlc.Title = i.Value.Replace("&#39;", "'");
                    }

                    if (name.Equals("filename"))
                    {
                        vlc.Title = i.Value.Replace("&#39;", "'");
                    }

                    if (name.Equals("showName"))
                    {
                        //It's has metadata telling us that it's a TV show. NICE!!!
                        if (length < Utils.tv_long_min)
                        {
                            vlc.PlaybackType = VlcStateItem.VideoType.TVShort;
                        }
                        else
                        {
                            vlc.PlaybackType = VlcStateItem.VideoType.TVLong;
                        }
                    }

                    if (name.Equals("Skärmupplösning") || name.Equals("Display resolution"))
                    {
                        string res    = i.Value;
                        double width  = int.Parse(res.Split('x')[0]);
                        double height = int.Parse(res.Split('x')[1]);
                        double aspect = Math.Round(width / height, 2);

                        //Console.WriteLine("Res: {0} ({1} calculated from: {2} )  ", res, "0:0", aspect);
                        foreach (DictionaryEntry de in Utils.aspectTable)
                        {
                            String   asp    = (string)de.Key;
                            string[] scales = (string[])de.Value;
                            foreach (string sc in scales)
                            {
                                if (aspect.ToString().Replace(',', '.') == sc)
                                {
                                    vlc.Resolution = String.Format("{0} ({1})", res, asp);
                                    // Console.WriteLine("Res: {0} ({1} calculated from: {2} )  ", res, asp, aspect);
                                }
                            }
                        }
                    }
                }
            }

            tbMonitor.Text   = vlc.Monitor.Name;
            tbStatus.Text    = String.Format("isOpen=True, {0} {1}", vlc.State, vlc.isFullScreen ? "in fullscreen" :"");
            tbTitle.Text     = vlc.Title;
            tbResAndAsp.Text = vlc.Resolution;
            tbType.Text      = String.Format("{0} @ {1}", vlc.PlaybackType.ToString(), Utils.SecToTime(vlc.Length));

            slider.Maximum = vlc.Length;
            slider.Value   = vlc.CurrentPosition;

            lblPos.Content    = Utils.formatSec(vlc.CurrentPosition);
            lblLenght.Content = Utils.formatSec(vlc.Length);
        }
            internal void addObject(int objectId, string name, string from, string to)
            {
                if (objects.Count((o) => o.id == objectId) > 0)
                    return;

                DisplayObject obj = new DisplayObject(objectId, name);

                foreach (ParameterId pId in paramIds)
                {
                    joinTimes(obj.addParameter(pId, from, to));
                    insertColumn(pId, dataView.Columns.Count, obj);
                }

                objects.Add(obj);

                refreshTable();
            }
Exemplo n.º 49
0
 // The overrides are here to block access to the harness from the outside, even from the children.
 public DisplayObject addChild2(DisplayObject child)
 {
     _world.addChild(child);
     return child;
 }
            private void removeColumn(int parameterId, DisplayObject obj)
            {
                GridColumn column = dataView.Columns.ColumnByFieldName(obj.id + "_" + parameterId);
                dataView.Columns.Remove(column);

                chartControl.Series.Remove(series[obj.id + "_" + parameterId]);
                series.Remove(obj.id + "_" + parameterId);
            }
Exemplo n.º 51
0
 public DisplayObject addChildAt2(DisplayObject child, int index)
 {
     _world.addChildAt(child, index);
     return child;
 }
Exemplo n.º 52
0
 private void UpdateDisplayObject(DisplayObject displayObject)
 {
     _window.FillRect(displayObject.Rect);
     displayObject.Invalidate();
 }
Exemplo n.º 53
0
 public void AddContent(DisplayObject content)
 {
     this.content     = content;
     content.Position = PositionOnScreen;
 }
Exemplo n.º 54
0
 private void MonitorTimer_Tick(object sender, EventArgs e)
 {
     obj = mon.getVLC();
 }
Exemplo n.º 55
0
		void recycleDisplayCache(int depth, DisplayObject displayObj){
			displayObj.view.visible = false;
			Movie movie = displayObj as Movie;
			if(movie!=null)
				movie.StopRecursive();
			List<DisplayObject> caches = _depth_displayCaches[depth];
			if(caches==null){
				caches = new List<DisplayObject>(2);
				_depth_displayCaches[depth] = caches;
			}
			caches.Add(displayObj);
		}