Exemplo n.º 1
0
    public static Character CreateCharacter(string charName, string className, int level, int xp, int move, int range, int hp, int mp, 
        CharacterInventory invent, int patk, int pdef, int matk, int mdef)
    {
        var thisObj = CharOBJ.AddComponent<Character>();

        //calls Start() on the object and initializes it.
        thisObj._name = charName;

        thisObj._characterClass = new CharacterClass(className, level, xp);
        thisObj._moves = move;
        thisObj.attackRange = range;

        thisObj._maxHealth = hp;
        thisObj._currHealth = hp;

        thisObj._maxMagic = mp;
        thisObj._currMagic = mp;

        thisObj._characterInventory = invent;
        thisObj._physAttack = patk;
        thisObj._physDefense = pdef;
        thisObj._magicAttack = matk;
        thisObj._magicDefense = mdef;

        return thisObj;
    }
Exemplo n.º 2
0
 public void ArmorThatWasInInventoryIsNotDoubleCountedWhenEquippedTwice()
 {
     var inventory = new CharacterInventory { _testArmor };
     inventory.EquippedArmor = _testArmor;
     inventory.EquippedArmor = _testArmor;
     inventory.Should().HaveCount(1);
 }
Exemplo n.º 3
0
 public Character()
 {
     this._spellRanks = new CharacterSpellRanks(this);
     this._weaponRanks = new CharacterWeaponRanks(this);
     this._skillRanks = new CharacterSkillRanks(this);
     this._inventory = new CharacterInventory();
     this._languageRanks = new CharacterLanguageRanks(this);
 }
Exemplo n.º 4
0
 public override void Pickup(CharacterInventory inventory)
 {
     if (Application.isWebPlayer) {
         Application.ExternalEval ("window.open('" + Link + "','_blank')");
     } else {
         Application.OpenURL (Link);
     }
     base.Pickup (inventory);
 }
Exemplo n.º 5
0
 public virtual void Pickup(CharacterInventory inventory)
 {
     if (inventory != null) {
         inventory.AddItemByIdemData (this, Quantity, NumTag, -1);
         if (SoundPickup) {
             AudioSource.PlayClipAtPoint (SoundPickup, this.transform.position);
         }
     }
     RemoveItem();
 }
Exemplo n.º 6
0
 public void PopulateEnemy(List<Personnages> list)
 {
     List<Character> enemyTeam = new List<Character>();
     CharacterInventory invent = new CharacterInventory();
     Personnages p;
     for (int i = 0; i < list.Count; ++i)
     {
         p = list[i];
         enemyTeam.Add(Character.CreateCharacter(p.Nom, p.ClassName, p.Level, p.Moves, p.Range, p.Health, p.Magic,
             invent, p.PhysAtk, p.PhysDef, p.MagicAtk, p.MagicDef));
     }
     _enemyTeam = enemyTeam;
 }
Exemplo n.º 7
0
    public override void Pickup(CharacterInventory inventory)
    {
        if (inventory != null && Items != null) {

            foreach (var item in Items) {
                if (item.Item != null) {
                    Debug.Log ("Pick up " + item.Item + "Num tag "+item.NumTag);
                    inventory.AddItemByIdemData (item.Item, item.Num,item.NumTag,-1);
                }
            }
        }

        RemoveItem();
    }
Exemplo n.º 8
0
    public bool CheckNeeds(ItemCrafter Crafter, CharacterInventory inventory)
    {
        if (Crafter == null || inventory == null)
            return false;

        for (int i=0; i<Crafter.ItemNeeds.Length; i++) {
            if (Crafter.ItemNeeds [i].Item) {
                if (inventory.GetItemNum (Crafter.ItemNeeds [i].Item) < Crafter.ItemNeeds [i].Num) {
                    return false;
                }
            }
        }
        return true;
    }
Exemplo n.º 9
0
    public bool Craft(CharacterInventory inventory)
    {
        if (ItemSelected == null || inventory == null)
            return false;

        characterInventory = inventory;
        for (int i=0; i<ItemSelected.ItemNeeds.Length; i++) {
            if (ItemSelected.ItemNeeds [i].Item) {
                if (characterInventory.GetItemNum (ItemSelected.ItemNeeds [i].Item) < ItemSelected.ItemNeeds [i].Num) {
                    return false;
                }
            }
        }
        crafting = true;
        timeTemp = Time.time;
        return true;
    }
Exemplo n.º 10
0
 public void SetupAwake()
 {
     DontDestroyOnLoad (this.gameObject);
     networkViewer = this.GetComponent<NetworkView> ();
     Motor = this.GetComponent<CharacterMotor> ();
     controller = this.GetComponent<CharacterController> ();
     Audiosource = this.GetComponent<AudioSource> ();
     animator = this.GetComponent<Animator> ();
     rayActive = this.GetComponent<FPSRayActive> ();
     inventory = this.GetComponent<CharacterInventory> ();
     spdMovAtkMult = 1;
 }
    // Constuctor Definition:
    // A Special Method of the class which gets automatically invoked whenever an instance of the class is created. Like Methods, a Constructor
    // also contains the collection if instructions that are executed at the time of Object creation.

    // This doesnt make a hole lot of sense to me cause it is a Custom Class and we cannot simply create an instance of this class??
    // We manually create a new instance of this class whenever we create a new type of Character.

    // Self: When is a new Instance of this Class created? At Runtime When an gameObject(Character) in the active in the Scene holds this script!
    #endregion
    public CharacterStats()
    {
        // We are accessing our charInv via the CharacterInventory'ies Singleton instance and
        // are assigning it to charInv!
        charInv = CharacterInventory.Instance;
    }
Exemplo n.º 12
0
 public void ItemCanBeAddedToInventory()
 {
     var testSubject = new CharacterInventory();
     var item = new Item("Fake item", 0);
     testSubject.Add(item);
     testSubject.Should().Contain(item);
 }
