Пример #1
0
 public void SetType(Weapon.WeaponType eType)
 {
     //Set the type
     _type = eType;
     Weapon.WeaponDefinition def = Main.GetWeaponDefinition (_type);
     renderer.material.color = def.projectileColor;
 }
Пример #2
0
 public WeaponCereal(Weapon w)
 {
     myType = w.GetMyType();
     name   = w.name;
     range  = w.range;
     damage = w.damage;
 }
Пример #3
0
        // =================== STAT HELPERS, ETC ====================== //

        public Weapon.WeaponType GetSwappedType(Weapon.WeaponType type)
        {
            switch (type)
            {
            case Weapon.WeaponType.Sword_1H:
                type = Weapon.WeaponType.Sword_2H;
                break;

            case Weapon.WeaponType.Sword_2H:
                type = Weapon.WeaponType.Sword_1H;
                break;

            case Weapon.WeaponType.Axe_1H:
                type = Weapon.WeaponType.Axe_2H;
                break;

            case Weapon.WeaponType.Axe_2H:
                type = Weapon.WeaponType.Axe_1H;
                break;

            case Weapon.WeaponType.Mace_1H:
                type = Weapon.WeaponType.Mace_2H;
                break;

            case Weapon.WeaponType.Mace_2H:
                type = Weapon.WeaponType.Mace_1H;
                break;

            default:
                break;
            }
            return(type);
        }
    void NewWeaponEquipped(Weapon.WeaponType weaponType)
    {
        //reset weapon animations
        animator.Rebind();

        //activate/deactivate specific animator layers when new weapons get equipped
        if (weaponType == Weapon.WeaponType.Sword)
        {
            animator.SetLayerWeight(2, 1);
            animator.SetLayerWeight(3, 0);
            animator.SetLayerWeight(4, 0);
        }
        else if (weaponType == Weapon.WeaponType.Axe)
        {
            animator.SetLayerWeight(2, 0);
            animator.SetLayerWeight(3, 1);
            animator.SetLayerWeight(4, 0);
        }
        else if (weaponType == Weapon.WeaponType.Hammer)
        {
            animator.SetLayerWeight(2, 0);
            animator.SetLayerWeight(3, 0);
            animator.SetLayerWeight(4, 1);
        }
    }
Пример #5
0
 public void Convert(Weapon w)
 {
     myType = w.GetMyType();
     name   = w.name;
     range  = w.range;
     damage = w.damage;
 }
Пример #6
0
    public override Weapon Create(Weapon.WeaponType weaponType, GameObject gameObject)
    {
        Item.Rarity   rarity  = GenerateRarity();
        Item.Keywords keyword = GenerateKeyword();
        Weapon        weapon  = gameObject.GetComponent <Weapon>();

        switch (weaponType)
        {
        case Weapon.WeaponType.SWORD:
            weapon.Init(Weapon.WeaponType.SWORD, rarity, GenerateWeaponSprite(ItemSprites.swordSprites, rarity), rarity + " " + keyword + " Sword");
            return(weapon);

        case Weapon.WeaponType.MACE:
            weapon.Init(Weapon.WeaponType.MACE, rarity, GenerateWeaponSprite(ItemSprites.maceSprites, rarity), rarity + " " + keyword + " Mace");
            return(weapon);

        case Weapon.WeaponType.BOW:
            weapon.Init(Weapon.WeaponType.BOW, rarity, GenerateWeaponSprite(ItemSprites.bowSprites, rarity), rarity + " " + keyword + " Bow");
            return(weapon);

        case Weapon.WeaponType.AXE:
            weapon.Init(Weapon.WeaponType.AXE, rarity, GenerateWeaponSprite(ItemSprites.axeSprites, rarity), rarity + " " + keyword + " Axe");
            return(weapon);

        case Weapon.WeaponType.SPEAR:
            weapon.Init(Weapon.WeaponType.SPEAR, rarity, GenerateWeaponSprite(ItemSprites.spearSprites, rarity), rarity + " " + keyword + " Spear");
            return(weapon);

        default:
            Debug.Log("Weapon Type not found");
            break;
        }
        throw new System.NotImplementedException();
    }
