예제 #1
0
파일: Ball.cs 프로젝트: stratts/Atlas
        public Ball(Vector2 startPos)
        {
            var radius = 10;

            Position  = startPos;
            Size      = new Vector2(radius * 2);
            _startPos = startPos;

            // Colored circle to represent ball
            var circle = new Circle()
            {
                Color  = Colors.Black,
                Radius = radius
            };

            AddChild(circle);

            // Update method called every frame
            var update = new Updateable()
            {
                UpdateMethod = Update
            };

            AddComponent(update);

            // Collision component that calls method when collision occurs
            var collision = new Collision()
            {
                OnCollision = HandleCollision
            };

            AddComponent(collision);
        }
예제 #2
0
 public Updater(Updateable applicationInfo)
 {
     this.applicationInfo              = applicationInfo;
     this.bgWorger                     = new BackgroundWorker();
     this.bgWorger.DoWork             += new DoWorkEventHandler(BgWorger_DoWork);
     this.bgWorger.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BgWorger_RunWorkerCompleted);
 }
예제 #3
0
        public virtual Emitter <T> OnEmit(T eventType)
        {
            if (!_active)
            {
                return(this);
            }
            int taskCount = 0;
            SortedList <Updateable> list = _emitterTable.Get(eventType);

            if (null != list)
            {
                for (LIterator <Updateable> it = list.ListIterator(); it.HasNext();)
                {
                    Updateable update = it.Next();
                    if (update != null)
                    {
                        update.Action(eventType);
                        if (update is ActionUpdate)
                        {
                            ActionUpdate au = (ActionUpdate)update;
                            if (au.Completed())
                            {
                                list.Remove(au);
                            }
                        }
                    }
                    taskCount++;
                    if (taskCount >= _maxFrameTask)
                    {
                        break;
                    }
                }
            }
            return(this);
        }
예제 #4
0
        // --- Load start ---//

        public void AddLoad(Updateable u)
        {
            lock (loads)
            {
                loads.Add(u);
            }
        }
예제 #5
0
        public void UpdateableCanCompareDirectlyToChildItem()
        {
            var rawItem    = new Uri("http://google.com");
            var updateable = new Updateable <Uri>(rawItem);

            updateable.Equals(rawItem).Should().BeTrue();
        }
예제 #6
0
    void Update()
    {
        if (backingInfo is Destructable)
        {
            Destructable d = backingInfo as Destructable;
            updateHealthbar(d);
            float damageFraction = d.health / d.maxHealth;

            if (d.health <= 0)
            {
                map.removeStructure(this);
            }

            spriteRenderer.color = new Color(1, damageFraction, damageFraction);
        }

        if (backingInfo is Updateable)
        {
            Updateable u = backingInfo as Updateable;
            u.OnUpdate();
        }

        if (backingInfo is ChargableStructure)
        {
            updatePowerbar(backingInfo as ChargableStructure);
        }
    }
예제 #7
0
        // --- Load end ---//

        // --- UnLoad start ---//

        public void AddUnLoad(Updateable u)
        {
            lock (unloads)
            {
                unloads.Add(u);
            }
        }
예제 #8
0
 public void RemoveLoad(Updateable u)
 {
     lock (loads)
     {
         loads.Remove(u);
     }
 }
예제 #9
0
 public void RemoveUnLoad(Updateable u)
 {
     lock (unloads)
     {
         unloads.Remove(u);
     }
 }
예제 #10
0
파일: LSystem.cs 프로젝트: keppelcao/LGame
	    public static void Post(Updateable update) {
		    if (global_queue != null) {
			    global_queue.InvokeLater(update);
		    } else {
			    LSystem.Load(update);
		    }
	    }
예제 #11
0
        public static StopwatchTimer Run(Updateable u)
        {
            StopwatchTimer sw = Begin();

            u.Action(null);
            sw.Stop();
            return(sw);
        }