Exemplo n.º 13
0
    void LoadUnitInfo(GameObject unit)
    {
        CharacterStats     stats = unit.GetComponent <CharacterStats>();
        CharacterInventory items = unit.GetComponent <CharacterInventory>();

        strength.text  = stats.GetStrength().ToString();
        magic.text     = stats.GetMagic().ToString();
        agiliy.text    = stats.GetSpeed().ToString();
        dexterity.text = stats.GetDexterity().ToString();
        defense.text   = stats.GetDefense().ToString();
        faith.text     = stats.GetFaith().ToString();
        build.text     = stats.GetBuild().ToString();
        move.text      = stats.GetMovement().ToString();

        if (items.equippedWeapon != null)
        {
            weapon.text = items.equippedWeapon.name;
        }
        else
        {
            weapon.text = "None";
        }
        if (items.equippedArmor != null)
        {
            armor.text = items.equippedArmor.name;
        }
        else
        {
            armor.text = "None";
        }
        if (items.inventory[0] != null)
        {
            itemOne.text = items.inventory[0].name;
        }
        else
        {
            itemOne.text = "None";
        }
        if (items.inventory[1] != null)
        {
            itemTwo.text = items.inventory[1].name;
        }
        else
        {
            itemTwo.text = "None";
        }
        if (items.inventory[2] != null)
        {
            itemThree.text = items.inventory[2].name;
        }
        else
        {
            itemThree.text = "None";
        }

        damage.text = stats.GetCombatAttack().ToString();
        if (items.equippedWeapon != null)
        {
            damageType.text = items.equippedWeapon.damageType.ToString();
        }
        else
        {
            damageType.text = "None";
        }
        accuracy.text    = stats.GetAccuracy().ToString();
        critChance.text  = stats.GetCritDamage().ToString();
        combatSpeed.text = stats.GetCombatSpeed().ToString();
        if (items.equippedArmor != null)
        {
            cutResist.text  = (stats.GetCombatDefense() + items.equippedArmor.cutBonus).ToString();
            stabResist.text = (stats.GetCombatDefense() + items.equippedArmor.stabBonus).ToString();
            bashResist.text = (stats.GetCombatDefense() + items.equippedArmor.bashBonus).ToString();
        }
        else
        {
            cutResist.text  = stats.GetCombatDefense().ToString();
            stabResist.text = stats.GetCombatDefense().ToString();
            bashResist.text = stats.GetCombatDefense().ToString();
        }
        critEvade.text = stats.GetCritDefense().ToString();
        evasion.text   = stats.GetCombatEvasion().ToString();
    }
Exemplo n.º 14
0
    private void JsonToCharacter(int i)
    {
        List <DayRoutine> sundayroutines    = new List <DayRoutine> ();
        List <DayRoutine> saturdayroutines  = new List <DayRoutine> ();
        List <DayRoutine> fridayroutines    = new List <DayRoutine> ();
        List <DayRoutine> thursdayroutines  = new List <DayRoutine> ();
        List <DayRoutine> wednesdayroutines = new List <DayRoutine> ();
        List <DayRoutine> tuesdayroutines   = new List <DayRoutine> ();
        List <DayRoutine> mondayroutines    = new List <DayRoutine> ();

        WeekRoutine weekroutine = new WeekRoutine(mondayroutines, tuesdayroutines, wednesdayroutines, thursdayroutines, fridayroutines, saturdayroutines, sundayroutines);

        CharacterInventory    inventory       = new CharacterInventory();
        List <RegularExpense> regularexpenses = new List <RegularExpense> ();
        List <RegularIncome>  regularincomes  = new List <RegularIncome> ();

        int      wealth   = (int)CurrentJsonData[i]["wealth"];
        Property property = new Property(wealth, regularincomes, regularexpenses, inventory);

        int currentposition = (int)CurrentJsonData[i]["currenttime"];
        int currenttime     = (int)CurrentJsonData[i]["currentposition"];
        PhysicalTemporal physicaltemporal = new PhysicalTemporal(currentposition, currenttime);


        List <Relationship> relationshiplist = new List <Relationship> ();
        List <Reputation>   reputationlist   = new List <Reputation> ();


        List <MentalDisorder> mentalhealth = new List <MentalDisorder> ();
        Skills skills = new Skills();

        List <Event>      pastlifeevents      = new List <Event> ();
        List <Motivation> pastlifemotivations = new List <Motivation> ();
        List <Need>       pastlifeneeds       = new List <Need> ();
        List <Thought>    pastlifethoughts    = new List <Thought> ();

        List <Event>      pastyearevents      = new List <Event> ();
        List <Motivation> pastyearmotivations = new List <Motivation> ();
        List <Need>       pastyearneeds       = new List <Need> ();
        List <Thought>    pastyearthoughts    = new List <Thought> ();

        List <Event>      pastmonthevents      = new List <Event> ();
        List <Motivation> pastmonthmotivations = new List <Motivation> ();
        List <Need>       pastmonthneeds       = new List <Need> ();
        List <Thought>    pastmonththoughts    = new List <Thought> ();

        List <Event>      pastweekevents      = new List <Event> ();
        List <Motivation> pastweekmotivations = new List <Motivation> ();
        List <Need>       pastweekneeds       = new List <Need> ();
        List <Thought>    pastweekthoughts    = new List <Thought> ();

        List <Event>      pastdayevents      = new List <Event> ();
        List <Motivation> pastdaymotivations = new List <Motivation> ();
        List <Need>       pastdayneeds       = new List <Need> ();
        List <Thought>    pastdaythoughts    = new List <Thought> ();

        PastLifetimeEvent pastlife  = new PastLifetimeEvent(pastlifethoughts, pastlifeneeds, pastlifemotivations, pastlifeevents);
        PastYearEvent     pastyear  = new PastYearEvent(pastyearthoughts, pastyearneeds, pastyearmotivations, pastyearevents);
        PastMonthEvent    pastmonth = new PastMonthEvent(pastmonththoughts, pastmonthneeds, pastmonthmotivations, pastmonthevents);
        PastWeekEvent     pastweek  = new PastWeekEvent(pastweekthoughts, pastweekneeds, pastweekmotivations, pastweekevents);
        PastDayEvent      pastday   = new PastDayEvent(pastdaythoughts, pastdayneeds, pastdaymotivations, pastdayevents);
        Memory            memory    = new Memory(pastday, pastweek, pastmonth, pastyear, pastlife);


        int            currentvigilance  = (int)CurrentJsonData[i]["currentvigilance"];
        int            currentecstasy    = (int)CurrentJsonData[i]["currentecstasy"];
        int            currentadmiration = (int)CurrentJsonData[i]["currentadmiration"];
        int            currentterror     = (int)CurrentJsonData[i]["currentterror"];
        int            currentamazement  = (int)CurrentJsonData[i]["currentamazement"];
        int            currentgrief      = (int)CurrentJsonData[i]["currentgrief"];
        int            currentloathing   = (int)CurrentJsonData[i]["currentloathing"];
        int            currentrage       = (int)CurrentJsonData[i]["currentrage"];
        CurrentEmotion emotion           = new CurrentEmotion(currentrage, currentloathing, currentgrief, currentamazement, currentterror, currentadmiration, currentecstasy, currentvigilance);


        Cognition cognition = new Cognition();

        int extraversion      = (int)CurrentJsonData[i]["extraversion"];
        int openness          = (int)CurrentJsonData[i]["openness"];
        int neuroticism       = (int)CurrentJsonData[i]["neuroticism"];
        int agreeableness     = (int)CurrentJsonData[i]["agreeableness"];
        int conscientiousness = (int)CurrentJsonData[i]["conscientiousness"];
        FundamentalPersonalityCharacteristics characteristics = new FundamentalPersonalityCharacteristics(conscientiousness, agreeableness, neuroticism, openness, extraversion);
        Personality personality = new Personality(characteristics);

        int       air     = (int)CurrentJsonData[i]["air"];
        int       shelter = (int)CurrentJsonData[i]["shelter"];
        int       warmth  = (int)CurrentJsonData[i]["warmth"];
        int       sleep   = (int)CurrentJsonData[i]["sleep"];
        int       water   = (int)CurrentJsonData[i]["water"];
        int       food    = (int)CurrentJsonData[i]["food"];
        BodyNeeds needs   = new BodyNeeds(food, water, sleep, warmth, shelter, air);

        int  currentenergy  = (int)CurrentJsonData[i]["currentenergy"];
        int  maxenergy      = (int)CurrentJsonData[i]["maxenergy"];
        int  consciousstate = (int)CurrentJsonData[i]["consciousstate"];
        bool deadoralive    = (bool)CurrentJsonData[i]["deadoralive"];

        BodyCondition bodycondition = new BodyCondition(deadoralive, consciousstate, maxenergy, currentenergy, needs);

        bool      rightarm  = (bool)CurrentJsonData[i]["rightarm"];
        bool      leftarm   = (bool)CurrentJsonData[i]["leftarm"];
        bool      rightleg  = (bool)CurrentJsonData[i]["rightleg"];
        bool      leftleg   = (bool)CurrentJsonData[i]["leftleg"];
        bool      smell     = (bool)CurrentJsonData[i]["smell"];
        bool      hearing   = (bool)CurrentJsonData[i]["hearing"];
        bool      sight     = (bool)CurrentJsonData[i]["sight"];
        BodyParts bodyparts = new BodyParts(sight, hearing, smell, leftleg, rightleg, leftarm, rightarm);

        int            bodytype  = (int)CurrentJsonData[i]["bodytype"];
        int            sex       = (int)CurrentJsonData[i]["sex"];
        int            height    = (int)CurrentJsonData[i]["height"];
        int            age       = (int)CurrentJsonData[i]["age"];
        int            race      = (int)CurrentJsonData[i]["race"];
        BasicBodyStats bodystats = new BasicBodyStats(race, age, height, sex, bodytype);

        string firstname      = (string)CurrentJsonData[i]["firstname"].ToString();
        string lastname       = (string)CurrentJsonData[i]["lastname"].ToString();
        int    nametype       = (int)CurrentJsonData[i]["nametype"];
        string commonnickname = (string)CurrentJsonData[i]["commonnickname"].ToString();

        string slug = (string)CurrentJsonData[i]["slug"].ToString();
        int    id   = (int)CurrentJsonData[i]["id"];

        CharacterName     charactername = new CharacterName(firstname, lastname, nametype, commonnickname);
        Body              body          = new Body(bodystats, bodyparts, bodycondition);
        Mind              mind          = new Mind(personality, cognition, emotion, memory, mentalhealth, skills);
        SocialCondition   social        = new SocialCondition(relationshiplist, reputationlist);
        PhysicalCondition physical      = new PhysicalCondition(physicaltemporal, property, weekroutine);
        CharacterSprites  sprites       = new CharacterSprites(slug);

        Character CurrentCharacter = new Character(charactername, id, body, mind, social, physical, sprites);

        CharacterList.Add(CurrentCharacter);
    }