Пример #7
0
        static bool Item_PerformEquip_Pre2(Item __instance, EquipmentSlot _slot)
        {
            Character character = _slot.Character;

            if (!_contextualSkillQuickslots || !character.IsPlayer())
            {
                return(true);
            }

            Weapon.WeaponType previousType = GetExtendedWeaponType(_slot.EquippedItem);
            Weapon.WeaponType currentType  = GetExtendedWeaponType(__instance);
            if (currentType == previousType)
            {
                return(true);
            }

            foreach (var quickslot in character.QuickSlotMngr.m_quickSlots)
            {
                if (quickslot.ActiveItem.TryAs(out Skill quickslotSkill) &&
                    _skillContextsByID.TryAssign(quickslotSkill.ItemID, out var context) &&
                    SKILL_CONTEXT_GROUPS.TryAssign(context, out var contextSkillGroup) &&
                    contextSkillGroup.TryAssign(currentType, out var newContextSkillID) &&
                    GetLearnedSkillByID(character, newContextSkillID).TryAssign(out var newContextSkill))
                {
                    quickslot.SetQuickSlot(newContextSkill, true);
                }
            }

            return(true);
        }
Пример #8
0
    public System.Type GetWeaponClassFromType(Weapon.WeaponType type)
    {
        switch (type)
        {
        case Weapon.WeaponType.Sword:
            return(typeof(Sword));

        case Weapon.WeaponType.Hammer:
            return(typeof(Sword));    // XD

        case Weapon.WeaponType.Flail:
            return(typeof(Sword));    // XD

        case Weapon.WeaponType.Bow:
            return(typeof(Sword));    // XD

        case Weapon.WeaponType.Dagger:
            return(typeof(Sword));    // XD

        case Weapon.WeaponType.Fist:
            return(typeof(Sword));    // XD

        default:
            return(typeof(Sword));    // XD
        }
    }
Пример #9
0
 public void SetType(Weapon.WeaponType wt)
 {
     Weapon.WeaponDefinition def = Main.GetWeaponDefinition(wt);
     cubeRend.material.color = def.color;
     letter.text             = def.letter;
     type = wt;
 }
	public DamageMessage (float dmg, Vector3 dir, float dmgFrce, Weapon.DamageBias bs, Weapon.WeaponType tp, Ship own)
	{
		damage = dmg;
		damageDirection = dir;
		damageForce = dmgFrce;
		bias = bs;
		type = tp;
		
		if (own != null)
			owner = own.gameObject;
		else
			return;
		
		hasShip = true;
		try
		{
			viewID = own.GetComponent<PhotonView>().viewID;
		}
		catch
		{
			Debug.Log(owner.name  + " does not have a photon View ID");
		}
		
		if (own is AiShip)
			player = false;
		else
			player = true;
	}
Пример #11
0
    public int GetAmmo(Weapon.WeaponType weaponType)
    {           // Calculates how many full clips there are..
        if (_ClipsUIText)
        {
            _ClipsUIText.text = Mathf.RoundToInt((_AR_ammo + 30) / 30f).ToString();
        }
        switch (weaponType)
        {
        case Weapon.WeaponType.AssaultRifle:
            return(_AR_ammo);

        case Weapon.WeaponType.Pistol:
            Debug.Log("Inventory.cs/GetAmmo(): TODO - Pistol Case");
            break;

        case Weapon.WeaponType.Shotgun:
            Debug.Log("Inventory.cs/GetAmmo(): TODO - Shotgun Case");
            break;

        case Weapon.WeaponType.Sniper:
            Debug.Log("Inventory.cs/SetAmmo(): TODO - Sniper Case");
            return(_AR_ammo);


        default:
            Debug.LogError("Inventory.cs/GetAmmo(): Invalid Weapon Type!");
            return(-1);
        }

        return(-1);
    }
Пример #12
0
 public WeaponCereal()
 {
     myType = 0;
     name   = "sword";
     range  = 1;
     damage = 1;
 }
Пример #13
0
 void OnPlayerDead(int hitFrom, Weapon.WeaponType weaponType)
 {
     gameData.CurrentScore = gameData.LastSavedScore;
     gameData.Lives       -= 1;
     EventKit.Broadcast <bool>("fade hud", true);
     EventKit.Broadcast <int>("load level", gameData.CurrentLevel);
 }
Пример #14
0
 static public Weapon.WeaponDefinition GetWeaponDefinition(Weapon.WeaponType wt)
 {
     if (WEAPON_DICT.ContainsKey(wt))
     {
         return(WEAPON_DICT[wt]);
     }
     return(new Weapon.WeaponDefinition());
 }
