Пример #1
0
    public ActionAttack(AuroraObject obj, AuroraObject target, bool bPassive) : base(obj)
    {
        this.self    = obj;
        this.target  = target;
        this.passive = bPassive;

        location   = AttackPosition(target);
        moveAction = new ActionMoveToLocation(obj, location, true);

        weapon = ((Creature)obj).GetMainWeapon();

        if (weapon == null)
        {
            weaponType = Item.WeaponType.MELEE;
        }
        else
        {
            weaponType = weapon.GetWeaponType();
        }

        if (weaponType == Item.WeaponType.MELEE)
        {
            // For melee weapons, we run up to the front of the target
        }
        else
        {
            // For ranged weapons, we run within a certain distance of the target
            // TODO: Use actual weapon range stats from baseitems.2da
            attackRange = 15f;
        }

        obj.attemptedAttackTarget = target;
    }
    public void UpdateInventory()
    {
        inventoryTitle.text = string.Format("Inventory {0}/{1}", playerScript.inventory.Count, playerScript.inventorySize);

        foreach (Transform child in inventoryPanel.transform)
        {
            Destroy(child.gameObject);
        }

        //Update Inventory
        if (playerScript.inventory.Count > 0)
        {
            int invIndex = 0;
            foreach (GameObject itemObject in playerScript.inventory)
            {
                Item               item = itemObject.GetComponent <Item>();
                GameObject         IP   = Instantiate(listItemPrefab);
                ListItemController IC   = IP.GetComponent <ListItemController>();
                IC.icon.sprite = item.icon;
                IC.name.text   = item.name;
                IC.invIndex    = invIndex;
                if (item.itemClass == Item.ItemClass.Armour)
                {
                    Item.ArmourType enumType = (Item.ArmourType)item.itemType;
                    string          itemType = enumType.ToString();
                    IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n",
                                                        item.minDamage, item.maxDamage, item.defence, item.modifier, itemType);
                }
                else if (item.itemClass == Item.ItemClass.Weapon)
                {
                    Item.WeaponType enumType = (Item.WeaponType)item.itemType;
                    string          itemType = enumType.ToString();
                    IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n",
                                                        item.minDamage, item.maxDamage, item.defence, item.modifier, itemType);
                }
                else
                {
                    Item.Consumeable enumType = (Item.Consumeable)item.itemType;
                    string           itemType = enumType.ToString();
                    IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n",
                                                        item.minDamage, item.maxDamage, item.defence, item.modifier, itemType);
                }
                IP.transform.SetParent(inventoryPanel.transform);
                IP.transform.localScale = Vector3.one;
                invIndex++;
            }
        }
    }