Exemplo n.º 15
0
 void Awake()
 {
     instance = this;
 }
 void Start()
 {
     instance = this;
 }
Exemplo n.º 17
0
    public void DisplayCharacterInventory(CharacterInventory characterInventory, GameObject slotItemPrefab)
    {
        _slotItemPrefab = slotItemPrefab;

        GameObject RightHand = transform.GetChild(0).gameObject;
        GameObject LeftHand  = transform.GetChild(1).gameObject;
        GameObject Equipment = transform.GetChild(2).gameObject;
        GameObject Inventory = transform.GetChild(3).gameObject;

        Debug.Assert(RightHand != null);
        Debug.Assert(LeftHand != null);
        Debug.Assert(Equipment != null);
        Debug.Assert(Inventory != null);

        GameObject Head  = Equipment.transform.GetChild(0).gameObject;
        GameObject Chest = Equipment.transform.GetChild(1).gameObject;
        GameObject Hands = Equipment.transform.GetChild(2).gameObject;
        GameObject Feet  = Equipment.transform.GetChild(3).gameObject;

        Debug.Assert(Head != null);
        Debug.Assert(Chest != null);
        Debug.Assert(Hands != null);
        Debug.Assert(Feet != null);

        // Destroy all the children so this function can be used to refresh the inventory.
        // Left hand right hand.
        for (int i = 0; i < RightHand.transform.childCount; ++i)
        {
            if (RightHand.transform.GetChild(i).childCount != 0)
            {
                Destroy(RightHand.transform.GetChild(i).GetChild(0).gameObject);
            }
            if (LeftHand.transform.GetChild(i).childCount != 0)
            {
                Destroy(LeftHand.transform.GetChild(i).GetChild(0).gameObject);
            }
        }
        // Head Chest Hands Feet
        if (Head.transform.GetChild(0).transform.childCount != 0)
        {
            Destroy(Head.transform.GetChild(0).transform.GetChild(0).gameObject);
        }
        if (Chest.transform.GetChild(0).transform.childCount != 0)
        {
            Destroy(Chest.transform.GetChild(0).transform.GetChild(0).gameObject);
        }
        if (Hands.transform.GetChild(0).transform.childCount != 0)
        {
            Destroy(Hands.transform.GetChild(0).transform.GetChild(0).gameObject);
        }
        if (Feet.transform.GetChild(0).transform.childCount != 0)
        {
            Destroy(Feet.transform.GetChild(0).transform.GetChild(0).gameObject);
        }
        // Inventory
        for (int i = 0; i < Inventory.transform.childCount; ++i)
        {
            if (Inventory.transform.GetChild(i).childCount != 0)
            {
                Destroy(Inventory.transform.GetChild(i).GetChild(0).gameObject);
            }
        }

        // Populate the UI.
        // Left and Right Hands.
        for (int i = 0; i < characterInventory.leftHand.Length - 1; ++i)
        {
            if (characterInventory.rightHand[i] != null)
            {
                GameObject newSlotItem = Instantiate(_slotItemPrefab, RightHand.transform.GetChild(i), false);
                newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.rightHand[i];
                Component   objectDataComponent = characterInventory.rightHand[i].GetComponent(typeof(IObjectData));
                IObjectData objectData          = objectDataComponent as IObjectData;
                newSlotItem.GetComponent <Text> ().text = objectData.objectName();
                if (objectData.count() != 1)
                {
                    newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
                }
            }
            if (characterInventory.leftHand[i] != null)
            {
                GameObject newSlotItem = Instantiate(_slotItemPrefab, LeftHand.transform.GetChild(i), false);
                newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.leftHand[i];
                Component   objectDataComponent = characterInventory.leftHand[i].GetComponent(typeof(IObjectData));
                IObjectData objectData          = objectDataComponent as IObjectData;
                newSlotItem.GetComponent <Text> ().text = objectData.objectName();
                if (objectData.count() != 1)
                {
                    newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
                }
            }
        }

        // Head
        if (characterInventory.head != null)
        {
            GameObject newSlotItem = Instantiate(_slotItemPrefab, Head.transform.GetChild(0), false);
            newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.head;
            Component   objectDataComponent = characterInventory.head.GetComponent(typeof(IObjectData));
            IObjectData objectData          = objectDataComponent as IObjectData;
            newSlotItem.GetComponent <Text> ().text = objectData.objectName();
            if (objectData.count() != 1)
            {
                newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
            }
        }

        // Chest
        if (characterInventory.chest != null)
        {
            GameObject newSlotItem = Instantiate(_slotItemPrefab, Chest.transform.GetChild(0), false);
            newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.chest;
            Component   objectDataComponent = characterInventory.chest.GetComponent(typeof(IObjectData));
            IObjectData objectData          = objectDataComponent as IObjectData;
            newSlotItem.GetComponent <Text> ().text = objectData.objectName();
            if (objectData.count() != 1)
            {
                newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
            }
        }

        // Hands
        if (characterInventory.hands != null)
        {
            GameObject newSlotItem = Instantiate(_slotItemPrefab, Hands.transform.GetChild(0), false);
            newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.hands;
            Component   objectDataComponent = characterInventory.hands.GetComponent(typeof(IObjectData));
            IObjectData objectData          = objectDataComponent as IObjectData;
            newSlotItem.GetComponent <Text> ().text = objectData.objectName();
            if (objectData.count() != 1)
            {
                newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
            }
        }

        // Feet
        if (characterInventory.feet != null)
        {
            GameObject newSlotItem = Instantiate(_slotItemPrefab, Feet.transform.GetChild(0), false);
            newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.feet;
            Component   objectDataComponent = characterInventory.feet.GetComponent(typeof(IObjectData));
            IObjectData objectData          = objectDataComponent as IObjectData;
            newSlotItem.GetComponent <Text> ().text = objectData.objectName();
            if (objectData.count() != 1)
            {
                newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
            }
        }

        // Inventory
        Debug.Assert(characterInventory.inventory.Count == 5);
        for (int i = 0; i < characterInventory.inventory.Count; ++i)
        {
            if (characterInventory.inventory[i] != null)
            {
                GameObject newSlotItem = Instantiate(_slotItemPrefab, Inventory.transform.GetChild(i), false);
                newSlotItem.GetComponent <SlotObjectContainer> ().obj = characterInventory.inventory[i];
                Component   objectDataComponent = characterInventory.inventory[i].GetComponent(typeof(IObjectData));
                IObjectData objectData          = objectDataComponent as IObjectData;
                newSlotItem.GetComponent <Text> ().text = objectData.objectName();
                if (objectData.count() != 1)
                {
                    newSlotItem.GetComponent <Text> ().text += " x" + objectData.count();
                }
            }
        }
    }
