Inheritance: MonoBehaviour
Exemplo n.º 1
0
    public int UpdateValues()
    {
        var newLevel = Mathf.Max(0, Mathf.FloorToInt(1 - Mathf.Log(Mathf.Max(1, xp) / baseLevelXP, levelIncreaseCoefficient))) + 1;
        var levelXP  = Mathf.Pow(levelIncreaseCoefficient, 1 - newLevel) * baseLevelXP;
        var progress = xp / levelXP;

        progressBar.progress = progress;
        progressBar.UpdateButton();

        if (newLevel != level)
        {
            if (level != -1)
            {
                LevelUp.Show(newLevel);
            }

            level           = newLevel;
            levelLabel.text = $"Level {newLevel}";
        }

        xpLabel.text = $"{xp} / {levelXP}";

        displayedAnimationToggle.Displayed = newLevel > 1;
        return(newLevel);
    }
Exemplo n.º 2
0
    void Initialized()
    {
        BaseWarriorClass warrior = new BaseWarriorClass(); // Need to make a method that gets the stats from warrior,

        baseCharacter.classess       = BaseCharacterClass.CharacterClasses.WARRIOR;
        GameInformation.PlayerClass  = baseCharacter;
        GameInformation.PlayerName   = "Anaku";// Will change later once we get the actual names of the heros in the story.
        GameInformation.PlayerLevel  = 0;
        GameInformation.Agility      = warrior.Agility;
        GameInformation.Strength     = warrior.Strength;
        GameInformation.Intellect    = warrior.Intellect;
        GameInformation.Mastery      = warrior.Mastery;
        GameInformation.Stamina      = warrior.Stamina;
        GameInformation.Resistance   = 100;
        GameInformation.Endurance    = warrior.Endurance;
        GameInformation.PlayerHealth = calculations.CalculateHealth(GameInformation.Endurance);
        GameInformation.PlayerEnergy = calculations.CalculateEnergy(GameInformation.Intellect);
        GameInformation.CurrentXp    = 0;
        GameInformation.CritChance   = 5 + (GameInformation.Agility * 0.2f);         // Affected by agility and items
        GameInformation.CritDamage   = 2 * ((GameInformation.Agility * 0.1f) / 100); // Affect by agility and some items
        GameInformation.Zodiac       = new BaseTigerClass();                         // The zodiac side and zodiac you are
        GameInformation.SummonsUp    = 0;
        basePlayer.SetStats(false);
        basePlayer.StatPointsToAllocate = 0;
        basePlayer.PlayerClass          = GameInformation.PlayerClass;
        // This will be how we calculate the p layers main stat.
        LevelUp levelUp = new LevelUp();

        for (int i = 0; i < level; i++)
        {
            levelUp.LevelUpCharacter();
        }
        Debug.Log(GameInformation.RequiredXP);
    }
Exemplo n.º 3
0
 void Start()
 {
     stateMachine = GetComponent <StateMachine>();
     levelUp      = GetComponent <LevelUp>();
     currentState = BattleStates.START;
     hero         = GetComponent <HeroCharacter>();
 }
Exemplo n.º 4
0
        public void Add(int amount)
        {
            if (Level >= MaxLevel)
            {
                return;
            }

            Current += amount;
            Changed?.Invoke(this);

            while (Current >= RequiredNextLevel())
            {
                Level = Math.Min(MaxLevel, Level + 1);

                LevelUp?.Invoke(this);
                Changed?.Invoke(this);

                if (Level < MaxLevel)
                {
                    continue;
                }

                Level   = MaxLevel;
                Current = RequiredNextLevel();
                break;
            }
        }
