예제 #1
0
        public static void RemoveHitArea(HitArea a)
        {
            Group             g = a.SelfGroup;
            HashSet <HitArea> ha;

            if (hitAreaDic.TryGetValue(g, out ha))
            {
                lock (ha) {
                    ha.Remove(a);
                }
            }
        }
예제 #2
0
        public static void AddHitArea(HitArea a)
        {
            Group             g = a.SelfGroup;
            HashSet <HitArea> ha;

            if (hitAreaDic.TryGetValue(g, out ha))
            {
                ha.Add(a);
            }
            else
            {
                ha = new HashSet <HitArea>();
                ha.Add(a);
                hitAreaDic.Add(g, ha);
            }
        }
예제 #3
0
        //bool frameSkip = false;

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // この辺のフレームスキップの作成意図がよく分からないので一旦コメントアウト
            // 戻す場合frameSkipのコメントアウトも戻す
            //if (updateCount++ > 0 && frameSkip) return;
            //if (updateCount++ > 0) return;
            updateCount++;

            //Debug.WriteLine("======== Update Start ========" + string.Format("(ticks = {0})", gameTime.ElapsedGameTime.Ticks));
            Input.UpdateKeyboard();
            Input.UpdateJoystick();
            HitArea.CheckHitArea();
            Message.PostAll();
            GameObject.UpdateAll(gameTime);

            GlobalWorldOffset = Matrix.CreateScale(-1, 1, -1);

            //Debug.WriteLine("========= Update OK  =========");
            base.Update(gameTime);
            //Debug.WriteLine("========= Update End =========");
        }
예제 #4
0
 private static bool Intersects(HitArea x, HitArea y)
 {
     return((x.X - y.X) * (x.X - y.X) + (x.Y - y.Y) * (x.Y - y.Y) <= (x.Size + y.Size));
 }