Beispiel #1
0
	public void SaveCharacterData(){
		
		if(PlayerPrefs.GetInt("Player_SaveLoad_Slot",1000) == 1000){
			Debug.LogError ("No saveload slot");
			PlayerPrefs.SetInt("Player_SaveLoad_Slot",0);
			return;
		}	
		
		SaveLoadSlot = PlayerPrefs.GetInt("Player_SaveLoad_Slot",1000).ToString() + "_";
		Debug.Log ("Creating new game at save: " + SaveLoadSlot);
		
		
		if(!playerNew.Alive){
			Debug.Log("Can't save when dead");
			return;
		}
		
		//Set the slot to inUse
		PlayerPrefsX.SetBool (SaveLoadSlot+"inUse",true);
		//PlayerPrefs.DeleteAll (); //Needs to be deleted when finalised save and load
	
		PlayerPrefs.SetString (SaveLoadSlot+"Player_Name",playerNew.Name);
		PlayerPrefs.SetInt(SaveLoadSlot+"Player_Class",(int)playerNew.playerClass);
		
		for(int cnt=0;cnt<Enum.GetValues(typeof(AttributeName)).Length;cnt++){
			PlayerPrefs.SetInt (SaveLoadSlot+"Player_Atr_"+((AttributeName)cnt).ToString ()+"_Value",playerNew.GetAttribute(cnt).BaseValue);		
		}
		
		for(int cnt=0;cnt<Enum.GetValues(typeof(VitalName)).Length;cnt++){
			PlayerPrefs.SetInt (SaveLoadSlot+"Player_Vital_"+((VitalName)cnt).ToString ()+"_Value",playerNew.GetVital(cnt).MaxValue);
			PlayerPrefs.SetInt (SaveLoadSlot+"Player_Vital_"+((VitalName)cnt).ToString ()+"_CurValue",playerNew.GetVital(cnt).CurValue);
		}
		
		PlayerPrefs.SetInt (SaveLoadSlot+"Player_Exp",playerNew.Exp);
		PlayerPrefs.SetInt (SaveLoadSlot+"Player_ExpToLevel",playerNew.ExpToLevel);
		PlayerPrefs.SetInt (SaveLoadSlot+"Player_Level",playerNew.Level);
		
		PlayerPrefs.SetInt (SaveLoadSlot+"Player_Gold",playerNew.Gold);
		
		SaveQuestsAndAchievements();
		SaveAllItems();
		
		//When done do a reload for debugging purposes
		//LoadCharacterData();
	}
Beispiel #2
0
    private void DisplayPlayerVitalsAndExp()
    {
        //vital bars
        float hp = (float)(player.GetVital((int)VitalName.Health).CurValue) / (float)(player.GetVital((int)VitalName.Health).MaxValue) * 125.0f;
        float mp = (float)(player.GetVital((int)VitalName.Mana).CurValue) / (float)(player.GetVital((int)VitalName.Mana).MaxValue) * 125.0f;;
        float ep = (float)(player.GetVital((int)VitalName.Energy).CurValue) / (float)(player.GetVital((int)VitalName.Energy).MaxValue) * 125.0f;;

        string hptxt = string.Format("HP: {0}/{1}", player.GetVital((int)VitalName.Health).CurValue, player.GetVital((int)VitalName.Health).MaxValue);
        string mptxt = string.Format("MP: {0}/{1}", player.GetVital((int)VitalName.Mana).CurValue, player.GetVital((int)VitalName.Mana).MaxValue);
        string eptxt = string.Format("EP: {0}/{1}", player.GetVital((int)VitalName.Energy).CurValue, player.GetVital((int)VitalName.Energy).MaxValue);

        GUI.Box(new Rect(20, 15, 125, 15), string.Format("{0} [Lv.{1}]", player.Name, player.Level), "Bar"); //player name

        GUI.Box(new Rect(20, 35, 125, 10), "", "Bar");                                                       //bg
        GUI.Box(new Rect(20, 35, hp, 10), "", "HPBar");
        GUI.Box(new Rect(20, 35, 125, 10), hptxt, "TextValues");                                             //label

        GUI.Box(new Rect(20, 50, 125, 10), "", "Bar");                                                       //bg
        GUI.Box(new Rect(20, 50, mp, 10), "", "MPBar");
        GUI.Box(new Rect(20, 50, 125, 10), mptxt, "TextValues");                                             //label

        GUI.Box(new Rect(20, 65, 125, 10), "", "Bar");                                                       //bg
        GUI.Box(new Rect(20, 65, ep, 10), "", "EPBar");
        GUI.Box(new Rect(20, 65, 125, 10), eptxt, "TextValues");                                             //label

        float  exp    = (float)player.Exp / (float)player.ExpToLevel * 455;
        string exptxt = string.Format("EXP: {0}/{1}", player.Exp, player.ExpToLevel);

        GUI.Box(new Rect(Screen.width / 2 - 225, Screen.height - 30, 455, 10), "", "MPBar");          //exp bar bg
        GUI.Box(new Rect(Screen.width / 2 - 225, Screen.height - 30, exp, 10), "", "EPBar");          //exp bar
        GUI.Box(new Rect(Screen.width / 2 - 225, Screen.height - 30, 455, 10), exptxt, "TextValues"); //label
    }