Exemplo n.º 5
0
    // Token: 0x06002B9F RID: 11167 RVA: 0x00480BC0 File Offset: 0x0047EDC0
    public void UpdateExp()
    {
        if (this.ItemKind - 1 != 9 || this.EffectVal != 33)
        {
            return;
        }
        DataManager instance    = DataManager.Instance;
        LevelUp     recordByKey = instance.LevelUpTable.GetRecordByKey((ushort)instance.RoleAttr.Level);
        float       num         = 424.47f / recordByKey.KingdomExp;
        Vector2     sizeDelta   = this.Degree.sizeDelta;

        this.VipBarStr.ClearString();
        if (instance.RoleAttr.Level < 60)
        {
            this.VipBarStr.IntToFormat((long)((ulong)instance.RoleAttr.Exp), 1, true);
            this.VipBarStr.IntToFormat((long)((ulong)recordByKey.KingdomExp), 1, true);
            this.VipBarStr.AppendFormat(instance.mStringTable.GetStringByID(896u));
            sizeDelta.x = num * instance.RoleAttr.Exp;
        }
        else
        {
            this.VipBarStr.Append(instance.mStringTable.GetStringByID(898u));
            sizeDelta.x = 424.7f;
        }
        this.Degree.sizeDelta = sizeDelta;
        this.BarText.text     = this.VipBarStr.ToString();
        this.BarText.SetAllDirty();
        this.BarText.cachedTextGenerator.Invalidate();
        this.VipLvStr.ClearString();
        this.VipLvStr.IntToFormat((long)instance.RoleAttr.Level, 1, false);
        this.VipLvStr.AppendFormat(instance.mStringTable.GetStringByID(895u));
        this.VipLvText.text = this.VipLvStr.ToString();
        this.VipLvText.SetAllDirty();
        this.VipLvText.cachedTextGenerator.Invalidate();
    }
Exemplo n.º 6
0
 //private static LevelUp levelUp = new LevelUp();
 public static void AddExperience(int XP) //Increases player experience for every player in the party and checks if conditions for level up are met
 {
     GameInformation.Player1Experience += XP;
     if (GameInformation.Player1Experience >= GameInformation.Player1Required)
     {
         BaseCharacterClass playerClass = new BaseHeroClass();
         LevelUp.LevelUpCharacter(playerClass, GameInformation.Player1Level);
     }
     if (GameInformation.Player2 != 0)
     {
         GameInformation.Player2Experience += XP;
         if (GameInformation.Player2Experience >= GameInformation.Player2Required)
         {
             //Level Up Function
         }
     }
     if (GameInformation.Player3 != 0)
     {
         GameInformation.Player3Experience += XP;
         if (GameInformation.Player3Experience >= GameInformation.Player3Required)
         {
             //Level Up Function
         }
     }
     if (GameInformation.Player4 != 0)
     {
         GameInformation.Player4Experience += XP;
         if (GameInformation.Player4Experience >= GameInformation.Player4Required)
         {
             //Level Up Function
         }
     }
 }
Exemplo n.º 7
0
 public void UpLevel()
 {
     Debug.Log("UpLevel from " + CurrLevel + " to " + (CurrLevel + 1));
     CurrLevel++;
     AudioManager.Instance.Play("LevelUp");
     LevelUp?.Invoke(CurrLevel);
 }
Exemplo n.º 8
0
        private void LateUpdate()
        {
            if (CurrentRow <= TrainController.TargetRail.Row + RowsAfter)
            {
                if (CurrentRow % 10 == 0)
                {
                    LevelUp?.Invoke();
                }
                GenerateRails();

                if (TrainController.TargetRail.Row - RowsBefore >= 0)
                {
                    foreach (var oldRail in _rowsList[TrainController.TargetRail.Row - RowsBefore].Rails)
                    {
                        if (oldRail != null)
                        {
                            oldRail.ReturnToPool();
                        }
                    }
                }
            }

            if (CurrentRow == RowsAfter && !_uiService.IsFirstTime)
            {
                InitialRailController.SwitchRail();
            }
        }
Exemplo n.º 9
0
 private void Update()
 {
     if (GameInformation.CurrentXp > GameInformation.RequiredXP)
     {
         LevelUp level = new LevelUp();
         level.LevelUpCharacter();
     }
 }
Exemplo n.º 10
0
 private void Start()
 {
     key         = FindObjectOfType <MenuHandler>();
     controller  = FindObjectOfType <CharacterMovement>();
     interact    = FindObjectOfType <Interact>();
     inv         = FindObjectOfType <Inventory>();
     skillWindow = FindObjectOfType <LevelUp>();
 }