Пример #15
0
    public object Args(GameObject collidee, Collider2D collider)
    {
        hitFrom    = M.HorizSideThatWasHit(collidee, collider);
        weapon     = collider.GetComponent <Weapon>();
        weaponType = weapon.weaponType;

        return(this);
    }
Пример #16
0
	public object Args(GameObject collidee, Collider2D collider)
	{
		hitFrom = M.HorizSideThatWasHit(collidee, collider);
		weapon = collider.GetComponent<Weapon>();
		weaponType = weapon.weaponType;

		return this;
	}
Пример #17
0
    //解析Json文件
    void ParseItemJson()
    {
        itemList = new List <Item>();
        //文本为在Unity里面是 TextAsset类型
        TextAsset  itemText  = Resources.Load <TextAsset>("Items");
        string     itemsJson = itemText.text;//物品信息的Json格式
        JSONObject j         = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            string        typeStr = temp["type"].str;
            Item.ItemType type    = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeStr);

            //下面的事解析这个对象里面的公有属性
            int              id          = (int)(temp["id"].n);
            string           name        = temp["name"].str;
            Item.ItemQuality quality     = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            string           description = temp["description"].str;
            int              capacity    = (int)(temp["capacity"].n);
            int              buyPrice    = (int)(temp["buyPrice"].n);
            int              sellPrice   = (int)(temp["sellPrice"].n);
            string           sprite      = temp["sprite"].str;

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = (int)(temp["hp"].n);
                int mp = (int)(temp["mp"].n);
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                //
                int strength  = (int)temp["strength"].n;
                int intellect = (int)temp["intellect"].n;
                int agility   = (int)temp["agility"].n;
                int stamina   = (int)temp["stamina"].n;
                Equipmen.EquipmentType equipType = (Equipmen.EquipmentType)System.Enum.Parse(typeof(Equipmen.EquipmentType), temp["equipType"].str);
                item = new Equipmen(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equipType);
                break;

            case Item.ItemType.Weapon:
                //
                int damage = (int)temp["damage"].n;
                Weapon.WeaponType wpType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, wpType);
                break;

            case Item.ItemType.Material:
                //
                item = new Materials(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
            Debug.Log(item);
        }
    }
Пример #18
0
    public void ManipulateAmmo(Weapon.WeaponType weaponType, int value)
    {
        switch (weaponType)
        {
        case Weapon.WeaponType.AssaultRifle:

            _AR_ammo += value;

            // Enforce lower bound limit.
            if (_AR_ammo < 0)
            {
                _AR_ammo          = 0;
                _ClipsUIText.text = "0";                         // Ensure Clips Text displays 0.
            }

            break;

        case Weapon.WeaponType.Pistol:
            Debug.Log("Inventory.cs/ManupulateAmmo(): TODO - Pistol Case");
            break;

        case Weapon.WeaponType.Shotgun:
            Debug.Log("Inventory.cs/ManupulateAmmo(): TODO - Shotgun Case");
            break;

        case Weapon.WeaponType.Sniper:
            //Debug.Log("Inventory.cs/ManupulateAmmo(): TODO - Sniper Case");

            _AR_ammo += value;

            // Enforce lower bound limit.
            if (_AR_ammo < 0)
            {
                _AR_ammo          = 0;
                _ClipsUIText.text = "0";                         // Ensure Clips Text displays 0.
            }
            break;

        default:
            Debug.LogError("Inventory.cs/ManupulateAmmo(): Invalid Weapon Type!");
            break;
        }

        // Get reference to the Clips UI Text component.
        if (!_ClipsUIText)
        {
            if (GameObject.FindGameObjectWithTag("ClipsText"))
            {
                _ClipsUIText = GameObject.FindGameObjectWithTag("ClipsText").GetComponent <Text> ();
            }
        }

        // Calculates how many full clips there are..
        if (_ClipsUIText)
        {
            _ClipsUIText.text = Mathf.RoundToInt((_AR_ammo + 30) / 30f).ToString();
        }
    }