Exemplo n.º 18
0
 public ItemPickUp()
 {
     _inventory = CharacterInventory.instance;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InventoryChangeTracker"/> class.
 /// </summary>
 /// <param name="inventory">The <see cref="CharacterInventory"/> to track the changes for.</param>
 public InventoryChangeTracker(CharacterInventory inventory)
 {
     _inventory = inventory;
 }
Exemplo n.º 20
0
    public bool UnequipArmour(ItemPickUp armourPickup, CharacterInventory inventory)
    {
        var previousArmourSame = false;

        switch (armourPickup.itemDefinition.ItemArmourSubType)
        {
        case ItemArmourSubType.Head:
            if (headArmour != null)
            {
                if (headArmour == armourPickup)
                {
                    previousArmourSame = true;
                }

                currentResistance -= armourPickup.itemDefinition.itemAmount;
                headArmour         = null;
            }
            break;

        case ItemArmourSubType.Chest:
            if (chestArmour != null)
            {
                if (chestArmour == armourPickup)
                {
                    previousArmourSame = true;
                }

                currentResistance -= armourPickup.itemDefinition.itemAmount;
                chestArmour        = null;
            }
            break;

        case ItemArmourSubType.Hands:
            if (handArmour != null)
            {
                if (handArmour == armourPickup)
                {
                    previousArmourSame = true;
                }
                currentResistance -= armourPickup.itemDefinition.itemAmount;
                handArmour         = null;
            }
            break;

        case ItemArmourSubType.Legs:
            if (legArmour != null)
            {
                if (legArmour == armourPickup)
                {
                    previousArmourSame = true;
                }
                currentResistance -= armourPickup.itemDefinition.itemAmount;
                legArmour          = null;
            }
            break;

        case ItemArmourSubType.Feet:
            if (feetArmour != null)
            {
                if (feetArmour == armourPickup)
                {
                    previousArmourSame = true;
                }
                currentResistance -= armourPickup.itemDefinition.itemAmount;
                feetArmour         = null;
            }
            break;
        }

        return(previousArmourSame);
    }
Exemplo n.º 21
0
 public void EquipWeapon(ItemPickUp weaponPickUp, CharacterInventory charInventory, GameObject weaponSlot)
 {
     weapon        = weaponPickUp;
     currentDamage = baseDamage + weapon.itemDefinition.itemAmount;
 }
Exemplo n.º 22
0
 public CharacterStats()
 {
     charInv = CharacterInventory.instance;
 }
Exemplo n.º 23
0
 public void Start()
 {
     _character          = this.GetComponent <Character>();
     _characterInventory = this.GetComponent <CharacterInventory>();
 }
Exemplo n.º 24
0
 public virtual void Pickup(CharacterInventory inventory)
 {
 }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Character"/> class.
        /// </summary>
        /// <param name="world">World that the character belongs to.</param>
        /// <param name="isPersistent">If the Character's state is persistent. If true, Load() MUST be called
        /// at some point during the Character's constructor!</param>
        protected Character(World world, bool isPersistent) : base(Vector2.Zero, Vector2.One)
        {
            IsAlive = false;
            _skillCaster = new CharacterSkillCaster(this);

            _world = world;
            _isPersistent = isPersistent;

            if (IsPersistent)
                _statusEffects = new PersistentCharacterStatusEffects(this);
            else
                _statusEffects = new NonPersistentCharacterStatusEffects(this);

            _statusEffects.Added -= StatusEffects_HandleOnAdd;
            _statusEffects.Added += StatusEffects_HandleOnAdd;
            _statusEffects.Removed -= StatusEffects_HandleOnRemove;
            _statusEffects.Removed += StatusEffects_HandleOnRemove;

            _baseStats = CreateStats(StatCollectionType.Base);
            _modStats = CreateStats(StatCollectionType.Modified);
            _spSync = CreateSPSynchronizer();
            _inventory = CreateInventory();
            _equipped = CreateEquipped();

            // Set up the listeners for when the stat collections change
            BaseStats.StatChanged -= BaseStatChangedHandler;
            BaseStats.StatChanged += BaseStatChangedHandler;
            ModStats.StatChanged -= ModStatChangedHandler;
            ModStats.StatChanged += ModStatChangedHandler;

            // Set up the listeners for when the equipped items change
            _equipped.Equipped -= EquippedHandler;
            _equipped.Equipped += EquippedHandler;
            _equipped.Unequipped -= UnequippedHandler;
            _equipped.Unequipped += UnequippedHandler;
        }
Exemplo n.º 26
0
        public async Task StartCommand(CommandContext ctx)
        {
            //Vérification de base
            if (dep.Entities.Characters.IsPresent(ctx.User.Id))
            {
                await ctx.RespondAsync(dep.Dialog.GetString("errorAlreadyRegistered"));

                return;
            }
            if (!dep.Entities.Guilds.IsPresent(ctx.Guild.Id))
            {
                return;
            }

            InteractivityModule interactivity = ctx.Client.GetInteractivityModule();

            //Créer Direct Channel (MP)
            DiscordDmChannel channel = await ctx.Member.CreateDmChannelAsync();

            //Création du Character
            Character c = new Character
            {
                Id = ctx.User.Id
            };

            //1 On récupère le truename puis on enregistre directement pour éviter les doublons
            DiscordEmbedBuilder embedTrueName = dep.Embed.CreateBasicEmbed(ctx.User, dep.Dialog.GetString("startIntroAskTruename"),
                                                                           dep.Dialog.GetString("startIntroInfoTruename"));
            await channel.SendMessageAsync(embed : embedTrueName);

            bool trueNameIsValid = false;

            do
            {
                MessageContext msgTrueName = await interactivity.WaitForMessageAsync(
                    xm => xm.Author.Id == ctx.User.Id && xm.ChannelId == channel.Id, TimeSpan.FromMinutes(1));

                if (msgTrueName != null)
                {
                    if (msgTrueName.Message.Content.Length <= 50 &&
                        !dep.Entities.Characters.IsTrueNameTaken(msgTrueName.Message.Content) &&
                        msgTrueName.Message.Content.Length > 2)
                    {
                        c.TrueName = dep.Dialog.RemoveMarkdown(msgTrueName.Message.Content);

                        dep.Entities.Characters.AddCharacter(c);
                        trueNameIsValid = true;
                    }
                    else
                    {
                        DiscordEmbedBuilder embedErrorTrueName = dep.Embed.CreateBasicEmbed(ctx.User, dep.Dialog.GetString("startIntroTrueTaken"));
                        await channel.SendMessageAsync(embed : embedErrorTrueName);
                    }
                }
            } while (!trueNameIsValid);

            //2 On demande le nom
            DiscordEmbedBuilder embedName = dep.Embed.CreateBasicEmbed(ctx.User, dep.Dialog.GetString("startIntroAskName"),
                                                                       dep.Dialog.GetString("startIntroInfoName"));
            await channel.SendMessageAsync(embed : embedName);

            MessageContext msgName = await interactivity.WaitForMessageAsync(
                xm => xm.Author.Id == ctx.User.Id && xm.ChannelId == channel.Id, TimeSpan.FromMinutes(1));

            if (msgName != null)
            {
                c.Name = dep.Dialog.RemoveMarkdown(msgName.Message.Content);
            }

            //3 Puis finalement le sexe
            DiscordEmbedBuilder embedSex = dep.Embed.CreateBasicEmbed(ctx.User, dep.Dialog.GetString("startIntroAskGender"),
                                                                      dep.Dialog.GetString("startIntroInfoGender"));
            await channel.SendMessageAsync(embed : embedSex);

            MessageContext msgSex = await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id &&
                                                                            (xm.Content.ToLower() == "male" ||
                                                                             xm.Content.ToLower() == "female" &&
                                                                             xm.ChannelId == channel.Id),
                                                                            TimeSpan.FromMinutes(1));

            if (msgSex != null)
            {
                if (msgSex.Message.Content.ToLower() == "male")
                {
                    c.Sex = Sex.Male;
                }
                else
                {
                    c.Sex = Sex.Female;
                }
            }
            else
            {
                c.Sex = Sex.Male;
            }

            //Si le nom a bien été rentré, on créer le personnage
            if (c.Name != null)
            {
                DiscordEmbedBuilder embedFinal = dep.Embed.CreateBasicEmbed(ctx.User, dep.Dialog.GetString("startIntroConclude", c));
                await channel.SendMessageAsync(embed : embedFinal);

                c.Level     = 1;
                c.Energy    = 100;
                c.MaxEnergy = 100;
                c.Location  = dep.Entities.Guilds.GetGuildById(ctx.Guild.Id).SpawnLocation;
                c.Stats     = new CharacterStats
                {
                    Endurance    = 1,
                    Strength     = 1,
                    Intelligence = 1,
                    Agility      = 1,
                    Dexterity    = 1,
                    Health       = 100,
                    MaxHealth    = 100,
                    UpgradePoint = 0
                };


                //INVENTAIRE
                CharacterInventory inv = new CharacterInventory
                {
                    Id = c.Id
                };
                inv.AddMoney(500);
                inv.AddItem(new Wood(10));
                inv.AddItem(new Weapon()
                {
                    Name         = "Awesome sword",
                    Quantity     = 1,
                    AttackDamage = 10,
                    CraftsmanId  = 100,
                    Hand         = 2
                });

                c.Skills.Add(new LoggerSkill());


                dep.Entities.Inventories.AddInventory(inv);

                c.OriginRegionName = dep.Entities.Map.GetRegionByLocation(dep.Entities.Guilds.GetGuildById(ctx.Guild.Id).SpawnLocation).Name;
                c.Profession       = Profession.Peasant;

                dep.Entities.Map.GetCase(c.Location).AddNewCharacter(c);
                dep.Entities.Characters.EditCharacter(c);
            }
            //Sinon on supprime celui qui avait commencé à être créer
            else
            {
                dep.Entities.Characters.DeleteCharacter(c.Id);
            }
        }
