Beispiel #1
0
 public FreedomEffect(Type clazz, int count_0, int limit, int x_1, int y_2,
                      int w, int h)
 {
     this.visible = true;
     this.tex2ds  = new List <LTexture>(10);
     this.SetLocation(x_1, y_2);
     this.width   = w;
     this.height  = h;
     this.count   = count_0;
     this.timer   = new LTimer(80);
     this.kernels = (IKernel[])Arrays.NewInstance(clazz, count_0);
     try
     {
         System.Reflection.ConstructorInfo constructor = JavaRuntime.GetConstructor(clazz, new Type[] { typeof(int), typeof(int),
                                                                                                        typeof(int) });
         for (int i = 0; i < count_0; i++)
         {
             int no = MathUtils.Random(0, limit);
             kernels[i] = (IKernel)JavaRuntime.Invoke(constructor, new object[] {
                 ((int)(no)), ((int)(w)), ((int)(h))
             });
         }
     }
     catch (Exception e)
     {
         Console.Error.WriteLine(e.StackTrace);
     }
 }
        /// <summary>
        /// Invokes a callback when connection is established, or after the timeout
        /// (even if failed to connect). If already connected, callback is invoked instantly
        /// </summary>
        /// <param name="connectionCallback"></param>
        /// <param name="timeoutSeconds"></param>
        public void WaitConnection(Action <IClientSocket> connectionCallback, float timeoutSeconds)
        {
            if (IsConnected)
            {
                connectionCallback.Invoke(this);
                return;
            }

            var    isConnected = false;
            var    timedOut    = false;
            Action onConnected = null;

            onConnected = () =>
            {
                Connected  -= onConnected;
                isConnected = true;

                if (!timedOut)
                {
                    connectionCallback.Invoke(this);
                }
            };

            Connected += onConnected;

            LTimer.AfterSeconds(timeoutSeconds, () =>
            {
                if (!isConnected)
                {
                    timedOut   = true;
                    Connected -= onConnected;
                    connectionCallback.Invoke(this);
                }
            });
        }
Beispiel #3
0
 public MoveObject(float x, float y, float dw, float dh,
                   Animation animation, TileMap map) : base(x, y, dw, dh, animation, map)
 {
     this.timer        = new LTimer(0);
     this.isComplete   = false;
     this.allDirection = false;
     this.speed        = 4;
 }
Beispiel #4
0
 public void Action(object tag)
 {
     if (tag != null && tag is LTimer t)
     {
         timer = t;
     }
     target = tag;
 }
Beispiel #5
0
 public ArcEffect(LColor c, int x, int y, int width, int height)
 {
     this.SetLocation(x, y);
     this.width   = width;
     this.height  = height;
     this.timer   = new LTimer(200);
     this.color   = c == null ? LColor.black : c;
     this.visible = true;
 }
Beispiel #6
0
 public ScrollEffect(int d, LTexture tex2d, float x, float y, int w, int h)
 {
     this.SetLocation(x, y);
     this.texture = tex2d;
     this.width   = w;
     this.height  = h;
     this.count   = 1;
     this.timer   = new LTimer(10);
     this.visible = true;
     this.code    = d;
 }
Beispiel #7
0
        public SplitEffect(LTexture t, RectBox limit_0, int d)
        {
            this.texture    = t;
            this.width      = texture.GetWidth();
            this.height     = texture.GetHeight();
            this.halfWidth  = width / 2;
            this.halfHeight = height / 2;
            this.multiples  = 2;
            this.direction  = d;
            this.limit      = limit_0;
            this.timer      = new LTimer(10);
            this.visible    = true;
            this.v1         = new Vector2f();
            this.v2         = new Vector2f();
            switch (direction)
            {
            case Config.UP:
            case Config.DOWN:
                special = true;
                {
                    v1.Set(0, 0);
                    v2.Set(halfWidth, 0);
                    break;
                }

            case Config.TLEFT:
            case Config.TRIGHT:
                v1.Set(0, 0);
                v2.Set(halfWidth, 0);
                break;

            case Config.LEFT:
            case Config.RIGHT:
                special = true;
                {
                    v1.Set(0, 0);
                    v2.Set(0, halfHeight);
                    break;
                }

            case Config.TUP:
            case Config.TDOWN:
                v1.Set(0, 0);
                v2.Set(0, halfHeight);
                break;
            }
        }