예제 #12
0
        public static void Unload(Updateable u)
        {
            LProcess process = LSystem.screenProcess;

            if (process != null)
            {
                process.AddUnLoad(u);
            }
        }
예제 #13
0
        public void UpdateResetsRequestCount()
        {
            var updateable = new Updateable <Uri>(new Uri("http://foo.com"), 100);

            updateable.Requests.Should().Be(100);

            updateable.Update();
            updateable.Requests.Should().Be(0);
        }
예제 #14
0
        public void TwoUpdateableObjectsCanCompareToEachOther()
        {
            var one = new Updateable <string>("item");
            var two = new Updateable <string>("item");

            one.Equals(two).Should().BeTrue();
            (one == two).Should().BeTrue();
            (one != two).Should().BeFalse();
            one.GetHashCode().Should().Be(two.GetHashCode());
        }
예제 #15
0
        public virtual bool RemoveObserver(T eventType, Updateable handler)
        {
            SortedList <Updateable> list = _emitterTable.Get(eventType);

            if (list != null)
            {
                return(list.Remove(handler));
            }
            return(false);
        }
예제 #16
0
 public static void Post(Updateable update)
 {
     if (global_queue != null)
     {
         global_queue.InvokeLater(update);
     }
     else
     {
         LSystem.Load(update);
     }
 }
예제 #17
0
        public void CompareToSelfIsTrue()
        {
            var updateable = new Updateable <Uri>(new Uri("https://[::1]"));

            updateable.Equals(updateable).Should().BeTrue();
            (updateable == updateable).Should().BeTrue();

            object indirect = updateable;

            indirect.Equals(indirect).Should().BeTrue();
        }
예제 #18
0
        public void CompareToNullIsFalse()
        {
            var updateable = new Updateable <string>("fore");

            updateable.Equals((string)null).Should().BeFalse();
            updateable.Equals((Updateable <string>)null).Should().BeFalse();
            (updateable == null).Should().BeFalse();
            (updateable != null).Should().BeTrue();

            object indirect = updateable;

            indirect.Equals(null).Should().BeFalse();
        }
예제 #19
0
        private void BgWorger_DoWork(object sender, DoWorkEventArgs e)
        {
            Updateable application = (Updateable)e.Argument;

            if (!UpdateXML.ExsistsOnServer(application.UpdateXmlLocation))
            {
                e.Cancel = true;
            }
            else
            {
                e.Result = UpdateXML.Parse(application.UpdateXmlLocation, application.ApplicationID);
            }
        }
예제 #20
0
        public UpdateInfoForm(Updateable applicationInfo, UpdateXML updateInfo)
        {
            InitializeComponent();

            if (applicationInfo.ApplicationIcon != null)
            {
                this.Icon = applicationInfo.ApplicationIcon;
            }

            this.Text = applicationInfo.ApplicationName + " - Update Info";
            this.lblVersionOld.Text   = "Current Version: " + applicationInfo.ApplicationAssembly.GetName().Version.ToString();
            this.lblVersionNew.Text   = "Current Version: " + updateInfo.Version.ToString();
            this.textDescription.Text = updateInfo.Description;
        }
예제 #21
0
        public virtual Emitter <T> AddObserver(T eventType, Updateable handler)
        {
            SortedList <Updateable> list = _emitterTable.Get(eventType);

            if (list == null)
            {
                list = new SortedList <Updateable>();
            }
            if (!list.Contains(handler))
            {
                list.Add(handler);
            }
            _emitterTable.Put(eventType, list);
            return(this);
        }
예제 #22
0
        internal UpdateAcceptForm(Updateable applicationInfo, UpdateXML updateInfo)
        {
            InitializeComponent();

            this.applicationInfo = applicationInfo;
            this.updateInfo      = updateInfo;

            this.Text = this.applicationInfo.ApplicationName + " - Update available";

            if (this.applicationInfo.ApplicationIcon != null)
            {
                this.Icon = this.applicationInfo.ApplicationIcon;
            }

            this.lblNewVersion.Text = string.Format("New Version: {0}", this.updateInfo.Version.ToString());
        }