Beispiel #3
0
    public void DealDamage(int damage)
    {
        int damageToDeal = (int)Random.Range(damage * 0.3f, damage + 1);
        int baseDamage   = (int)(damageToDeal * Random.Range(0.1f, 0.2f));

        damageToDeal -= baseDamage;
        if (!Invincible)
        {
            //Armor blocks it
            damageToDeal -= _pc.PlayerArmor;


            GameObject dmgTxt = Instantiate(globalPrefabs.floatingDamageText, transform.position, Quaternion.identity) as GameObject;
            dmgTxt.transform.parent = this.transform;
            FloatingTextGUI dmgText = dmgTxt.GetComponent <FloatingTextGUI>();
            dmgText.PlayerDamage("", _pc.transform.position, 0.5f);

            //Chance to block (damage blocked always equal to Pc.DamageBlocked)
            int blockRandom = Random.Range(0, 100 + 1);

            if (blockRandom < (_pc.PlayerChanceToBlock * 100))
            {
                damageToDeal -= _pc.PlayerDamageBlocked;

                dmgText.AddToText(ToolTipStyle.Italic + "\t" + ToolTipStyle.Small + "Block!" + ToolTipStyle.EndSize + ToolTipStyle.EndItalic);
            }

            //deal the damage
            if (damageToDeal < 0)
            {
                damageToDeal = 0;
            }

            damageToDeal += baseDamage;             //will always do some damage

            dmgText.AddToText(ToolTipStyle.Break + ToolTipStyle.Brown + "-" + damageToDeal.ToString() + ToolTipStyle.EndColor);
            _pc.GetVital((int)VitalName.Health).CurValue -= damageToDeal;
        }
    }
Beispiel #4
0
    private void ProcHandler(MonsterAI fa)
    {
        Weapon wep = playerNew.EquipedWeapon as Weapon;

        if (wep != null)
        {
            if (wep.Proc == ProcType.Slow || wep.Proc == ProcType.Poison ||
                wep.Proc == ProcType.Knockback || wep.Proc == ProcType.Stun)
            {
                int randomNum = Random.Range(0, 100 + 1);
                if (randomNum < (wep.ProcModifier * 100))
                {
                    switch (wep.Proc)
                    {
                    case ProcType.Slow:
                        fa.SlowAttackSpeed(0.3f);
                        break;

                    case ProcType.Poison:
                        int damageToDeal = (int)(fa.MonsterHealth * 0.01);
                        fa.UseDot("Poison", damageToDeal, 5, 0.5f);
                        break;

                    case ProcType.Knockback:
                        fa.KnockBackSelf();
                        break;

                    case ProcType.Stun:
                        fa.StunSelf(3.0f);
                        break;
                    }
                }
            }
            else
            {
                switch (wep.Proc)
                {
                case ProcType.GainLifeOnHit:
                    playerNew.GetVital((int)VitalName.Health).CurValue += (int)wep.ProcModifier;
                    GameObject infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    FloatingTextGUI ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    var             info = ToolTipStyle.Green + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.GainEnergyOnHit:
                    playerNew.GetVital((int)VitalName.Energy).CurValue += (int)wep.ProcModifier;
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Yellow + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.GainManaOnHit:
                    playerNew.GetVital((int)VitalName.Mana).CurValue += (int)wep.ProcModifier;
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Blue + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToLife:
                    playerNew.GetVital((int)VitalName.Health).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Green + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToEnergy:
                    playerNew.GetVital((int)VitalName.Energy).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Yellow + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToMana:
                    playerNew.GetVital((int)VitalName.Mana).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Blue + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                default:
                    break;
                }
            }
        }
    }