public HelpMenuHandler(IHandler returnTo, string buttonName, GameHandler game = null)
        {
            background = Main.content.Load<Texture2D>((string)Main.Config[buttonName]["background"]);

            returnButton = new MoveButton(returnTo, (JObject)Main.Config[buttonName], true);
            this.game = game;
        }
Beispiel #2
0
 public void Update(GameHandler game)
 {
     if ((Main.newMouseState.RightButton == ButtonState.Pressed && Main.oldMouseState.RightButton == ButtonState.Released) || (Main.newMouseState.LeftButton == ButtonState.Pressed && Main.oldMouseState.LeftButton == ButtonState.Released) || Main.newKeyState.GetPressedKeys().Except(Main.oldKeyState.GetPressedKeys()).Any())
     {
         //game.Screen = null;
         //game.Initialize();
     }
 }
Beispiel #3
0
        public Entity(Vector2 pos, GameHandler game)
        {
            this.pos = pos;
            this.game = game;

            maxHealth = 100.0f; //Set default maxHealth
            maxHealthMult = 1.0f / maxHealth;
            _state = -1; //Set initial value to be non-zero, so setting state detects change
        }
 public ProjectileBall(Spell spell, GameHandler game, Entity target, Entity owner, Vector2 pos, Vector2 direction, float speed)
     : base(spell, game, target, owner)
 {
     this.pos = pos;
     this.speed = speed;
     moveSpeed = direction * speed;
     lifetime = TIMEOUT;
     lastCollide = null;
 }
 //Add target
 public ProjectileBurst(Spell spell, GameHandler game, Entity target, Entity owner, Vector2 origin, float radSquared)
     : base(spell, game, target, owner)
 {
     this.origin = origin;
     this.radSquared = radSquared;
     lifetime = TIMEOUT;
     projPos = new List<Vector2>();
     projSpeed = new List<Vector2>();
 }
Beispiel #6
0
        public PauseHandler(GameHandler game)
        {
            this.game = game;
            background = Main.content.Load<Texture2D>("pauseScreen");
            music = Main.content.Load<SoundEffect>("pauseMusic").CreateInstance();
            music.IsLooped = true;

            buttons = new List<IButton>() { new TextMoveButton(new HelpMenuHandler(this, "backBtnPause", game), (JObject)Main.Config["helpBtn2"], true), new TextMoveButton(game, (JObject)Main.Config["resumeBtn"]) };
        }
Beispiel #7
0
 public Projectile(Spell spell, GameHandler game, Entity target, Entity owner)
 {
     this.spell = spell;
     this.game = game;
     this.target = target;
     this.owner = owner;
     arcCount = spell.arcCount;
     size = new Vector2(4.0f, 4.0f); //To load
     projTexture = new AnimatedTexture(Main.content.Load<Texture2D>("flyingProj"), 3, 0.5f, 4, 4); //To load/implement
 }
Beispiel #8
0
 public override Projectile generateProjectiles(Vector2 pos, Spell spell, GameHandler game, Entity target, Entity owner)
 {
     ProjectileBurst projReturn = new ProjectileBurst(spell, game, target, owner, pos, spell.arcCount == 0 ? radSquared : arcRadSquared);
     Vector2 vecSpeed;
     for (int i = 0; i < partCount; i++)
     {
         vecSpeed = new Vector2((float)(random.NextDouble() < 0.5 ? random.NextDouble() : random.NextDouble() * -1.0), (float)(random.NextDouble() < 0.5 ? random.NextDouble() : random.NextDouble() * -1.0));
         vecSpeed.Normalize();
         vecSpeed *= (float)(random.NextDouble() * 2.0 + 1.0);
         projReturn.addProjectile(pos, vecSpeed);
     }
     return projReturn;
 }
Beispiel #9
0
 public override Projectile generateProjectiles(Vector2 pos, Spell spell, GameHandler game, Entity target, Entity owner)
 {
     Vector2 dir;
     if (target != null)
     {
         dir = target.pos - pos;
     }
     else
     {
         dir = game.posFromScreenPos(Main.newMouseState.Position.ToVector2()) - pos;//dir = game.player.dir.Vector();
     }
     dir.Normalize();
     return new ProjectileBall(spell, game, target, owner, pos, dir, speed);
 }