Exemplo n.º 11
0
        public LevelUps(JToken j)
        {
            var moves    = (JArray)j[nameof(LevelUpMoves)];
            int numMoves = moves.Count;

            LevelUpMoves = new LevelUp[numMoves];
            for (int i = 0; i < numMoves; i++)
            {
                LevelUpMoves[i] = new LevelUp(moves[i]);
            }
        }
Exemplo n.º 12
0
 void Awake()
 {
     if (L == null)
     {
         L = this;
     }
     else
     {
         Debug.LogError("ERROR: NewLevel.Awake(): L is already set!");
     }
 }
Exemplo n.º 13
0
        private void HandleLevelUpKeys(ResultSet resultSet)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            int index = -1;

            for (char i = 'a'; i <= 'c'; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    index = (int)(i - 'a');
                    break;
                }
            }

            // Check if pointer clicked on any of the items
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                if (mMenuInventory.pointerIndex >= 0 && mMenuInventory.pointerIndex <= 2)
                {
                    index = mMenuInventory.pointerIndex;
                }
            }

            LevelUp levelUp = LevelUp.None;

            if (index >= 0 && index <= 2)
            {
                switch (index)
                {
                case 0:
                    levelUp = LevelUp.Hp;
                    break;

                case 1:
                    levelUp = LevelUp.Str;
                    break;

                case 2:
                    levelUp = LevelUp.Def;
                    break;
                }

                resultSet.AddLevelUp(levelUp);

                RB.SoundPlay(game.assets.soundSelectOption, 1, RandomUtils.RandomPitch(0.1f));
            }
        }
Exemplo n.º 14
0
        private void LevelUp_Click(object sender, EventArgs e)
        {
            LevelUp levelUp = new LevelUp(player, player.storedLevelUps);

            levelUp.ShowDialog();

            player.level         += player.storedLevelUps;
            player.storedLevelUps = 0;

            levelUpButton.Enabled = false;
            levelUpButton.Text    = "Already leveled up";
        }
Exemplo n.º 15
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
     sn = snGO.GetComponent<SelecaoNiveis>();
     btns = btnsGO.GetComponent<buttons>();
     btl = btlGO.GetComponent<Battle>();
     ce = ceGO.GetComponent<CreateEnemys>();
     lu = luGO.GetComponent<LevelUp>();
 }
Exemplo n.º 16
0
    public void EndMatch(bool isWin)
    {
        setDefault();
        currentToken = PData.Tokens;

        LvlUpType = PData.SetXP(isWin);
        EndToken  = GameSparksManager.playerData.Tokens;

        GameSparksManager.EndMatch(isWin);

        StartCoroutine("AnimateXpScreen");
    }
Exemplo n.º 17
0
        // disassembler
        private void Disassemble()
        {
            int offset = (index * 20) + 0x3A002C;

            //
            startingLevel      = rom[offset++];
            startingCurrentHP  = Bits.GetShort(rom, offset); offset += 2;
            startingMaxHP      = Bits.GetShort(rom, offset); offset += 2;
            startingSpeed      = rom[offset++];
            startingAttack     = rom[offset++];
            startingDefense    = rom[offset++];
            startingMgAttack   = rom[offset++];
            startingMgDefense  = rom[offset++];
            startingExperience = Bits.GetShort(rom, offset); offset += 2;
            startingWeapon     = rom[offset++];
            startingArmor      = rom[offset++];
            startingAccessory  = rom[offset]; offset += 2;
            //
            startingMagic = new bool[32];
            int a = 0;

            for (int o = 0; o < 4; o++, offset++)
            {
                for (int i = 0; i < 8; i++)
                {
                    startingMagic[a++] = Bits.GetBit(rom, offset, i);
                }
            }
            // set up the levels
            levels = new LevelUp[31];
            for (int i = 2; i < levels.Length; i++)
            {
                levels[i] = new LevelUp(i, index);
            }
            //
            startingCoins     = Bits.GetShort(rom, 0x3A00DB);
            startingCurrentFP = rom[0x3A00DD];
            startingMaximumFP = rom[0x3A00DE];
            startingFrogCoins = Bits.GetShort(rom, 0x3A00DF);
            //
            defenseStartL1 = rom[0x02C9B3];
            defenseStartL2 = rom[0x02C9B9];
            defenseEndL2   = rom[0x02C9BF];
            defenseEndL1   = rom[0x02C9C5];
            //
            name = new char[10];
            for (int i = 0; i < name.Length; i++)
            {
                name[i] = (char)rom[(index * 10) + 0x3a134d + i];
            }
        }