Exemplo n.º 27
0
    public void PopulateCharacterInventory(ref CharacterInventory characterInventory)
    {
        GameObject RightHand = transform.GetChild(0).gameObject;
        GameObject LeftHand  = transform.GetChild(1).gameObject;
        GameObject Equipment = transform.GetChild(2).gameObject;
        GameObject Inventory = transform.GetChild(3).gameObject;

        Debug.Assert(RightHand != null);
        Debug.Assert(LeftHand != null);
        Debug.Assert(Equipment != null);
        Debug.Assert(Inventory != null);

        GameObject Head  = Equipment.transform.GetChild(0).gameObject;
        GameObject Chest = Equipment.transform.GetChild(1).gameObject;
        GameObject Hands = Equipment.transform.GetChild(2).gameObject;
        GameObject Feet  = Equipment.transform.GetChild(3).gameObject;

        Debug.Assert(Head != null);
        Debug.Assert(Chest != null);
        Debug.Assert(Hands != null);
        Debug.Assert(Feet != null);

        // Zero out the characterInventory.
        for (int i = 0; i < characterInventory.leftHand.Length - 1; ++i)
        {
            characterInventory.leftHand[i]  = null;
            characterInventory.rightHand[i] = null;
            if (LeftHand.transform.GetChild(i).childCount != 0)
            {
                characterInventory.leftHand[i] = LeftHand.transform.GetChild(i).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
            }
            if (RightHand.transform.GetChild(i).childCount != 0)
            {
                characterInventory.rightHand[i] = RightHand.transform.GetChild(i).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
            }
        }
        for (int i = 0; i < characterInventory.inventory.Count; ++i)
        {
            characterInventory.inventory[i] = null;
            if (Inventory.transform.GetChild(i).childCount != 0)
            {
                characterInventory.inventory[i] = Inventory.transform.GetChild(i).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
            }
        }

        characterInventory.head  = null;
        characterInventory.chest = null;
        characterInventory.hands = null;
        characterInventory.feet  = null;

        if (Head.transform.GetChild(0).childCount != 0)
        {
            characterInventory.head = Head.transform.GetChild(0).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
        }
        if (Chest.transform.GetChild(0).childCount != 0)
        {
            characterInventory.chest = Chest.transform.GetChild(0).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
        }
        if (Hands.transform.GetChild(0).childCount != 0)
        {
            characterInventory.hands = Hands.transform.GetChild(0).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
        }
        if (Feet.transform.GetChild(0).childCount != 0)
        {
            characterInventory.feet = Feet.transform.GetChild(0).GetChild(0).gameObject.GetComponent <SlotObjectContainer> ().obj;
        }
    }