Beispiel #10
0
 public static Enemy SpawnEnemy(Vector2 pos, GameHandler game)
 {
     int totalChance = 0;
     foreach (Enemy enemy in enemies)
     {
         totalChance += enemy.GetSpawnChance(game);
     }
     if (totalChance == 0)
     {
         return null;
     }
     int enemyNum = random.Next(totalChance);
     totalChance = 0;
     foreach (Enemy enemy in enemies)
     {
         totalChance += enemy.GetSpawnChance(game);
         if (enemyNum < totalChance)
         {
             return enemy.Spawn(pos, game);
         }
     }
     return null;
 }
Beispiel #11
0
        //Instance enemy constructor. To be called by Spawn()
        protected Enemy(Enemy data, Vector2 pos, GameHandler game)
            : base(pos, game)
        {
            foreach (AnimatedTexture tex in data.textures)
            {
                textures.Add(new AnimatedTexture(tex));
            }

            id = data.id;

            health = data.health;
            speeds = Array.ConvertAll(data.speeds, speed => speed + (float)(random.NextDouble() * 2.0 * data.speedDeviation - data.speedDeviation));
            size = data.size;
            damage = data.damage;
            hitForce = data.hitForce;

            spawnBiome = data.spawnBiome;

            state = (int)States.STANDING;
            dir = Dir.DOWN;

            barOffset = data.barOffset;
        }
Beispiel #12
0
        public Player(Vector2 pos, GameHandler game)
            : base(pos, game)
        {
            JObject data = JObject.Parse(File.ReadAllText("Content/Player.json"));
            JObject stats = (JObject)data["Stats"];

            //Stopwatch s1 = new Stopwatch();
            //s1.Start();
            loadTextures((JObject)data["Animations"]);
            //s1.Stop();
            //Console.WriteLine(s1.ElapsedMilliseconds);

            health = (float)stats["Health"];
            var speedList = stats["Speed"];
            speeds = new[] { (float)speedList["Forest"], (float)speedList["Desert"], (float)speedList["Cold"], (float)speedList["Forest"] };
            size = new Vector2((float)stats["Width"], (float)stats["Height"]);

            state = (int)States.STANDING;
            dir = Dir.DOWN;

            knowledgePoints = 0;

            loadSkills(JArray.Parse(File.ReadAllText("Content/Skills.json")), JObject.Parse(File.ReadAllText("Content/SkillTree.json")));
        }
Beispiel #13
0
 public int GetSpawnChance(GameHandler game)
 {
     return game.terrain.getTileAtPos(game.player.pos + game.player.size).ToBiome() == spawnBiome ? 1 : 0;
 }
Beispiel #14
0
 //For EnemyManager, to be overridden to use derived constructor.
 //Spawn new enemy using current enemy as a template.
 public virtual Enemy Spawn(Vector2 pos, GameHandler game)
 {
     return new Enemy(this, pos, game);
 }
 public ProjectileStream(Spell spell, GameHandler game, Entity target, Entity owner)
     : base(spell, game, target, owner)
 {
     projectiles = new List<Vector2>();
     this.hasUpdated = false;
 }
Beispiel #16
0
 public SkillHandler(GameHandler game, Player player)
 {
     this.game = game;
     background = Main.content.Load<Texture2D>("skillTree");
     this.player = player;
 }
Beispiel #17
0
 public Projectile createProjectile(Vector2 pos, GameHandler game, Entity target)
 {
     game.player.lastCast = spell;
     return spell.shape.generateProjectiles(pos, spell, game, target, game.player);
 }
Beispiel #18
0
        public override Projectile generateProjectiles(Vector2 origin, Spell spell, GameHandler game, Entity target, Entity owner)
        {
            Vector2 dir;
            if (target != null)
            {
                dir = target.pos - origin;
            }
            else
            {
                dir = game.posFromScreenPos(Main.newMouseState.Position.ToVector2()) - origin;//dir = game.player.dir.Vector();
            }
            dir.Normalize();

            ProjectileStream projReturn = new ProjectileStream(spell, game, target, owner);

            float maxMult = projReturn.ProcessCollision(origin, dir * length);

            float mult;
            for (int i = 0; i < partCount; i++)
            {
                mult = (float)random.NextDouble();
                if (mult < maxMult)
                {
                    projReturn.addProjectile(origin + dir * length * mult);
                }
            }

            return projReturn;
        }
Beispiel #19
0
 public abstract Projectile generateProjectiles(Vector2 pos, Spell spell, GameHandler game, Entity target, Entity owner);