예제 #23
0
 public void Add(Updateable update)
 {
     if (_head == null)
     {
         _head = new Entry(update);
     }
     else
     {
         Entry parent = _head;
         while (parent.next != null)
         {
             parent = parent.next;
         }
         parent.next = new Entry(update);
     }
     _count++;
 }
예제 #24
0
 public void Add(Updateable update)
 {
     if (_head == null)
     {
         _head = new Entry(update);
     }
     else
     {
         Entry parent = _head;
         while (parent.next != null)
         {
             parent = parent.next;
         }
         parent.next = new Entry(update);
     }
     _count++;
 }
예제 #25
0
파일: LProcess.cs 프로젝트: nobcdz/LGame
        private static void CallUpdateable(List <Updateable> list)
        {
            List <Updateable> loadCache;

            lock (list)
            {
                loadCache = new List <Updateable>(list);
                list.Clear();
            }
            for (int i = 0; i < loadCache.Count; i++)
            {
                Updateable running = loadCache[i];
                lock (running)
                {
                    running.Action();
                }
            }
            loadCache = null;
        }
예제 #26
0
        public Paddle()
        {
            Size = new Vector2(30, 120);

            // Coloured rectangle to represent paddle
            var paddleRect = new Rect()
            {
                Color = Colors.Black,
                Size  = Size
            };

            AddChild(paddleRect);

            // Update method that will be called every frame
            var update = new Updateable()
            {
                UpdateMethod = Update
            };

            AddComponent(update);

            // Collision component so the ball can collide with the paddle
            AddComponent <Collision>();
        }
예제 #27
0
 // --- Load start ---//
 public void AddLoad(Updateable u)
 {
     lock (loads)
     {
         loads.Add(u);
     }
 }
예제 #28
0
 public void RemoveUnLoad(Updateable u)
 {
     lock (unloads)
     {
         unloads.Remove(u);
     }
 }
예제 #29
0
 public void RemoveLoad(Updateable u)
 {
     lock (loads)
     {
         loads.Remove(u);
     }
 }
예제 #30
0
 // --- Load end ---//
 // --- UnLoad start ---//
 public void AddUnLoad(Updateable u)
 {
     lock (unloads)
     {
         unloads.Add(u);
     }
 }
예제 #31
0
 public static void AddParticle(Updateable updateable)
 {
     updatePAdd.Add(updateable);
 }
예제 #32
0
파일: LSystem.cs 프로젝트: keppelcao/LGame
 public static void Unload(Updateable u)
 {
     LProcess process = LSystem.screenProcess;
     if (process != null)
     {
         process.AddUnLoad(u);
     }
 }
예제 #33
0
 public void SetFunction(Updateable function)
 {
     this._function = function;
 }
예제 #34
0
 public abstract void InvokeAsync(Updateable action);
예제 #35
0
 public virtual void AddUnLoad(Updateable u)
 {
     if (handler != null)
     {
         handler.AddUnLoad(u);
     }
 }
예제 #36
0
 public Entry(Updateable update)
 {
     this.update = update;
 }
예제 #37
0
 public void InvokeLater(Updateable update)
 {
     _queue.Add(update);
 }
예제 #38
0
 public virtual void RemoveUnLoad(Updateable u)
 {
     if (handler != null)
     {
         handler.RemoveUnLoad(u);
     }
 }
예제 #39
0
 public ActionCounter(int limit, Updateable actListener) : base(limit)
 {
 }
예제 #40
0
 public Entry(Updateable update)
 {
     this.update = update;
 }
예제 #41
0
 public virtual LTimer SetUpdateable(Updateable u)
 {
     this._update = u;
     return(this);
 }
예제 #42
0
 public void InvokeLater(Updateable update)
 {
     _queue.Add(update);
 }
예제 #43
0
 public virtual ActionCounter SetActionListener(Updateable u)
 {
     this.actListener = u;
     return(this);
 }