Пример #19
0
    void ParseItemJson()
    {
        itemList = new List <Item>();

        TextAsset itemText  = Resources.Load <TextAsset>("Items");
        string    itemsJson = itemText.text;

        JSONObject j = new JSONObject(itemsJson);

        Debug.Log(string.Format("{0} {1} {2} {3}", j.IsArray, j.isContainer, j.Count, j.list.Count));

        foreach (JSONObject temp in j.list)
        {
            string        typeStr = temp["type"].str;
            Item.ItemType type    = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeStr);

            int              id          = (int)(temp["id"].n);
            string           name        = temp["name"].str;
            Item.ItemQuality quality     = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            string           description = temp["description"].str;
            int              capacity    = (int)(temp["capacity"].n);
            int              buyPrice    = (int)(temp["buyPrice"].n);
            int              sellPrice   = (int)(temp["sellPrice"].n);
            string           sprite      = temp["sprite"].str;

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = (int)(temp["hp"].n);
                int mp = (int)(temp["mp"].n);
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                int strength  = (int)(temp["strength"].n);
                int intellect = (int)(temp["intellect"].n);
                int agility   = (int)(temp["agility"].n);
                int stamina   = (int)(temp["stamina"].n);
                Equipment.EquipmentType equipType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equipType);
                break;

            case Item.ItemType.Weapon:
                int damage = (int)(temp["damage"].n);
                Weapon.WeaponType wpType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, wpType);
                break;

            case Item.ItemType.Material:
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
            //Debug.Log(item);
        }
    }
Пример #20
0
    void ParseItemJson()
    {
        itemList = new List <Item>();
        TextAsset itemText  = Resources.Load <TextAsset>("Items");
        JsonData  itemsData = JsonMapper.ToObject(itemText.text);

        Item item = null;

        foreach (JsonData itemData in itemsData)
        {
            int              id       = (int)itemData["id"];
            string           itemName = itemData["name"].ToString();
            Item.ItemQuality quality  =
                (Item.ItemQuality)Enum.Parse(typeof(Item.ItemQuality), itemData["quality"].ToString());
            string des       = itemData["description"].ToString();
            int    capacity  = (int)itemData["capacity"];
            int    buyPrice  = (int)itemData["buyPrice"];
            int    sellPrice = (int)itemData["sellPrice"];
            string sprite    = itemData["sprite"].ToString();
            switch (itemData["type"].ToString())
            {
            case "Consumable":
                int hp = (int)itemData["hp"];
                int mp = (int)itemData["mp"];
                item = new Consumable(id, itemName, Item.ItemType.Consumable, quality, des, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case "Equipment":
                int strength  = (int)itemData["strength"];
                int intellect = (int)itemData["intellect"];
                int agility   = (int)itemData["agility"];
                int stamina   = (int)itemData["stamina"];
                Equipment.EquipmentType equipmentType =
                    (Equipment.EquipmentType)Enum.Parse(typeof(Equipment.EquipmentType),
                                                        itemData["equipmentType"].ToString());
                item = new Equipment(id, itemName, Item.ItemType.Consumable, quality, des, capacity, buyPrice,
                                     sellPrice, sprite, strength, intellect, agility, stamina, equipmentType);
                break;

            case "Weapon":
                int damage = (int)itemData["damage"];
                Weapon.WeaponType weaponType = (Weapon.WeaponType)Enum.Parse(typeof(Weapon.WeaponType),
                                                                             itemData["weaponType"].ToString());
                item = new Weapon(id, itemName, Item.ItemType.Consumable, quality, des, capacity, buyPrice,
                                  sellPrice, sprite, damage, weaponType);
                break;

            case "Material":
                item = new Material(id, itemName, Item.ItemType.Consumable, quality, des, capacity, buyPrice,
                                    sellPrice, sprite);
                break;
            }
            itemList.Add(item);
            //Debug.Log(item);
        }
    }
Пример #21
0
    /// <summary>
    /// 解析Json文件
    /// </summary>
    public void ParseItemJson()
    {
        itemList = new List <Item>();
        //文本在unity里面是TextAsset类型
        TextAsset itemText = Resources.Load <TextAsset>("Item"); //加载json文本
        string    itemJson = itemText.text;                      //得到json文本里面的内容
        //bug.Log(itemJson);
        JSONObject j = new JSONObject(itemJson);

        foreach (var temp in j.list)
        {
            //物品类型字符串转化为枚举类型
            Item.ItemType type = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["type"].str);
            //print(type);
            //下面解析的是物品的共有属性:id,name,quality。。。注:temp["id"].n 的 .n,.str等是json插件的写法,用于解析
            int              id          = (int)(temp["id"].n);
            string           name        = temp["name"].str;
            Item.ItemQuality quality     = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            string           description = temp["description"].str;
            int              capacity    = (int)(temp["capacity"].n);
            int              buyPrice    = (int)(temp["buyPrice"].n);
            int              sellPrice   = (int)(temp["sellPrice"].n);
            string           sprite      = temp["sprite"].str;
            Item             item        = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = (int)(temp["hp"].n);
                int mp = (int)(temp["mp"].n);
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                int strength  = (int)(temp["strength"].n);
                int intellect = (int)(temp["intellect"].n);
                int agility   = (int)(temp["agility"].n);
                int stamina   = (int)(temp["stamina"].n);
                Equipment.EquipmentType equiType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equiType);
                break;

            case Item.ItemType.Weapon:
                int damage = (int)(temp["damage"].n);
                Weapon.WeaponType weaponType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, weaponType);
                break;

            case Item.ItemType.Material:
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);//把解析到的物品信息加入物品列表里面
            Debug.Log(item);
        }
    }
