Exemplo n.º 1
0
        public Town(EntityState es)
            : base(es)
        {
            Body = new Body(this, Vector2.Zero, new Vector2(20,15));
            Components.Add(Body);

            TileRender = new TileRender(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/town"), new Vector2(20, 15));
            Render = TileRender;
            Render.Scale = 6f;
            Render.Layer = 1f;
            Components.Add(Render);

            Body.Position = new Vector2(StateRef.GameRef.Viewport.Width/2 - Render.DrawRect.Width / 2, 450);
            DeadCityAnim = new Animation(this, es.GameRef.Game.Content.Load<Texture2D>(@"game/deadcity"), new Vector2(20, 15), 4, "deadtown");
            DeadCityAnim.Layer = 1f;
            DeadCityAnim.Scale = 6.0f;

            Health = new Health(this, 100);
            Health.HurtEvent += ChangeColor;

            TileRender.Index = 2;
            Components.Add(Health);

            Gun = new Gun(this);
            Components.Add(Gun);

            Cursor = new Cursor(StateRef, this);
            StateRef.AddEntity(Cursor);

            Collision = new Collision(this);
            Components.Add(Collision);

            _fire = new Sound(this, es.GameRef.Game.Content.Load<SoundEffect>(@"game/sounds/bombfire"));
            Components.Add(_fire);
        }
Exemplo n.º 2
0
    void Update()
    {
        int[] intCameraRect = RectFunctions.roundRectToInts(RectFunctions.getCameraRect(Camera.main));

        for (int x = intCameraRect[0]; x <= intCameraRect[2]; x++)
        {
            for (int y = intCameraRect[1]; y <= intCameraRect[3]; y++)
            {
                Tile tile = map.getTile(x, y);
                if (tile == null)
                {
                    continue;
                }

                if (tile.IsRendering == false)
                {
                    GameObject obj        = objPool.GetPooledObject();
                    TileRender tileRender = obj.GetComponent <TileRender>();
                    tileRender.tile               = tile;
                    tileRender.tile.IsRendering   = true;
                    tileRender.transform.position = new Vector2(x, y);
                    tileRender.gameObject.SetActive(true);
                }
            }
        }
    }
Exemplo n.º 3
0
        public Town(EntityState es, XmlParser xp)
            : base(es, "Town")
        {
            Body = new Body(this, "Body");
            AddComponent(Body);

            TileRender = new TileRender(this, "TileRender");
            AddComponent(TileRender);

            DeadCityAnim = new Animation(this, "DeadCityAnim");
            AddComponent(DeadCityAnim);

            Collision = new Collision(this, "Collision");
            AddComponent(Collision);

            Health = new Health(this, "Health");
            AddComponent(Health);

            Gun = new Gun(this, "Gun");
            AddComponent(Gun);

            Targets = new Targets(this, "Targets");
            AddComponent(Targets);

            _firebombsound = new Sound(this, "FireBombSound");
            AddComponent(_firebombsound);

            _firekey = new DoubleInput(this, "FireKey", Keys.Enter, Buttons.A, PlayerIndex.One);
            AddComponent(_firekey);

            _debugkey = new DoubleInput(this, "DebugKey", Keys.Tab, Buttons.B, PlayerIndex.One);
            AddComponent(_debugkey);

            ParseXml(xp, "GameState->" + Name);

            //Add our custom data here.
            Body.Position.X = StateRef.GameRef.Viewport.Width / 2 - TileRender.DrawRect.Width / 2;

            //Set our rotation origins
            TileRender.Origin = new Vector2(TileRender.TileSize.X / 2f, TileRender.TileSize.Y / 2f);
            DeadCityAnim.Origin = TileRender.Origin;

            //TODO: Health.Hurtevent changes color
            Cursor = new Cursor(es, this, xp);
            es.AddEntity(Cursor);
        }
Exemplo n.º 4
0
        public Particle(int index, Vector2 position, int ttl, Emitter e)
            : base(e.Entity.StateRef)
        {
            Body = new Body(this, position, e.TileSize);
            Components.Add(Body);

            _tr    = new TileRender(this, e.Texture, e.TileSize);
            Render = _tr;
            Components.Add(Render);
            Index = index;

            Physics = new Physics(this);
            Components.Add(Physics);

            Emitter       = e;
            TimeToLive    = ttl;
            MaxTimeToLive = TimeToLive;
        }
Exemplo n.º 5
0
        public Particle(int index, Vector2 position, int ttl, Emitter e)
            : base(e.Entity.StateRef)
        {
            Body = new Body(this, position, e.TileSize);
            Components.Add(Body);

            _tr = new TileRender(this, e.Texture, e.TileSize);
            Render = _tr;
            Components.Add(Render);
            Index = index;

            Physics = new Physics(this);
            Components.Add(Physics);

            Emitter = e;
            TimeToLive = ttl;
            MaxTimeToLive = TimeToLive;
        }
Exemplo n.º 6
0
        public Particle(int index, Vector2 position, int ttl, Emitter e)
            : base(e.Entity.StateRef, e.Name + ".Particle")
        {
            Name = Name + ID;

            Body = new Body(this, "Body", position);
            AddComponent(Body);

            TileRender       = new TileRender(this, "TileRender", e.Texture, e.TileSize);
            TileRender.Index = index;
            AddComponent(TileRender);

            Physics = new Physics(this, "Physics");
            AddComponent(Physics);

            Emitter       = e;
            TimeToLive    = ttl;
            MaxTimeToLive = TimeToLive;
        }
Exemplo n.º 7
0
 private void InitializeContent()
 {
     Map.ClipToBounds = true;
     World            = new World.World(64, 64);
     TileRender       = new TileRender(World, Map.Dispatcher);
 }