Exemplo n.º 1
0
        public override void reward(Player player, ModCollection mods)
        {
            int exp = (int)(40 * (float)level / (float)player.level);

            exp = Math.Min(exp, 75);
            exp = Math.Max(exp, 1);

            if (player.lv != 50)
            {
                player.getEXP(exp);
                countXPGained += exp;
            }

            if (startLv < player.level)
            {
                mods.generate(Math.Min(player.level, level));
                rewardLabel = mods.lastMod;
            }
            else
            {
                rewardLabel = "-";
            }
        }
Exemplo n.º 2
0
        public override void reward(Player player, ModCollection mods)
        {
            int exp = (int)(40 * (float)level / (float)player.level);
                exp = Math.Min(exp, 75);
                exp = Math.Max(exp, 1);

                if (player.lv != 50)
                {
                    player.getEXP(exp);
                    countXPGained += exp;
                }

            if (startLv < player.level)
            {
                mods.generate(Math.Min(player.level, level));
                rewardLabel = mods.lastMod;
            }
            else rewardLabel = "-";
        }
Exemplo n.º 3
0
        public bool update(GameTime gameTime, BulletCollection bullets, Camera camera, Player p, Mission m)
        {
            #region npc death
            //die and grant xp
            if (health <= 0 && !isDead)
            {
                int exp = (int)(XP * (float)level / (float)p.level);
                exp = Math.Min(exp, (int)(XP * 1.5f));
                exp = Math.Max(exp, 1);
                if (p.lv == 50)
                {
                    exp = 0;
                }
                else
                {
                    p.getEXP(exp);
                }
                m.update(kind, exp);
                isDead             = true;
                isHit              = false;
                hitTimer           = 0;
                explosion.Position = Position + new Vector3(0, 0.5f, 0);
                explosion.Initialize(camera);
            }

            //Explosion Update if NPC is down
            if (isDead && active)
            {
                hitTimer++;
                explosion.Update(gameTime, camera);
                if (hitTimer > 25)
                {
                    active = false;
                    isDead = false;
                    this.explosion.Clear();
                    dmgNumbers.Clear();
                    return(false);
                }
            }
            #endregion

            #region shoot

            //shoot if player is within shooting distance and not on cooldown
            if (playerDistance <= world.shootDistance && cooldown == 0)
            {
                cooldown = maxCooldn;
                Vector3 dir = (p.position - position);
                dir.Normalize();
                bullets.generate(false, position + dir, dir, 1, world.shootDistance * 2, strength, element);
                audio.playShoot(false);
            }

            if (cooldown > 0)
            {
                cooldown--;
            }
            #endregion

            #region move
            //if (moving)
            //move();
            //else



            if (!moving || !move())
            {
                {
                    pathFinder.setup(new Point((int)Math.Round((-1 * position.X + world.size - 1)), (int)Math.Round((-1 * position.Z + world.size - 1))), p);
                    target    = pathFinder.findPath(kind == Constants.NPC_BOSS);
                    newTarget = true;
                    direction = target - position;
                    if (direction.Length() != 0)
                    {
                        direction.Normalize();
                    }
                    moving = true;
                    //move();
                }
            }

            #endregion

            #region get hit billboard/dmg number
            //Hit Notification
            if (isHit)
            {
                hitTimer++;
                billboardEngine.AddBillboard(this.position + new Vector3(0, 2, 0), Color.Red, 1.5f);
                if (hitTimer == 70)
                {
                    isHit    = false;
                    hitTimer = 0;
                }
            }
            #endregion

            //Rotate Model
            double rotationAngle = Math.Acos((Vector3.Dot(direction, -1 * Vector3.UnitX)) / (direction.Length()));
            rotationAngle  = (p.Position.Z < this.Position.Z) ? rotationAngle * -1.0f : rotationAngle;
            rotationAngle += (this.kind == Constants.NPC_BOSS) ? Math.PI / 2 : -Math.PI / 2;
            model.Rotation = new Vector3(0, (float)(rotationAngle), 0);

            //Update PlayerDistance
            playerDistance = (p.Position - this.Position).Length();

            if (playerDistance < 4)
            {
                target    = position;
                direction = p.Position - this.Position;
            }

            return(true);
        }
Exemplo n.º 4
0
Arquivo: NPC.cs Projeto: kayorga/3DSP
        public bool update(GameTime gameTime, BulletCollection bullets, Camera camera, Player p, Mission m)
        {
            #region npc death
            //die and grant xp
            if (health <= 0 && !isDead)
            {
                int exp = (int)(XP * (float)level / (float)p.level);
                exp = Math.Min(exp,(int) (XP * 1.5f));
                exp = Math.Max(exp, 1);
                if (p.lv == 50) exp = 0;
                else p.getEXP(exp);
                m.update(kind, exp);
                isDead = true;
                isHit = false;
                hitTimer = 0;
                explosion.Position = Position + new Vector3(0, 0.5f, 0);
                explosion.Initialize(camera);
            }

            //Explosion Update if NPC is down
            if (isDead && active)
            {
                hitTimer++;
                explosion.Update(gameTime, camera);
                if (hitTimer > 25)
                {
                    active = false;
                    isDead = false;
                    this.explosion.Clear();
                    dmgNumbers.Clear();
                    return false;
                }
            }
            #endregion

            #region shoot

            //shoot if player is within shooting distance and not on cooldown
            if (playerDistance <= world.shootDistance && cooldown == 0)
            {
                cooldown = maxCooldn;
                Vector3 dir = (p.position - position);
                dir.Normalize();
                bullets.generate(false, position + dir, dir, 1, world.shootDistance * 2, strength, element);
                audio.playShoot(false);
            }

            if (cooldown > 0) cooldown--;
            #endregion

            #region move
            //if (moving)
                //move();
            //else

            if (!moving || !move())
            {
                {
                    pathFinder.setup(new Point((int)Math.Round((-1 * position.X + world.size - 1)), (int)Math.Round((-1 * position.Z + world.size - 1))), p);
                    target = pathFinder.findPath(kind == Constants.NPC_BOSS);
                    newTarget = true;
                    direction = target - position;
                    if (direction.Length() != 0) direction.Normalize();
                    moving = true;
                    //move();
                }
            }

            #endregion

            #region get hit billboard/dmg number
            //Hit Notification
            if (isHit)
            {
                hitTimer++;
                billboardEngine.AddBillboard(this.position + new Vector3(0, 2, 0), Color.Red, 1.5f);
                if (hitTimer == 70)
                {
                    isHit = false;
                    hitTimer = 0;
                }
            }
            #endregion

            //Rotate Model
            double rotationAngle = Math.Acos((Vector3.Dot(direction, -1 * Vector3.UnitX)) / (direction.Length()));
            rotationAngle = (p.Position.Z < this.Position.Z) ? rotationAngle * -1.0f : rotationAngle;
            rotationAngle += (this.kind == Constants.NPC_BOSS) ? Math.PI / 2 : -Math.PI / 2;
            model.Rotation = new Vector3(0, (float)(rotationAngle), 0);

            //Update PlayerDistance
            playerDistance = (p.Position - this.Position).Length();

            if (playerDistance < 4)
            {
                target = position;
                direction = p.Position - this.Position;
            }

            return true;
        }