Beispiel #8
0
 public Blood(LColor c, int x, int y)
 {
     this.SetLocation(x, y);
     this.color = c;
     this.timer = new LTimer(20);
     this.drops = new Drop[20];
     this.limit = 50;
     for (int i = 0; i < drops.Length; ++i)
     {
         SetBoolds(i, x, y, 6.0f * (MathUtils.Random() - 0.5f), -2.0f
                   * MathUtils.Random());
     }
     this.xSpeed  = 0F;
     this.ySpeed  = 0.5F;
     this.step    = 0;
     this.visible = true;
 }
Beispiel #9
0
 public CrossEffect(int c, LTexture o, LTexture n)
 {
     this.code     = c;
     this.otexture = o;
     this.ntexture = n;
     this.width    = o.GetWidth();
     this.height   = o.GetHeight();
     if (width > height)
     {
         maxcount = 16;
     }
     else
     {
         maxcount = 8;
     }
     this.timer   = new LTimer(160);
     this.visible = true;
 }
Beispiel #10
0
 public WaitSprite(int s, int w, int h)
 {
     this.style   = s;
     this.wait    = new DrawWait(s, w, h);
     this.delay   = new LTimer(120);
     this.alpha   = 1.0F;
     this.visible = true;
     if (s > 1)
     {
         int width  = w / 2;
         int height = h / 2;
         cycle = NewSample(s - 2, width, height);
         RectBox limit = cycle.GetCollisionBox();
         SetLocation(
             (w - ((limit.GetWidth() == 0) ? 20 : limit.GetWidth())) / 2,
             (h - ((limit.GetHeight() == 0) ? 20 : limit.GetHeight())) / 2);
     }
     Update(0);
 }
Beispiel #11
0
        public Cycle(List <object[]> path_0, int x_1, int y_2, int w, int h)
        {
            if (path_0 != null)
            {
                CollectionUtils.Add(data, CollectionUtils.ToArray(path_0));
                isUpdate = true;
            }
            else
            {
                data = new List <object[]>(10);
            }

            this.SetLocation(x_1, y_2);
            this.timer           = new LTimer(25);
            this.color           = LColor.white;
            this.points          = new List <CycleProgress>();
            this.multiplier      = 1;
            this.pointDistance   = 0.05f;
            this.padding         = 0;
            this.stepType        = 0;
            this.stepsPerFrame   = 1;
            this.trailLength     = 1;
            this.scaleX          = 1;
            this.scaleY          = 1;
            this.alpha           = 1;
            this.blockWidth      = w;
            this.blockHeight     = h;
            this.blockHalfWidth  = w / 2;
            this.blockHalfHeight = h / 2;
            if (signatures == null)
            {
                signatures = new Dictionary <Int32, float[]>(3);
                CollectionUtils.Put(signatures, ARC, new float[] { 1, 1, 3, 2, 2, 0 });
                CollectionUtils.Put(signatures, BEZIER, new float[] { 1, 1, 1, 1, 1, 1, 1, 1 });
                CollectionUtils.Put(signatures, LINE, new float[] { 1, 1, 1, 1 });
            }
            this.Setup();
            this.isVisible = true;
        }
Beispiel #12
0
 public LSelect(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height)
 {
     if (formImage == null)
     {
         this.SetBackground(new LTexture(width, height, true));
         this.SetAlpha(0.3F);
     }
     else
     {
         this.SetBackground(formImage);
     }
     this.customRendering = true;
     this.selectFlag      = 1;
     this.tmpOffset       = -(width / 10);
     this.delay           = new LTimer(150);
     this.autoAlpha       = 0.25F;
     this.isAutoAlpha     = true;
     this.SetCursor(XNAConfig.LoadTexture("creese.png"));
     this.SetElastic(true);
     this.SetLocked(true);
     this.SetLayer(100);
 }
Beispiel #13
0
 public LSelect(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height)
 {
     if (formImage == null)
     {
         this.SetBackground(new LTexture(width, height, true, Loon.Core.Graphics.Opengl.LTexture.Format.SPEED));
         this.SetAlpha(0.3F);
     }
     else
     {
         this.SetBackground(formImage);
     }
     this.customRendering = true;
     this.selectFlag      = 1;
     this.tmpOffset       = -(width / 10);
     this.delay           = new LTimer(150);
     this.autoAlpha       = 0.25F;
     this.isAutoAlpha     = true;
     this.SetCursor(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "creese.png"));
     this.SetElastic(true);
     this.SetLocked(true);
     this.SetLayer(100);
 }