Exemplo n.º 18
0
    private static void SetupStats()
    {
        PlayerCPU = 1;
        BaseClass classType = PlayerClass;

        RAM        = classType.RAM;
        CurrentRAM = classType.RAM;
        CurrentXP  = 0;
        LevelUp.DetermineRequiredXP();
        Strength        = classType.Strength;
        Dexterity       = classType.Dexterity;
        Intellect       = classType.Intellect;
        PlayerFunctions = PlayerClass.functions;
    }
Exemplo n.º 19
0
    //Send the iD of the completed Quest
    /// <summary>
    ///ID has to be 1 or greater
    /// </summary>
    /// <param name="iD"></param>
    /// <returns></returns>
    public override void CompleteQuest(int iD)
    {
        FetchQuest fetchQuest = new FetchQuest();

        fetchQuest = (FetchQuest)quest[iD - 1];
        fetchQuest.isQuestComplete = true;
        GameInformation.CurrentXp += GetXPReward(iD);
        if (GameInformation.CurrentXp > GameInformation.RequiredXP)
        {
            LevelUp level = new LevelUp();
            level.LevelUpCharacter();
        }
        GameInformation.Gold += GetGoldReward(iD);
    }
Exemplo n.º 20
0
 public static IEnumerable <LevelUp> ReadCsv()
 {
     string[] lines = File.ReadAllLines(Application.dataPath + "/LevelUp.csv");
     return(lines.Select(line =>
     {
         string[] data = line.Split(',');
         LevelUp up = new LevelUp();
         up.level = Convert.ToInt32(data[0]);
         up.exp = Convert.ToInt32(data[1]);
         up.atk = Convert.ToInt32(data[2]);
         up.def = Convert.ToInt32(data[3]);
         up.hp = Convert.ToInt32(data[4]);
         return up;
     }));
 }
Exemplo n.º 21
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
     sn = snGO.GetComponent<SelecaoNiveis>();
     btns = btnsGO.GetComponent<buttons>();
     btl = btlGO.GetComponent<Battle>();
     ce = ceGO.GetComponent<CreateEnemys>();
     lu = luGO.GetComponent<LevelUp>();
     ask = askGO.GetComponent<ActivateSkills>();
     us = usGO.GetComponent<UseSkills>();
     lus = lusGO.GetComponent<levelUpSkills>();
     su = suGO.GetComponent<Save_User>();
 }
    private void Start()
    {
        //make sure player is alive
        alive = true;
        //connect the Character Controller to the controller variable
        controller = GetComponent <CharacterController>();
        movement   = GetComponent <CharacterMovement>();
        checkPoint = GetComponent <CheckPoint>();
        levelUp    = GetComponent <LevelUp>();

        maxHealth = 100 * constitution;
        //set current health to max
        curHealth         = maxHealth;
        movement.runSpeed = 7 + dexterity;
        LoadStats();
        healTimer = startHealTime;
    }
