Exemplo n.º 1
0
        public void Draw(GameTime gameTime, bool Blur)
        {
            if (Blur)
            {
                TileSpriteBatch.Begin();
                EntitySpriteBatch.Begin();
            }
            else
            {
                TileSpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone);
                EntitySpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone);
            }

            for (int Ty = W.Camera.StartTile.Y; Ty <= W.Camera.EndTile.Y; Ty++)
            {
                for (int Tx = W.Camera.StartTile.X; Tx <= W.Camera.EndTile.X; Tx++)
                {
                    if (Tx >= 0 && Ty >= 0 && Tx < W.worldProperty.Size * 16 - 1 && Ty < W.worldProperty.Size * 16 - 1)
                    {
                        //Calcule des emplacements
                        CurrentLocation  = new Point(Tx, Ty);
                        OnScreenLocation = new Point(
                            (Tx - W.Camera.StartTile.X) * W.Camera.Zoom + W.Camera.ScreenOrigine.X,
                            (Ty - W.Camera.StartTile.Y) * W.Camera.Zoom + W.Camera.ScreenOrigine.Y);

                        //Recuperation des arguments
                        GameObject.Event.GameObjectEventArgs e = W.eventsManager.GetEventArgs(CurrentLocation.ToWorldLocation(), OnScreenLocation);

                        //recuperation des objets
                        Obj.ObjTile T = W.chunkManager.GetTile(CurrentLocation);


                        //desin des objets


                        GameObjectsManager.Tiles[T.ID].OnDraw(e, TileSpriteBatch, gameTime);



                        if (!(T.Entity == -1))
                        {
                            Obj.ObjEntity E = W.chunkManager.GetEntity(CurrentLocation);
                            GameObjectsManager.Entities[E.ID].OnDraw(e, EntitySpriteBatch, gameTime);
                        }
                    }
                }
            }
            TileSpriteBatch.End();
            EntitySpriteBatch.End();
        }
Exemplo n.º 2
0
        public GameObject.Event.GameObjectEventArgs GetEventArgs(WorldLocation Location, Point _OnScreenLocation)
        {
            GameObject.Event.GameObjectEventArgs args = new GameObject.Event.GameObjectEventArgs();

            args.CurrentLocation = Location;

            args.ParrentTile = W.chunkManager.GetTile(Location);

            if (args.ParrentTile.Entity == -1)
            {
                args.ParrentEntity = new Obj.ObjEntity(-1, -1);
            }
            else
            {
                args.ParrentEntity = W.chunkManager.GetEntity(Location);
            }

            args.World            = W;
            args.OnScreenLocation = _OnScreenLocation;

            return(args);
        }
Exemplo n.º 3
0
        public override void Update(MouseState Mouse, KeyboardState KeyBoard, GameTime gameTime)
        {
            for (int Tx = W.Camera.StartTile.X; Tx <= W.Camera.EndTile.X; Tx++)
            {
                for (int Ty = W.Camera.StartTile.Y; Ty <= W.Camera.EndTile.Y; Ty++)
                {
                    if (Tx >= 0 && Ty >= 0 && Tx < W.worldProperty.Size * 16 - 1 && Ty < W.worldProperty.Size * 16 - 1)
                    {
                        //Calcule des emplacements
                        CurrentLocation  = new Point(Tx, Ty);
                        OnScreenLocation = new Point(
                            (Tx - W.Camera.StartTile.X) * W.Camera.Zoom + W.Camera.ScreenOrigine.X,
                            (Ty - W.Camera.StartTile.Y) * W.Camera.Zoom + W.Camera.ScreenOrigine.Y);

                        //recuperation des arguments
                        GameObject.Event.GameObjectEventArgs e = W.eventsManager.GetEventArgs(CurrentLocation.ToWorldLocation(), OnScreenLocation);

                        //recuperation des objets
                        Obj.ObjTile T = W.chunkManager.GetTile(CurrentLocation);

                        GameObjectsManager.Tiles[T.ID].OnTick(e, gameTime);
                        GameObjectsManager.Tiles[T.ID].OnUpdate(e, KeyBoard, Mouse, gameTime);

                        if (!(T.Entity == -1))
                        {
                            //On recuper l'entitée
                            Obj.ObjEntity E = W.chunkManager.GetEntity(CurrentLocation);
                            E.Location = CurrentLocation.ToWorldLocation();

                            GameObjectsManager.Entities[E.ID].OnTick(e, gameTime);
                            GameObjectsManager.Entities[E.ID].OnUpdate(e, KeyBoard, Mouse, gameTime);
                        }
                    }
                }
            }

            base.Update(Mouse, KeyBoard, gameTime);
        }
Exemplo n.º 4
0
        public void ExecuteAction(GameObject.Event.GameObjectEventArgs e, GameTime gametime)
        {
            if (e.ParrentEntity.IAToDo.Count > 0)
            {
                Helper.Action a   = e.ParrentEntity.IAToDo[0];
                Point         pt  = new Point(0, 0);
                Vector2       Vc2 = Vector2.Zero;
                e.ParrentEntity.ActionProgress += a.aSpeed;
                float P = e.ParrentEntity.ActionProgress;



                switch (a.aType)
                {
                case Helper.ActionType.Move:

                    switch (a.aDirection)
                    {
                    case Helper.Direction.Up:

                        pt  = new Point(0, -1);
                        Vc2 = new Vector2(0, -P / 100);

                        break;

                    case Helper.Direction.Down:

                        pt  = new Point(0, 1);
                        Vc2 = new Vector2(0, P / 100);

                        break;

                    case Helper.Direction.Left:

                        pt  = new Point(-1, 0);
                        Vc2 = new Vector2(-P / 100, 0);

                        break;

                    case Helper.Direction.Right:

                        pt  = new Point(1, 0);
                        Vc2 = new Vector2(P / 100, 0);

                        break;

                    default:
                        break;
                    }

                    if (!(e.World.entityManager.TileIsFree(Location.AddPoint(e.CurrentLocation, pt))))
                    {
                        e.ParrentEntity.IAToDo.Remove(a);
                        e.ParrentEntity.ActionProgress = 0;
                        e.ParrentEntity.OnTileLocation = Vector2.Zero;
                    }
                    else
                    {
                        if (e.ParrentEntity.ActionProgress == 100)
                        {
                            e.ParrentEntity.ActionProgress = 0;
                            e.ParrentEntity.OnTileLocation = Vector2.Zero;
                            e.World.entityManager.MoveEntity(e.CurrentLocation, Location.AddPoint(e.CurrentLocation, pt));
                            e.ParrentEntity.IAToDo.Remove(a);

                            GameObjectsManager.Tiles[e.ParrentTile.ID].OnEntityWalkIn(e, gametime);
                        }
                        else
                        {
                            e.ParrentEntity.OnTileLocation = Vc2;
                        }

                        if (e.ParrentEntity.IsFocus)
                        {
                            e.World.Camera.FocusLocation        = e.ParrentEntity.Location.ToPoint();
                            e.World.Camera.PreciseFocusLocation = e.ParrentEntity.OnTileLocation;
                        }
                    }
                    break;

                case Helper.ActionType.Atack:
                    break;

                case Helper.ActionType.Destroy:
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 5
0
 public virtual void Tick(GameObject.Event.GameObjectEventArgs e, KeyboardState _KeyBoard, MouseState _Mouse, GameTime _GameTime)
 {
     //do nothing
 }