Пример #22
0
    /// <summary>
    /// 解析JSON
    /// </summary>
    private void ParseItemsJSON()
    {
        itemList = new List <Item>();
        TextAsset  ta = Resources.Load <TextAsset>("items");
        JSONObject j  = new JSONObject(ta.text);

        foreach (JSONObject temp in j.list)
        {
            string        itemType = temp["type"].str;
            Item.ItemType type     = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), itemType);
            int           id       = (int)temp["id"].n; //公用物品解析
            string        name     = temp["name"].str;
            //string Quality = temp["quality"].str;
            Item.ItemQuality quality =
                (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            string description = temp["description"].str;
            int    capacity    = (int)(temp["capacity"].n);
            int    buyPrice    = (int)(temp["buyPrice"].n);
            int    sellPrice   = (int)(temp["sellPrice"].n);
            string sprite      = temp["sprite"].str;

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = (int)temp["hp"].n;
                int mp = (int)temp["mp"].n;
                item = new Consumable
                           (id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                int strength  = (int)temp["strength"].n;
                int intellect = (int)temp["intellect"].n;
                int agility   = (int)temp["agility"].n;
                int stamina   = (int)temp["stamina"].n;
                Equipment.EquipmentType equipType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment
                           (id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equipType);
                break;

            case Item.ItemType.Weapon:
                int damage = (int)temp["damage"].n;
                Weapon.WeaponType weaponType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, weaponType);
                break;

            case Item.ItemType.Material:
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
            //Debug.Log(item);
        }
    }
Пример #23
0
    /// <summary>
    /// 解析物品Json
    /// </summary>
    public void ParseItemJson()
    {
        TextAsset textAsset = Resources.Load <TextAsset>("Items");
        string    itemsJson = textAsset.text;

        //List<Item> itemList = JsonConvert.DeserializeObject<List<Item>>(itemsJson);
        JSONObject j = new JSONObject(itemsJson);

        foreach (JSONObject temp in j.list)
        {
            int              id          = (int)temp["id"].n;
            string           name        = temp["name"].str;
            string           description = temp["description"].str;
            int              capacity    = (int)temp["capacity"].n;
            int              buyPrice    = (int)temp["buyPrice"].n;
            int              sellPrice   = (int)temp["sellPrice"].n;
            string           sprite      = temp["sprite"].str;
            Item.ItemQuality quality     = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str);
            Item.ItemType    type        = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["type"].str);

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = (int)temp["hp"].n;
                int mp = (int)temp["mp"].n;
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                int strength     = (int)temp["strength"].n;
                int intelligence = (int)temp["intelligence"].n;
                int agility      = (int)temp["agility"].n;
                int stamina      = (int)temp["stamina"].n;
                Equipment.EquipmentType equipType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, strength, intelligence, agility, stamina, equipType, sprite);
                break;

            case Item.ItemType.Weapon:
                int damage = (int)temp["damage"].n;
                Weapon.WeaponType weaponType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str);
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, weaponType);
                break;

            case Item.ItemType.Material:
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;

            default:
                break;
            }

            itemList.Add(item);
        }
    }
Пример #24
0
 // Token: 0x0600002E RID: 46 RVA: 0x00002AAB File Offset: 0x00000CAB
 public static void ChangeGrip(Character character, Weapon.WeaponType toMoveset)
 {
     if (character != null)
     {
         Animator animator = character.Animator;
         if (animator != null)
         {
             animator.SetInteger("WeaponType", (int)toMoveset);
         }
     }
 }
Пример #25
0
 public void RemoveWeapon(Weapon.WeaponType t)
 {
     // Remove in descending order in case of more than one occurrence.
     for (int weaponIndex = Weapons.Count - 1; weaponIndex >= 0; weaponIndex--)
     {
         if (Weapons [weaponIndex].Type == t)
         {
             Weapons.RemoveAt(weaponIndex);
         }
     }
 }
