示例#1
0
    private static TextRef GetSpecificDetails(Loot l)
    {
        if (l.GetType() == typeof(Loot.Melee))
        {
            Loot.Melee m = (Loot.Melee)l;
            return(TextRef.Create("d: " + TextRef.ToSI(m.damage) + ", r:" + TextRef.ToSI(m.range),
                                  "Damage: " + TextRef.ToSI(m.damage) + "\nRange: " + TextRef.ToSI(m.range), false));
        }
        else if (l.GetType() == typeof(Loot.Ranged))
        {
            Loot.Ranged r = (Loot.Ranged)l;
            return(TextRef.Create("d: " + TextRef.ToSI(r.damage) + ", r:" + TextRef.ToSI(r.range),
                                  "Damage: " + TextRef.ToSI(r.damage) + "\nRange: " + TextRef.ToSI(r.range), false));
        }
        else if (l.GetType() == typeof(Loot.Shield))
        {
            Loot.Shield s = (Loot.Shield)l;
            return(TextRef.Create("p: " + s.blockChancePassive.ToString("#0%") + ", a:" + s.blockChanceActive.ToString("#0%"),
                                  "Passive block chance: " + s.blockChancePassive.ToString("#0%") + "\nActive block chance: " + s.blockChanceActive.ToString("#0%"), false));
        }
        else if (l.GetType() == typeof(Loot.Armor))
        {
            Loot.Armor a = (Loot.Armor)l;
            return(TextRef.Create("b: " + a.blockChance.ToString("#0%"), "Block chance: " + a.blockChance.ToString("#0%"), false));
        }


        else
        {
            throw new Exception("This switsh statement did not acount for: " + l.GetType().ToString());
        }
    }
示例#2
0
    // Update is called once per frame
    void Update () {
        if (weapon != pl.equipment.rHand.item)
        {
            weapon = pl.equipment.rHand.item;
            isMelee = weapon is Loot.Melee;
            if (isMelee)
            {
                Loot.Melee melee = weapon as Loot.Melee;
                slashGraphic.transform.localScale = new Vector3(melee.range, melee.range, 1);
                bowGraphic.SetActive(false);
            }
            else if(weapon != null)
            {
                bowGraphic.SetActive(true);
            }
        }
        if(shield != pl.equipment.lHand.item)
        {
            shield = pl.equipment.lHand.item as Loot.Shield;
            if (shield != null)
                shieldGraphic.SetActive(true);
            else
                shieldGraphic.SetActive(false);
        }


        if (isMelee && weapon != null)
        {
            if (Input.GetMouseButtonDown(0) && UI_Stats.windowstance == UI_Stats.WindowStance.non)
            {
                slashGraphic.SetActive(true);
                Invoke("DeactivateSlash", .2f);
                MusicPlayer.PlaySlash();
            }
        }else if (weapon != null) // Ranged
        {
            if (Input.GetMouseButtonDown(0) && UI_Stats.windowstance == UI_Stats.WindowStance.non)
            {
                GameObject newArrow = GameObject.Instantiate(arrowPrefab, transform.position, transform.rotation);
                ArrowScript arSc = newArrow.GetComponent<ArrowScript>();
                arSc.ws = this;
                arSc.speed = (weapon as Loot.Ranged).range / 1;
                arSc.damage = (weapon as Loot.Ranged).damage;
                MusicPlayer.PlayShot();
            }
        }

        if(shield != null)
        {
            if (Input.GetMouseButton(1))
                shieldGraphic.transform.localRotation = Quaternion.Euler(0, 0, 0);
            else
                shieldGraphic.transform.localRotation = Quaternion.Euler(0, 0, 35);
        }
    }