Exemplo n.º 28
0
 private void Start()
 {
     _inventory          = GameObject.FindGameObjectWithTag("InventoryGO").GetComponent <Inventory>();
     _characterInventory = GameObject.FindGameObjectWithTag("CharacterInfo").GetComponent <CharacterInventory>();
     _slotsPanel         = GameObject.FindGameObjectWithTag("SlotsPanel").GetComponent <Transform>();
 }
Exemplo n.º 29
0
    public bool UnEquipArmor(ItemPickUp armorPickUp, CharacterInventory charInventory)
    {
        bool previousArmorSame = false;

        switch (armorPickUp.itemDefinition.itemArmorSubType)
        {
        case ItemArmorSubType.Head:
            if (headArmor != null)
            {
                if (headArmor == armorPickUp)
                {
                    previousArmorSame = true;
                }
                //charInventory.inventoryDisplaySlots[3].sprite = null;
                currentResistance -= armorPickUp.itemDefinition.itemAmount;
                headArmor          = null;
            }
            break;

        case ItemArmorSubType.Chest:
            if (chestArmor != null)
            {
                if (chestArmor == armorPickUp)
                {
                    previousArmorSame = true;
                }
                //charInventory.inventoryDisplaySlots[4].sprite = null;
                currentResistance -= armorPickUp.itemDefinition.itemAmount;
                chestArmor         = null;
            }
            break;

        case ItemArmorSubType.Hands:
            if (handArmor != null)
            {
                if (handArmor == armorPickUp)
                {
                    previousArmorSame = true;
                }
                //charInventory.inventoryDisplaySlots[5].sprite = null;
                currentResistance -= armorPickUp.itemDefinition.itemAmount;
                handArmor          = null;
            }
            break;

        case ItemArmorSubType.Legs:
            if (legArmor != null)
            {
                if (legArmor == armorPickUp)
                {
                    previousArmorSame = true;
                }
                //charInventory.inventoryDisplaySlots[6].sprite = null;
                currentResistance -= armorPickUp.itemDefinition.itemAmount;
                legArmor           = null;
            }
            break;

        case ItemArmorSubType.Boots:
            if (footArmor != null)
            {
                if (footArmor == armorPickUp)
                {
                    previousArmorSame = true;
                }
                //charInventory.inventoryDisplaySlots[7].sprite = null;
                currentResistance -= armorPickUp.itemDefinition.itemAmount;
                footArmor          = null;
            }
            break;
        }

        return(previousArmorSame);
    }