Exemplo n.º 23
0
    public void Win()
    {
        rewards = GameObject.FindObjectOfType <MapRewards>();


        LevelUp.LevelUpNow();

        if (CurrentGame.game.memoryGeneral.levelHolder.ogLevels.currentLevels.Exists(x => x == CurrentGame.game.memoryGeneral.currentLevel))
        {
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.levelHolder.ogLevels.currentLevels.Find(x => x == CurrentGame.game.memoryGeneral.currentLevel).complete = true;
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.gold += CurrentGame.game.memoryGeneral.currentLevel.goldReward;
            CurrentGame.game.memoryGeneral.unitsInParty.Clear();
        }
        else if (CurrentGame.game.memoryGeneral.levelHolder.ftLevels.currentLevels.Exists(x => x == CurrentGame.game.memoryGeneral.currentLevel))
        {
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.levelHolder.ftLevels.currentLevels.Find(x => x == CurrentGame.game.memoryGeneral.currentLevel).complete = true;
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.gold += CurrentGame.game.memoryGeneral.currentLevel.goldReward;


            CurrentGame.game.memoryGeneral.unitsInParty.Clear();
        }
        else if (CurrentGame.game.memoryGeneral.levelHolder.swLevels.currentLevels.Exists(x => x == CurrentGame.game.memoryGeneral.currentLevel))
        {
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.levelHolder.swLevels.currentLevels.Find(x => x == CurrentGame.game.memoryGeneral.currentLevel).complete = true;
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.gold += CurrentGame.game.memoryGeneral.currentLevel.goldReward;
            CurrentGame.game.memoryGeneral.unitsInParty.Clear();
        }
        else if (CurrentGame.game.memoryGeneral.levelHolder.gdLevels.currentLevels.Exists(x => x == CurrentGame.game.memoryGeneral.currentLevel))
        {
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.levelHolder.gdLevels.currentLevels.Find(x => x == CurrentGame.game.memoryGeneral.currentLevel).complete = true;
            CurrentGame.game.memoryGeneral.currentLevel.complete = true;
            CurrentGame.game.memoryGeneral.gold += CurrentGame.game.memoryGeneral.currentLevel.goldReward;


            CurrentGame.game.memoryGeneral.unitsInParty.Clear();
        }

        StartCoroutine(BackToTown());
    }
Exemplo n.º 24
0
 // Update is called once per frame
 void Update()
 {
     Move();
     if (remainingDamageFrames > 0)
     {
         remainingDamageFrames--;
         if (remainingDamageFrames == 0)
         {
             UnShowDamage();
         }
     }
     if (increaseScore == 1)
     {
         Main.S.score += scoreIncrease;
         increaseScore = 0;
         LevelUp.CheckLevelUp();
     }
 }
Exemplo n.º 25
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.TryGetComponent <ColliderScript>(out ColliderScript collider))
     {
         if (transform.localScale.x > 0.175f)
         {
             transform.localScale -= new Vector3(0.025f, 0.025f);
         }
     }
     if (collision.TryGetComponent <Raindrops>(out Raindrops raindrops))
     {
         if (transform.localScale.x < 0.3f)
         {
             transform.localScale += new Vector3(0.01f, 0.01f);
             _speed += 0.1f;
             LevelUp.GainExp(10);
         }
     }
 }
Exemplo n.º 26
0
 private void OnGUI()
 {
     if (GUILayout.Button("EXP + 10"))
     {
         LevelUp.AddExperience(10);
     }
     if (GUILayout.Button("EXP + 100"))
     {
         LevelUp.AddExperience(100);
     }
     if (GUILayout.Button("EXP + 1000"))
     {
         LevelUp.AddExperience(1000);
     }
     if (GUILayout.Button("EXP + 10000"))
     {
         LevelUp.AddExperience(10000);
     }
 }
Exemplo n.º 27
0
 // On click to OpenBox, looks at how many items are in the box and adds an Item.
 public void OpenBox()
 {
     if (User.user.LootBoxes > 0)
     {
         LootBox lootBox = GenerateLootBox();
         if (User.user.inventory.Count + lootBox.ItemCount > User.user.InventorySlots)
         {
             errorText.enabled = true;
             errorText.text    = "Your inventory is too full!";
             StartCoroutine(DisableErrorText());
             return;
         }
         for (int i = 0; i < lootBox.ItemCount; i++)
         {
             GameObject thisObject = lootManager.lootSlots[i].gameObject;
             ClearItemSprites(thisObject);
             CreateLoot(thisObject, thisObject.GetComponent <Image>());
         }
         User.user.Experience += lootBox.Experience;
         if (User.user.Experience >= User.user.ExperienceToNext)
         {
             LevelUp levelUp = new LevelUp();
             levelUp.IncreaseLevel(playerLevelText, firebaseManager);
         }
         if (User.user.LootBoxes == User.user.MaxLootBoxes)
         {
             firebaseManager.UpdateLastTimeOpenedLootBox();
         }
         User.user.LootBoxes  -= 1;
         User.user.Experience += lootBox.Experience;
         firebaseManager.UpdateDatabaseValues();
     }
     else
     {
         errorText.enabled = true;
         errorText.text    = "You do not have any more loot boxes!";
         StartCoroutine(DisableErrorText());
     }
     //DataManager.dataManager.Save();
 }