Пример #26
0
 //special LevelUp function for weapon types
 public void LevelUp(Attribute attrib, Weapon.WeaponType newWeapon)
 {
     if (Attribute.WeaponType == attrib)
     {
         CURRENT_WEAPON = newWeapon;
         weapon.UpdateWeapon();
     }
     else
     {
         return;
     }
 }
Пример #27
0
 public void ShipDestroyed(Enemy e)
 {
     if (Random.value <= e.powerUpDropChance)
     {
         int ndx = Random.Range(0, powerUpFrequency.Length);
         Weapon.WeaponType puType = powerUpFrequency[ndx];
         GameObject        go     = Instantiate(prefabPowerUp) as GameObject;
         PowerUp           pu     = go.GetComponent <PowerUp>();
         pu.SetType(puType);
         pu.transform.position = e.transform.position;
     }
 }
Пример #28
0
    /// <summary>
    /// 解析物品信息
    /// </summary>
    private void ParseItemJson()
    {
        //文本在Unity里是TextAsset类型
        itemText = Resources.Load <TextAsset>("ItemJson");
        //string itemContent = itemText.ToString();
        string itemContent = itemText.text;

        JsonData json = JsonMapper.ToObject(itemContent);

        //下面的是解析这个对象里面的共有属性
        for (int i = 0; i < json.Count; i++)
        {
            int              id          = int.Parse(json[i]["id"].ToString());
            string           name        = json[i]["name"].ToString();
            Item.ItemType    type        = (Item.ItemType)Enum.Parse(typeof(Item.ItemType), json[i]["type"].ToString());
            Item.ItemQuality quality     = (Item.ItemQuality)Enum.Parse(typeof(Item.ItemQuality), json[i]["quality"].ToString());
            string           description = json[i]["description"].ToString();
            int              capacity    = int.Parse(json[i]["capacity"].ToString());
            int              buyPrice    = int.Parse(json[i]["buyPrice"].ToString());
            int              sellPrice   = int.Parse(json[i]["sellPrice"].ToString());
            string           sprite      = json[i]["sprite"].ToString();

            Item item = null;
            switch (type)
            {
            case Item.ItemType.Consumable:
                int hp = int.Parse(json[i]["hp"].ToString());
                int mp = int.Parse(json[i]["mp"].ToString());
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case Item.ItemType.Equipment:
                int strength  = int.Parse(json[i]["strength"].ToString());
                int intellect = int.Parse(json[i]["intellect"].ToString());
                int agility   = int.Parse(json[i]["agility"].ToString());
                int stamina   = int.Parse(json[i]["stamina"].ToString());
                Equipment.EquipmentType equipType = (Equipment.EquipmentType)Enum.Parse(typeof(Equipment.EquipmentType), json[i]["equipType"].ToString());
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equipType);
                break;

            case Item.ItemType.Weapon:
                int damage = int.Parse(json[i]["damage"].ToString());
                Weapon.WeaponType wpType = (Weapon.WeaponType)Enum.Parse(typeof(Weapon.WeaponType), json[i]["weaponType"].ToString());
                item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, wpType);
                break;

            case Item.ItemType.Material:
                item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
        }
    }
Пример #29
0
 public void PickUpWeapon(Weapon.WeaponType weaponType, int ammo)
 {
     foreach (Weapon w in Weapons)
     {
         if (w.weaponType == weaponType)
         {
             w.ammo += ammo;
             break;
         }
     }
     UpdateWeaponUI();
 }
Пример #30
0
    public void Choice(Weapon.WeaponType type)
    {
        weaponSword.SetActive(false); weaponBow.SetActive(false); weaponMagic.SetActive(false);
        switch (type)
        {
        case Weapon.WeaponType.Sword: weaponSword.SetActive(true); break;

        case Weapon.WeaponType.Bow: weaponBow.SetActive(true); break;

        case Weapon.WeaponType.Magic: weaponMagic.SetActive(true); break;
        }
    }