Exemplo n.º 30
0
        protected IEnumerator MakeTradeoverTime()
        {
            Debug.Log("Starting to make trade");
            var loadStart = GUILoading.LoadStart(GUILoading.Mode.SmallInGame);

            while (loadStart.MoveNext())
            {
                yield return(null);
            }
            GUILoading.ActivityInfo = "Making Trade... " + CharacterGoods.Count.ToString() + " character goods going to player";
            //give stuff to player...
            foreach (BarterGoods good in CharacterGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    if (goodPair.Key.HasTopItem)
                    {
                        Debug.Log("Adding " + goodPair.Key.TopItem.FileName + " to player inventory...");
                    }
                    var addItem = PlayerInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (addItem.MoveNext())
                    {
                        yield return(null);
                    }
                }
                yield return(null);
            }
            //wait a tick...
            yield return(null);

            //give stuff to character...
            foreach (BarterGoods good in PlayerGoods)
            {
                foreach (KeyValuePair <WIStack, int> goodPair in good)
                {
                    var enumerator = CharacterInventory.AddItems(goodPair.Key, goodPair.Value);
                    while (enumerator.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            //TODO determine what counts as a 'successful use'
            BarterManager.Use(true);

            PlayerBank.Absorb(CharacterGoodsBank);
            CharacterBank.Absorb(PlayerGoodsBank);

            ClearGoodsAndCurrency();
            MadeTradeThisSession = true;
            Player.Get.AvatarActions.ReceiveAction(AvatarAction.BarterMakeTrade, WorldClock.AdjustedRealTime);
            var loadFinish = GUILoading.LoadFinish();

            while (loadFinish.MoveNext())
            {
                yield return(null);
            }
            Debug.Log("Finished making trade");
            mMakingTrade = false;
            yield break;
        }
Exemplo n.º 31
0
    // ====================================================================================================================
    #region pub
    public Character(string className, int level, int move,int range, int hp, int mp, CharacterInventory invent, int patk, int pdef, int matk, int mdef)
    {
        _characterClass = new CharacterClass(className, level);
        this._moves = move;
        this._maxHealth = hp;
        this._maxMagic = mp;
        this.attackRange = range;

        this._currHealth = hp;
        this._currMagic = mp;
        this._isAlive = _currHealth > 0;

        this._characterInventory = invent;

        this._physAttack = patk;
        this._physDefense = pdef;
        this._magicAttack = matk;
        this._magicDefense = mdef;

        this._currPhysAttack = patk;
        this._currPhysDefense = pdef;
        this._currMagicAttack = matk;
        this._currMagicDefense = mdef;
    }
Exemplo n.º 32
0
 private void Start()
 {
     Instance = this;
 }
Exemplo n.º 33
0
 public Character(string name)
 {
     characterData = new CharacterData(name, GetRandomStats());
     inventory = CharacterInventory.Load(name);
 }
Exemplo n.º 34
0
        private void LoadQuickSlotsFromJSON(CharacterQuickSlotManager self)
        {
            CharacterInventory      charInvent = self.gameObject.GetComponent <CharacterInventory>();
            CharacterSkillKnowledge charSkills = charInvent.SkillKnowledge;
            ItemManager             itemMan    = ItemManager.Instance;


            //Load Quickslots for Bar 1
            for (int i = 0; i < slotAmount; i++)
            {
                if (dev)
                {
                    Debug.Log("LOADING QUICK SLOT " + i + " FOR BAR 1");
                }

                var itemID = qsm.currentCharacter["DefaultBarIDS"][i];
                if (itemID != 0)
                {
                    if (dev)
                    {
                        Debug.Log("ID of slot " + i + " from JSON is : " + itemID);
                    }
                    var item = charSkills.GetItemFromItemID(itemID.AsInt);

                    //this isnt a skill
                    if (item == null)
                    {
                        item = charInvent.GetOwnedItems(itemID).First();
                    }

                    defaultSlotItems[i] = item;
                }
                else
                {
                    if (dev)
                    {
                        Debug.Log("QUICK SLOT " + i + " Has No ID");
                    }
                }
            }


            for (int i = 0; i < slotAmount; i++)
            {
                if (dev)
                {
                    Debug.Log("LOADING QUICK SLOT " + i + " FOR BAR 2");
                }
                var itemID = qsm.currentCharacter["SecondaryBarIDS"][i];
                if (itemID != 0)
                {
                    if (dev)
                    {
                        Debug.Log("ID of slot " + i + " from JSON is : " + itemID);
                    }
                    var item = charSkills.GetItemFromItemID(itemID.AsInt);

                    //this isnt a skill
                    if (item == null)
                    {
                        item = charInvent.GetOwnedItems(itemID).First();
                    }

                    secondarySlotItems[i] = item;
                }
                else
                {
                    if (dev)
                    {
                        Debug.Log("QUICK SLOT " + i + " Has No ID");
                    }
                }
            }
        }
 private void UpdateCharacter()
 {
     Inventory = ControlScript.ActiveCharacters[0].GetComponent <CharacterInventory>();
     Inventory.OnItemChangeCallback += UpdateInventory;
     UpdateInventory();
 }
Exemplo n.º 36
0
    void Start()
    {
        //setup Controllstates
        _KnightIDLE = new KnightIDLE();
        _KnightIDLEONFIRE = new KnightIDLEONFIRE();
        _KnightRUN = new KnightRUN();
        _KnightSLIDE = new KnightSLIDE();
        _KnightJUMP = new KnightJUMP();
        _KnightFALL = new KnightFALL();
        _KnightWAIT = new KnightWAIT();
        _KnightDIE = new KnightDIE();
        _KnightATTACK = new KnightATTACK();
        _KnightATTACKB = new KnightATTACKB();
        _KnightATTACKC = new KnightATTACKC();
        _KnightSIT = new KnightSIT();
        _KnightSTANDUP = new KnightSTANDUP();
        _KnightGETHIT = new KnightGETHIT();

        state = _KnightSIT;
        KnightInventory = gameObject.GetComponent<CharacterInventory>();
        KnightStats = stats;
        Initialize();
        stats.healthMax = 5;
        stats.healthCurrent = 5;
        stats.enduranceMax = 100;
        stats.enduranceCurrent = 50;
    }
Exemplo n.º 37
0
 public void ArmorThatIsUnequippedStaysInInventory()
 {
     var inventory = new CharacterInventory { EquippedArmor = _testArmor };
     inventory.EquippedArmor = null;
     inventory.Should().Contain(_testArmor);
 }
Exemplo n.º 38
0
 private void CharacterInventory_TakeItem_1(On.CharacterInventory.orig_TakeItem_1 orig, CharacterInventory self, string _itemUID, bool _tryToEquip)
 {
     OLogger.Log($"TakeItem_1");
     orig(self, _itemUID, _tryToEquip);
 }
Exemplo n.º 39
0
 public void InventoryCanReportTotalWeight()
 {
     var testSubject = new CharacterInventory { new Item("Sandwich", 1), new Item("Shotgun", 5) };
     testSubject.GetWeightForSet("All").Should().Be(6m);
 }
Exemplo n.º 40
0
 private void CharacterInventory_TakeItem(On.CharacterInventory.orig_TakeItem orig, CharacterInventory self, string _itemUID)
 {
     OLogger.Log($"TakeItem");
     orig(self, _itemUID);
 }
Exemplo n.º 41
0
	public void LoadNPCInventory(CharacterInventory inventory)
	{
		Item item1 = LoadItem("huntingshotgun");
		Item item3 = LoadItem("lightarmor");

		Item item2 = LoadItem("44magnum");

		Item item8 = LoadItem("ammo12shot");


		inventory.Backpack.Add(new GridItemData(item8, 5, 5, GridItemOrient.Landscape, 30));
		inventory.SideArmSlot = item2;
		inventory.RifleSlot = item1;
		inventory.ArmorSlot = item3;
	}
Exemplo n.º 42
0
        private void CharacterInventory_TakeItem_3(On.CharacterInventory.orig_TakeItem_3 orig, CharacterInventory self, Item takenItem, bool _tryToEquip)
        {
            //OLogger.Log($"forbiden:{(takenItem.ParentContainer.IsManagedByLocalPlayer)}");
            orig(self, takenItem, _tryToEquip);
            try
            {
                // Gatherable, ItemContainerStatic (only not player), MerchantPouch, ItemContainer
                if (takenItem.ParentContainer is MerchantPouch ||
                    (takenItem.ParentContainer is ItemContainerStatic /*&& (takenItem.ParentContainer as ItemContainerStatic).IsChildToPlayer*/) ||
                    (takenItem.OwnerCharacter != null && !takenItem.OwnerCharacter.IsDead))
                {
                    //OLogger.Log($"forbiden");
                    return; // Only loot from dead enemies or when crafting
                }
                //OLogger.Log($"ParentContainer={takenItem.ParentContainer.GetType()}");
                if ((!takenItem.IsFood && !takenItem.IsIngredient) ||
                    takenItem.IsDrink ||
                    takenItem.IsEquippable || takenItem.IsDeployable)
                //(takenItem.IsFood || takenItem.IsIngredient) && !takenItem.IsDrink && !takenItem.IsEquippable && !takenItem.IsDeployable
                {
                    return;
                }

                //string iName = takenItem.name.Substring(0, takenItem.name.LastIndexOf('_'));
                string iName = takenItem.name.Split(new char[] { '_' })[0];
                //OLogger.Log($"TakeItem={iName}");

                if (!m_recipes.ContainsKey(iName))
                {
                    return;
                }

                // Only ingredients not so common (like salt)
                // Alternative : add skills to unlock some recipes

                // Only items that have no RecipeItem ?
                Dictionary <string, Recipe> allRecipes = (Dictionary <string, Recipe>)AccessTools.Field(typeof(RecipeManager), "m_recipes").GetValue(RecipeManager.Instance);
                List <Recipe> lstRecipes = allRecipes.Where(r =>
                                                            m_recipes[iName].Contains(r.Value.name) && !self.RecipeKnowledge.IsRecipeLearned(r.Key) // Ignore recipes already learned
                                                            ).Select(r => r.Value).ToList();
                foreach (var recipe in lstRecipes)
                {
                    // Calculate chance of learning recipes based on item's value
                    int itemValue = recipe.Results[0].Item.Value;
                    //int recipeValue =
                    double chance = 100f;

                    /*switch (recipe.CraftingStationType)
                     * {
                     *  case Recipe.CraftingType.Alchemy: // Value between 0 and 60
                     *      chance = m_data.PercentMax - ((float)(m_data.PercentMax - m_data.PercentMin) / m_data.AlchemyValueMax) * itemValue;
                     *      break;
                     *  case Recipe.CraftingType.Cooking: // Value between 0 and 30
                     *      chance = m_data.PercentMax - ((float)(m_data.PercentMax - m_data.PercentMin) / m_data.CookingValueMax) * itemValue;
                     *      break;
                     *  case Recipe.CraftingType.Survival:  // Value between 0 and 100
                     *      chance = m_data.PercentMax - ((float)(m_data.PercentMax - m_data.PercentMin) / m_data.SurvivalValueMax) * itemValue;
                     *      break;
                     * }*/
                    //OLogger.Log($"{recipe.Name} ({Math.Round(chance, 0)} %)");
                    int r = UnityEngine.Random.Range(0, 100);
                    if (r < chance)
                    {
                        //OLogger.Log($"{recipe.Name} ({r} < {Math.Round(chance, 2)} %)");
                        self.RecipeKnowledge.LearnRecipe(recipe);
                        break; // only one recipe to add
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Log($"[{m_modName}] CharacterInventory_TakeItem_3: {ex.Message}");
            }
        }
Exemplo n.º 43
0
    /// <summary>
    /// Instancie le joueur, ses personnages, son inventaire, etc
    /// </summary>
    private void GetPlayerInfo()
    {
        CharacterInventory characterInvent = new CharacterInventory();
        PlayerInventory playerInvent = null;
        List<Potion> list = new List<Potion>();
        Potion uItem;
        EquipableItem eItem;

        GameManager._instance._enemySide = 2;
        PlayerManager._instance._playerSide = 1;
        //infos venant du serveur

        /*
         *  CES LIGNES SERVENT AUX TESTS, LES VALEURS SONT BIDONS, ET PROVIENDRONT DE LA BD LORSQUE PRÊT
         * */

        //on génère l'inventaire du joueur, peut être mis dans la DLL commune au serveur, pour recevoir l'inventaire complet plutôt
        //que de le génèrer du côté client
        //uItem = new Potion(1, "", "Potion de soins", "Guérit de 20 points de vie", 0, 10, 0, 0, 0, 0, 20);
        //list.Add(uItem);
        //uItem = new Potion(2, "", "Potion d'attaque", "Augmente les capacités physiques", 3, 5, 10, 0, 0, 0, 0);
        //list.Add(uItem);

        //on crée l'inventaire de chaque personnage, encore içi, peut être mis dans la DLL commune au serveur, pour reçevoir les infos
        //directement
        playerInvent = new PlayerInventory(list);
        //eItem = new EquipableItem(1, "Guerrier", "Épée de fer", "Une simple épée en fer", "WATK", 10, "Weapon", 1);
        //characterInvent._invent.Add(eItem);

        //tout les personnages du joueur, pour le menu prinçipal
        PlayerManager._instance._characters.Add(Character.CreateCharacter("Bartoc", "Guerrier", 2, 3, 2, 100, 10, characterInvent, 20, 10, 0, 10));
        PlayerManager._instance._characters.Add(Character.CreateCharacter("Kodak", "Mage", 1, 2, 1, 50, 50, characterInvent, 10, 10, 10, 10));
        PlayerManager._instance._characters.Add(Character.CreateCharacter("Bubulle", "Archer", 1, 4, 10, 100, 10, characterInvent, 10, 10, 10, 10));
        PlayerManager._instance._characters.Add(Character.CreateCharacter("Mr Poire", "Prêtre", 1, 2, 1, 60, 40, characterInvent, 10, 10, 10, 10));

        //quand on choisit un personnage qui participera à la partie
        PlayerManager._instance._chosenTeam[0] = Character.CreateCharacter("Bartoc", "Guerrier", 2, 20, 1, 100, 10, characterInvent, 20, 10, 0, 10);
        PlayerManager._instance._chosenTeam[1] = Character.CreateCharacter("Kodak", "Mage", 1, 15, 1, 50, 50, characterInvent, 10, 10, 10, 10);
        PlayerManager._instance._chosenTeam[2] = Character.CreateCharacter("Bubulle", "Archer", 1, 15, 3, 100, 10, characterInvent, 10, 10, 10, 10);
        PlayerManager._instance._chosenTeam[3] = Character.CreateCharacter("Mr Poire", "Prêtre", 1, 15, 1, 60, 40, characterInvent, 10, 10, 10, 10);


        PlayerManager._instance._playerInventory = playerInvent;
    }
Exemplo n.º 44
0
 protected Player()
 {
     PlayerEquipInventory = InitializeCharacterInventory();
     PlayerItemInventory  = InitializePlayerInventory();
 }
Exemplo n.º 45
0
 void Start()
 {
     page = 0;
     inventory = this.GetComponent<CharacterInventory> ();
     crafterManager = (ItemCrafterManager)GameObject.FindObjectOfType (typeof(ItemCrafterManager));
     StyleManager Styles = (StyleManager)GameObject.FindObjectOfType (typeof(StyleManager));
     if(!Skin && Styles)
         Skin = Styles.GetSkin(0);
 }
Exemplo n.º 46
0
 public CharacterInventory(CharacterInventory templateArg)
 {
     Setup(templateArg);
 }