Exemple #1
0
        public static void InitNew(int seed)
        {
            InitBefore();

            Terrain.CreateNew(seed);
            Terrain.Init();

            EntityManager.Init();
            Player.CreateNew();
            EntityManager.AddEntity(Player.Instance);
            Player.Instance.CorrectTerrainCollision();
            PlayerInventory.Init();
            PlayerInventory.Instance.LoadDefaultItems();


            //for (int i = 1; i <= 300; i++) {
            //    Shooter s = new Shooter(new Vector2(i * 20 * MathUtil.RandFloat(Program.Rand, 0.8f, 1.2f), 0), 100, 250);
            //    EntityManager.AddEntity(s);
            //    s.CorrectTerrainCollision();

            //    Squisher sq = new Squisher(new Vector2(i * 20 * MathUtil.RandFloat(Program.Rand, 0.8f, 1.2f), 0));
            //    EntityManager.AddEntity(sq);
            //    sq.CorrectTerrainCollision();
            //}
        }
Exemple #2
0
        public static void InitLoad(TerrainData worlddata, EntitiesData entitiesdata)
        {
            InitBefore();

            #region Terrain
            Terrain.Load(worlddata);
            Terrain.Init();
            #endregion

            #region Entities
            EntityManager.Init();

            //load other entities
            foreach (var e in entitiesdata.entities)
            {
                EntityManager.AddEntity(e);
                e.InitTimers();
            }
            #endregion

            #region Player
            //load player data
            Player.LoadPlayer(entitiesdata.player);
            EntityManager.AddEntity(Player.Instance);

            //load player inventory
            PlayerInventory.Init();
            PlayerInventory.Instance.LoadItems(entitiesdata.playerItems);
            #endregion
        }
Exemple #3
0
        public override void Update()
        {
            UpdatePosition();
            if (!shootCooldown.Ready())
            {
                return;
            }

            shootCooldown.Reset();
            Vector2 vel = Player.ToPlayer(data.pos.val);

            vel.x += MathUtil.RandFloat(Program.Rand, -0.1, 0.1);
            vel   /= 5;
            Projectile proj = new Projectile(data.pos.val, vel, projlife);

            if (!Terrain.IsColliding(proj))
            {
                EntityManager.AddEntity(proj);
            }
        }