Exemplo n.º 1
0
 public Character()
 {
     Equipment = new CharacterEquipment
     {
         Character = this
     };
     CurrentHealth = MaxHealth;
     CurrentMana   = MaxMana;
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     skills = GameObject.FindGameObjectWithTag("Controller").GetComponent<SkillList>();
     magic = GameObject.FindGameObjectWithTag("Controller").GetComponent<MagicList>();
     Items = GameObject.FindGameObjectWithTag("Controller").GetComponent<AllItemsList>();
     Equipment = GetComponent<CharacterEquipment>();
     skillsKnown = new Dictionary<string, int>();
     magicKnown = new Dictionary<string, int>();
     skillsKnown.Add("Attack", 100);
     skillsKnown.Add("Block", 100);
 }
Exemplo n.º 3
0
    //used to initialise a skill
    //required info: name of skill, target of skill, character skill originating from, and name of weapon (replace with equipment list later)
    public void PerformSkill(string name, Vector3 targt, GameObject orgn, int cost)
    {
        skillName = name;
        target = targt;
        origin = orgn;
        skillCost = cost;

        Equipment = origin.GetComponent<CharacterEquipment>();
        string[] allEquipment = Equipment.GetAllEquipment();

        if(Items.GetItemType(allEquipment[0]) == "Weapon"){
            weaponType = Items.GetWpnType(allEquipment[0]);
            baseDamage = Items.GetWpnDamage(allEquipment[0]);
        }

        StartCoroutine(skillName);
    }
Exemplo n.º 4
0
    public void OnEquip(CharacterEquipment.Equipment.EquipMessage message)
    {
        GameObject wep = SavedWeapon.LoadFromString (message.metadata).Build ();
        wep.transform.position = transform.position;
        wep.transform.rotation = transform.rotation;
        wep.transform.parent = transform;

        Weapon w = wep.GetComponent<Weapon> ();
        if (message.character) {
            w.character = message.character;
            CharacterEquipment.Equipment slot = message.character.FindSlotByType (CharacterEquipment.Slot.Ammo);
            if (slot != null)
                w.characterAmmoSlot = slot.item;

            if (message.slot != null)
                message.slot.equippedItem = gameObject;

            message.character.activeWeapon = w;
            w.Reload ();
        }

        w.UpdateAmmunition ();
    }
Exemplo n.º 5
0
 public void UnEquip(CharacterEquipment.Equipment.EquipMessage message)
 {
     message.character.armorPieces.Remove (this);
 }
Exemplo n.º 6
0
 public void OnEquip(CharacterEquipment.Equipment.EquipMessage message)
 {
     message.character.armorPieces.Add (this);
 }
Exemplo n.º 7
0
 //DESIGN: Equipment GUI
 void SelectCharacter(GameObject character)
 {
     Character = character;
     Equipment = Character.GetComponent<CharacterEquipment>();
 }
Exemplo n.º 8
0
 public void OnUnEquip( CharacterEquipment.Equipment.EquipMessage message )
 {
     message.character.activeWeapon = null;
 }
Exemplo n.º 9
0
    //ADD: Magic
    void Awake()
    {
        //initialize all component variables
        Stats = GetComponent<AttributesScript>();
        KnownAbilities = GetComponent<CharacterKnownAbilities>();
        Status = GetComponent<CharacterStatus>();
        Equipment = GetComponent<CharacterEquipment>();

        Move = GameObject.FindGameObjectWithTag("Controller").GetComponent<MovementScript>();
        pathFind = GameObject.FindGameObjectWithTag("Controller").GetComponent<PathfindingScript>();
        findValid = GameObject.FindGameObjectWithTag("Controller").GetComponent<FindValidPoints>();
        Draw = GameObject.FindGameObjectWithTag("Controller").GetComponent<DrawSquaresScript>();
        Controller = GameObject.FindGameObjectWithTag("Controller").GetComponent<TurnController>();
        Magic = GameObject.FindGameObjectWithTag("Controller").GetComponent<MagicList>();
        Skills = GameObject.FindGameObjectWithTag("Controller").GetComponent<SkillList>();

        Items = GameObject.FindGameObjectWithTag("ItemManager").GetComponent<AllItemsList>();
        if(GetComponent<MouseControlScript>()){
            Mouse = GetComponent<MouseControlScript>();
            isPlayer = true;
        }

        skillSelected = "";
    }
Exemplo n.º 10
0
 void UpdateItem(CharacterEquipment.Equipment slot)
 {
     slot.Update ();
 }
Exemplo n.º 11
0
 public void OnEquip(CharacterEquipment.Equipment slot, GameObject equipment)
 {
     UpdatePose ();
 }
Exemplo n.º 12
0
    public CharacterEquipment.Equipment FindSlotByType(CharacterEquipment.Slot slotType)
    {
        foreach (CharacterEquipment.Equipment e in equipment.slots) {
            if (e.slot == slotType)
                return e;
        }

        return null;
    }
Exemplo n.º 13
0
    public void ChangeEquipment(CharacterEquipment.Slot slotType, CharacterEquipment.Equipment slot, Inventory.Slot fromSlot)
    {
        if (fromSlot.item && slotType != fromSlot.item.prefab.slotType)
            return;

        // Handle removing incompatable ammo if new weapon type is placed.
        if (fromSlot.item && slotType == CharacterEquipment.Slot.Hand) {
            CharacterEquipment.Equipment ammoSlot = FindSlotByType (CharacterEquipment.Slot.Ammo);

            if (ammoSlot.item.item) {
                AmmoPrefab.AmmoType ammoType = ammoSlot.item.item.attributes.GetAttribute<AmmoPrefab.AmmoType> ("AmmoType");
                SavedWeapon saved = SavedWeapon.LoadFromString (fromSlot.item.metadata);
                AmmoPrefab.AmmoType weaponType = WeaponGenerator.cur.weaponClasses[saved.classID].bodies[saved.bodyID].GetComponent<WeaponBody> ().ammoType;

                if (weaponType != ammoType) {
                    inventory.PlaceItems (ammoSlot.item);
                }

                // Just to avoid memory being used up or something. Feels right to do this.
                Destroy (saved);
            }
        }

        // Handle specifics when swapping ammunition.
        if (fromSlot.item && slotType == CharacterEquipment.Slot.Ammo) {
            AmmoPrefab.AmmoType ammoType = fromSlot.item.attributes.GetAttribute<AmmoPrefab.AmmoType> ("AmmoType");

            if (activeWeapon) {
                if (activeWeapon.body.ammoType == ammoType) {
                    int space = Mathf.Min (activeWeapon.body.magazine.maxAmmo - slot.item.count, fromSlot.count);

                    if (space > 0) {
                        fromSlot.MoveItem (slot.item, space, false);
                    }
                }
                UpdateAmmunition ();
            }

            slot.item.ForceButtonUpdate ();
            UpdateItem (slot);

            SendMessage ("OnEquipmentChanged", SendMessageOptions.DontRequireReceiver);
            return;
        }

        slot.item.ForceButtonUpdate ();
        fromSlot.MoveItem (slot.item);
        UpdateItem (slot);

        SendMessage ("OnEquipmentChanged", SendMessageOptions.DontRequireReceiver);
    }