Exemplo n.º 28
0
    public void Setup(PlayerStatus playerStatus)
    {
        this.playerStatus = playerStatus;

        //アイテムのセットアップ
        items = new Dictionary <ItemType, ItemBase>();
        ItemBase item;

        item = new Rest();
        items.Add(item.Type, item);

        item = new LevelUp();
        items.Add(item.Type, item);

        item = new Portion();
        items.Add(item.Type, item);

        item = new InfinitePower();
        items.Add(item.Type, item);

        item = new Resurrection();
        items.Add(item.Type, item);
    }
Exemplo n.º 29
0
    /// <summary>
    /// Start is called before the first frame update
    /// </summary>
    void Start()
    {
        // Start level timer
        levelTime           = ConfigurationUtils.InitialLevelTimer;
        levelTimer          = gameObject.AddComponent <Timer>();
        levelTimer.Duration = ConfigurationUtils.InitialLevelTimer + 1;
        levelTimer.AddTimerFinishedListener(HandleLevelTimerFinished);
        levelTimer.Run();

        // Set level
        level = 1;

        // Initialize text
        timeLeftText      = GameObject.FindGameObjectWithTag("TimeLeftText").GetComponent <Text>();
        levelText         = GameObject.FindGameObjectWithTag("LevelText").GetComponent <Text>();
        timeLeftText.text = timeLeftPrefix + levelTime;
        levelText.text    = levelPrefix + level;

        // Initialize events and add class as invoker
        levelUp   = new LevelUp();
        playerWon = new PlayerWon();
        EventManager.AddLevelUpInvoker(this);
        EventManager.AddPlayerWonInvoker(this);
    }
Exemplo n.º 30
0
 private void OnEnable()
 {
     level = FindObjectOfType <LevelUp>();
 }
Exemplo n.º 31
0
        public void NotifyLevelUp(IChampion c)
        {
            var lu = new LevelUp(c);

            _packetHandlerManager.BroadcastPacket(lu, Channel.CHL_S2C);
        }
Exemplo n.º 32
0
        void ApplyLevel(LevelUp levelUp)
        {
            xp += levelUp.xp;
            level += levelUp.level;
            nextLevelXP = GetXPtoNextLevel(level);

            foreach(Stat lvlStat in levelUp.growth)
            {
                foreach(Stat charStat in stats)
                {
                    if(charStat.id == lvlStat.id)
                    {
                        charStat.baseValue += lvlStat.baseValue;
                        break;
                    }
                }
            }
        }
Exemplo n.º 33
0
        LevelUp CreateLevelUp()
        {
            LevelUp newLevel = new LevelUp();

            newLevel.xp = -GetXPtoNextLevel(level);
            newLevel.level = 1;
            newLevel.growth = new Stat[statsGrowth.Length];

            for(int i = 0; i < statsGrowth.Length; i++)
            {
                newLevel.growth[i] = new Stat();
                newLevel.growth[i].id = statsGrowth[i].id;
                newLevel.growth[i].baseValue = statsGrowth[i].RollDice();
            }

            return newLevel;
        }