Пример #31
0
        private static float GetTimePerAttack(Weapon.WeaponType type, float speed, bool useAxeSpecial, float colliderRadius = 0.4f)
        {
            if (speed == 0f)
            {
                return(999f);
            }

            Dictionary <Weapon.WeaponType, float[]> dict;

            if (useAxeSpecial && (type == Weapon.WeaponType.Axe_1H || type == Weapon.WeaponType.Axe_2H))
            {
                dict = SpecialSpeeds;
            }
            else
            {
                dict = NormalSpeeds;
            }

            if (!dict.ContainsKey(type))
            {
                return(999f);
            }

            float hitstop = (((colliderRadius - 0.4f) / 0.1f * 37) + 175) * 0.001f;

            if (speed > 1.2f)
            {
                // get 1.0x speed and auto-calculate from value
                var baseSpeed = dict[type][2];
                return(hitstop + (baseSpeed * (float)(1 / (decimal)speed)));
            }
            else if (speed > 1.1f)
            {
                return(hitstop + dict[type][4]);
            }
            else if (speed > 1.0f)
            {
                return(hitstop + dict[type][3]);
            }
            else if (speed > 0.9f)
            {
                return(hitstop + dict[type][2]);
            }
            else if (speed > 0.8f)
            {
                return(hitstop + dict[type][1]);
            }
            else
            {
                return(hitstop + dict[type][0]);
            }
        }
Пример #32
0
        public static void Prefix(WeaponDamage __instance, ref AttackSkill ___m_attackSkill, out List <Weapon.WeaponType> __state)
        {
            __state = null;
            AttackSkill attackSkill = ___m_attackSkill;
            Weapon      weapon;

            if (attackSkill == null)
            {
                weapon = null;
            }
            else
            {
                Character ownerCharacter = attackSkill.OwnerCharacter;
                weapon = ((ownerCharacter != null) ? ownerCharacter.CurrentWeapon : null);
            }
            Weapon weapon2 = weapon;
            bool   flag    = weapon2 != null;

            if (flag)
            {
                Weapon.WeaponType valueOrDefault = (Weapon.WeaponType) 0;
                bool flag2;
                if (___m_attackSkill.RequiredWeaponTypes != null)
                {
                    Weapon.WeaponType?bastardType = BehaviourManager.GetBastardType(weapon2.Type);
                    if (bastardType != null)
                    {
                        valueOrDefault = bastardType.GetValueOrDefault();
                        flag2          = true;
                    }
                    else
                    {
                        flag2 = false;
                    }
                }
                else
                {
                    flag2 = false;
                }
                bool flag3 = flag2;
                if (flag3)
                {
                    bool flag4 = ___m_attackSkill.RequiredWeaponTypes.Contains(valueOrDefault) && !___m_attackSkill.RequiredWeaponTypes.Contains(weapon2.Type) && BehaviourManager.IsBastardMode(weapon2);
                    if (flag4)
                    {
                        __state = ___m_attackSkill.RequiredWeaponTypes;
                        ___m_attackSkill.RequiredWeaponTypes = new List <Weapon.WeaponType>(__state);
                        ___m_attackSkill.RequiredWeaponTypes.Add(weapon2.Type);
                    }
                }
            }
        }
Пример #33
0
    public void ReadData()
    {
        //read play attribute from xml

        //for test
        _weapon_origin            = Weapon.WeaponType.gun;
        _maxHealth_origin         = 100f;
        _defence_origin           = 1f;
        _moveSpeed_origin         = 0.12f;
        _jumpForce_origin         = 750f;
        _collectionTime_origin    = 2f;
        _invicibleTimeRate_origin = 1f;
    }
Пример #34
0
    public void SetType(Weapon.WeaponType wt)
    {
        //Grab the WeaponDefinition from Main
        Weapon.WeaponDefinition def = Main.GetWeaponDefinition (wt);

        //Set the color of the CUbe child
        cube.GetComponent<Renderer> ().material.color = def.color;

        letter.color = def.color; //We could colorize the letter too

        letter.text = def.letter; //Set the letter that is shown

        type = wt; //Finally actually set the type
    }
	public DamageMessage (float dmg, Vector3 dir, float dmgFrce, Weapon.DamageBias bs, Weapon.WeaponType tp, GameObject own)
	{
		damage = dmg;
		damageDirection = dir;
		damageForce = dmgFrce;
		bias = bs;
		type = tp;
		owner = own;
		try
		{
			viewID = own.GetComponent<PhotonView>().viewID;
		}
		catch
		{
			Debug.Log(owner.name  + " does not have a photon View ID");
		}
	}