Beispiel #14
0
        public virtual void OnCreate(int width, int height)
        {
            this.mode       = SCREEN_NOT_REPAINT;
            this.stageRun   = true;
            this.width      = width;
            this.height     = height;
            this.halfWidth  = width / 2;
            this.halfHeight = height / 2;
            this.lastTouchX = lastTouchY = touchDX = touchDY = 0;
            this.isLoad     = isLock = isClose = isTranslate = isGravity = false;

            /*if (sprites != null)
             * {
             *      sprites.close();
             *      sprites.removeAll();
             *      sprites = null;
             * }
             * this.sprites = new Sprites("ScreenSprites", this, width, height);
             * if (desktop != null)
             * {
             *      desktop.close();
             *      desktop.clear();
             *      desktop = null;
             * }
             * this.desktop = new Desktop("ScreenDesktop", this, width, height);*/
            this.isNext       = true;
            this.tx           = ty = 0;
            this.isTranslate  = false;
            this._screenIndex = 0;
            this._lastTocuh.Empty();
            this._keyActions.Clear();
            this._visible          = true;
            this._rotation         = 0;
            this._scaleX           = _scaleY = _alpha = 1f;
            this._baseColor        = null;
            this._isExistCamera    = false;
            this._initLoopEvents   = false;
            this._desktopPenetrate = false;
            if (this.delayTimer == null)
            {
                this.delayTimer = new LTimer(0);
            }
            if (this.pauseTimer == null)
            {
                this.pauseTimer = new LTimer(LSystem.SECOND);
            }
            if (this._rect_limits == null)
            {
                this._rect_limits = new TArray <RectBox>(10);
            }
            if (this._action_limits == null)
            {
                this._action_limits = new TArray <ActionBind>(10);
            }
            if (this._touchAreas == null)
            {
                this._touchAreas = new TArray <LTouchArea>();
            }
            if (this._conns == null)
            {
                this._conns = new loon.utils.reply.Closeable.Set();
            }
            if (this._keyActions == null)
            {
                this._keyActions = new ArrayMap();
            }
        }
Beispiel #15
0
        public override void Alter(LTimerContext t)
        {
            if (IsWait())
            {
                return;
            }
            if (timer1 == null)
            {
                timer1 = new LTimer(50);
            }
            if (title != null && timer1.Action(t.GetTimeSinceLastUpdate()))
            {
                if (title.GetY() > 50)
                {
                    title.Move_up(8);
                    title.ValidatePosition();
                }
                else if (title.GetAlpha() > 0.2f)
                {
                    title.SetAlpha(title.GetAlpha() - 0.1f);
                }
                else
                {
                    title.SetVisible(false);
                    Remove(title);
                    title = null;
                }
                return;
            }
            else if (over != null && timer1.Action(t.GetTimeSinceLastUpdate()) &&
                     !overFlag)
            {
                if (over.GetY() < (GetHeight() - over.GetHeight()) / 2)
                {
                    over.Move_down(8);
                    over.ValidatePosition();
                }
                else if (over.GetAlpha() < 1.0f)
                {
                    over.SetAlpha(over.GetAlpha() + 0.1f);
                }
                else
                {
                    CenterOn(over);
                    overFlag = true;
                }

                return;
            }
            if (!wingame)
            {
                if (timer == null)
                {
                    timer = new LTimer(100);
                }
                if (timer.Action(t.GetTimeSinceLastUpdate()))
                {
                    if (progress != null)
                    {
                        progress.SetUpdate(progress.GetValue() - (stageNo * 30));
                        if (progress.GetValue() <= 100 && !failgame)
                        {
                            failgame = true;
                            GetSprites().SetVisible(false);

                            over       = new LPaper(GetImage(16), 0, 0);
                            over.Click = new OverClick();
                            over.SetAlpha(0.1f);
                            CenterOn(over);
                            over.SetY(0);
                            Add(over);
                        }
                    }
                }
            }
            else
            {
                wingame = false;
                RemoveAll();
                Stage(stageNo + 1);
            }
        }
Beispiel #16
0
 public ActionEvent()
 {
     timer = new LTimer(0);
 }
Beispiel #17
0
 public void SetEquals(LTimer other)
 {
     this.active = other.active;
     this.delay = other.delay;
     this.currentTick = other.currentTick;
 }
Beispiel #18
0
 public void SetEquals(LTimer other)
 {
     this.active      = other.active;
     this.delay       = other.delay;
     this.currentTick = other.currentTick;
 }