Exemplo n.º 34
0
        private static async void LevelUpAsync(IMessage message, User user, int level)
        {
            SocketTextChannel channel = message.Channel as SocketTextChannel;

            if (Program.Guilds.GetValueOrDefault(channel.Guild.Id).LevelupChannel != 0)
            {
                channel = Program.Client.GetChannel(Program.Guilds.GetValueOrDefault(channel.Guild.Id).LevelupChannel) as SocketTextChannel;
            }
            if (!File.Exists($"{Program.Rootdir}\\Users\\LevelUp\\{user.Id}.gif"))
            {
                try { await channel.SendMessageAsync("", false, Embed.GetEmbed($"Congratulations {message.Author.Username} you are now level {level}!", "You havn't uploaded a levelup image yet")); }
                catch { await channel.SendMessageAsync("", false, Embed.GetEmbed("Get Levelup", "Sorry there was an error")); }
                return;
            }

            var tmp = await channel.SendMessageAsync("", false, Embed.GetEmbed($"Congratulations {message.Author.Username} you are now level {level}!", "Loading image..."));

            try
            {
                int globalRank = await Ranks.GetGlobalRank(message.Author.Id);

                int localRank = await Ranks.GetLocalRank(channel.Guild, message.Author.Id);

                if (!File.Exists($"{Program.Rootdir}\\Users\\LevelUp\\{user.Id}Processed.gif") || Program.Users.GetValueOrDefault(user.Id).changed == true)
                {
                    var tmpimg = await LevelUp.MakeLevelAsync(user.Id);

                    if (tmpimg.Length > 8000000)
                    {
                        await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed($"Congratulations {message.Author.Username} you are now level {level}!", "Levelup image is too big for discord after processing"));

                        GC.Collect();
                        return;
                    }
                    else
                    {
                        File.WriteAllBytes($"{Program.Rootdir}\\Users\\LevelUp\\{message.Author.Id}Processed.gif", tmpimg);
                        Program.Users.GetValueOrDefault(message.Author.Id).changed = false;
                        await Program.SaveUser(user.Id);
                    }
                }
                try
                {
                    await channel.SendFileAsync($"{Program.Rootdir}\\Users\\LevelUp\\{user.Id}Processed.gif", "", false, Embed.GetEmbed($"Congratulations {message.Author} you are now level {level}!", $"You currently rank:\nGuild: {localRank}\nOverall: {globalRank}"));
                }
                catch
                {
                    await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed("Get Levelup", "Sorry there was an error"));

                    GC.Collect();
                    return;
                }
                await tmp.DeleteAsync();
            }
            catch
            {
                await tmp.ModifyAsync(x => x.Embed = Embed.GetEmbed($"Congratulations {message.Author.Username} you are now level {level}!", "Sorry there was an error"));

                GC.Collect();
                return;
            }
        }
Exemplo n.º 35
0
 void DebugLevelUp(LevelUp lvlUp)
 {
     int debugLevel = level + lvlUp.level;
     Debug.Log(string.Format("<b><color=purple>LEVEL UP! (Level {0})</color></b>", debugLevel));
     Debug.Log(string.Format("HP:+{0} MP:+{1}",
         lvlUp.GetGrowth("MaxHP"),
         lvlUp.GetGrowth("MaxMP")));
     Debug.Log(string.Format("Atk:+{0} Def:+{1} Str:+{2} Mag:+{3} Spd:+{4} Lck:+{5}",
         lvlUp.GetGrowth("Attack"),
         lvlUp.GetGrowth("Defense"),
         lvlUp.GetGrowth("Strength"),
         lvlUp.GetGrowth("Magic"),
         lvlUp.GetGrowth("Speed"),
         lvlUp.GetGrowth("Luck")));
     Debug.Log(string.Format("***XP TO NEXT LEVEL: {0}***", GetXPtoNextLevel(debugLevel)));
 }
Exemplo n.º 36
0
 protected new void Start()
 {
     base.Start();
     if(controlled) {
         hud = gameObject.AddComponent<HUD>();
         playerTurn = gameObject.AddComponent<PlayerTurn>();
         lu = gameObject.AddComponent<LevelUp>();
     }
     levelUpsAvailable += 19;
 }
Exemplo n.º 37
0
    static void Draw ( LevelUp _c, GizmoType _gizmoType ) {
        if ( EditorApplication.isPlaying ) return;

        Gizmos.color = Color.green;
        foreach ( GameObject go in _c.targets ) {
            if ( go == null )
                continue;
            Vector3 position = _c.transform.position;
            Gizmos.DrawLine (position, go.transform.position);
        }
    }