Пример #36
0
 public Projectile(Game game, Vector2 spawn, float angle, int velocity, int dmg, Weapon.WeaponType type)
     : base(game)
 {
     location = spawn;
     //            origin = new Point((int)Mouse.SLocation.X, (int)Mouse.SLocation.Y);
     tempVelocity = velocity;
     wepType = type;
     this.velocity = new Vector2((float)(tempVelocity * Math.Cos(angle)), (float)(tempVelocity * Math.Sin(angle)));
     damage = dmg;
     rotation = angle;
     MouseState ms = Microsoft.Xna.Framework.Input.Mouse.GetState();
     this.location = spawn;
     if (wepType == Weapon.WeaponType.CATNIP)
     {
         this.location = Mouse.SLocation+ new Vector2(ms.X-400, ms.Y-300) + new Vector2(-30, -30);
         Map.sModList.Add(this);
         this.range = 150;
     }
     else
         Map.sProjList.Add(this);
     length = 10;
     trajLength = 60;
 }
Пример #37
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyState = Keyboard.GetState();
            MouseState ms = Microsoft.Xna.Framework.Input.Mouse.GetState();
            // if keys are pressed, update the character positions.
            if (ms.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released)
            {
                weapon.FireWeapon(this.location, this.rotation);
            }
            if (keyState.GetPressedKeys().Length > 0)
            {
                // if >0 move down
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.S) && location.Y < 1800)
                {
                    this.location.Y += (int)velocity.Y;
                }
                // if <1800 move up
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.W) && location.Y > 0)
                {
                    this.location.Y -= (int)velocity.Y;
                }
                // if >0 move right
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D) && location.X < 2400)
                {
                    this.location.X += (int)velocity.X;
                }
                // if <2400 move leftx
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A) && location.X > 0)
                {
                    this.location.X -= (int)velocity.X;
                }

                if (Microsoft.Xna.Framework.Input.Mouse.GetState().ScrollWheelValue < wheel)
                {
                    if ((int)weapon.CurrentWeapon == 0)
                        weapon.SetWeapon(Weapon.WeaponType.CATNIP);
                    else weapon.SetWeapon(weapon.CurrentWeapon - 1);
                    //wep = weapon.CurrentWeapon;
                    wheel = Microsoft.Xna.Framework.Input.Mouse.GetState().ScrollWheelValue;
                }
                if (Microsoft.Xna.Framework.Input.Mouse.GetState().ScrollWheelValue > wheel)
                {
                    if ((int)weapon.CurrentWeapon == 3)
                        weapon.SetWeapon(0);
                    else weapon.SetWeapon(weapon.CurrentWeapon + 1);
                    //wep = weapon.CurrentWeapon;
                    wheel = Microsoft.Xna.Framework.Input.Mouse.GetState().ScrollWheelValue;
                }
                if (Microsoft.Xna.Framework.Input.Mouse.GetState().RightButton.Equals(ButtonState.Pressed))
                {
                    wep = weapon.CurrentWeapon;
                    weapon.SetWeapon(Weapon.WeaponType.CATNIP);
                    weapon.FireWeapon(this.location, this.rotation);
                    weapon.SetWeapon(wep);
                }
                else if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D4) && oldKS.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.D4))
                {
                    weapon.SetWeapon(Weapon.WeaponType.CATNIP);
                }
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D1) && oldKS.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.D1))
                {
                    weapon.SetWeapon(Weapon.WeaponType.BASIC);

                }
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D2) && oldKS.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.D2))
                {
                    weapon.SetWeapon(Weapon.WeaponType.SHOTGUN);
                }
                if (keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D3) && oldKS.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.D3))
                {
                    weapon.SetWeapon(Weapon.WeaponType.GUIDED);
                }

            }
            oldState = ms;
            oldKS = keyState;
            sLocation = location;

            MouseState tmp = Microsoft.Xna.Framework.Input.Mouse.GetState();
            float tmpF = (float)Math.Atan2(300-tmp.Y, 400-tmp.X);
            if (tmpF!=rotation)
            {
                this.rotation = tmpF;
                //this.drawingLocation.X = (float)((drawingLocation.X) * Math.Cos(rotation) - (drawingLocation.Y) * Math.Sin(rotation));
                //this.drawingLocation.Y = (float)((drawingLocation.Y) * Math.Cos(rotation) + (drawingLocation.X) * Math.Sin(rotation));
            }

            // IF MOUSE ENCOUNTERS A CATNIP PICKUP (put this wherever collisions are being done)
            // Delete the pickup object
            // weapon.CurrentWeapon = 3;

            base.Update(gameTime);
        }