//更新角色属性显示
    private void UpdatePropertyText()
    {
        int strength = 0, intellect = 0, agility = 0, stamina = 0, damage = 0;

        foreach (_EquipmentSlot slot in slotArray) //遍历角色面板中的装备物品槽
        {
            if (slot.transform.childCount > 0)     //找到有物品的物品槽,获取里面装备的属性值
            {
                _Item item = slot.transform.GetChild(0).GetComponent <_ItemUI>().Item;
                if (item is _Equipment)//如果物品是装备,那就加角色对应的属性
                {
                    _Equipment e = (_Equipment)item;
                    strength  += e.Strength;
                    intellect += e.Intellect;
                    agility   += e.Agility;
                    stamina   += e.Stamina;
                }
                else if (item is _Weapon)///如果物品是武器,那就加角色的伤害(damage)属性
                {
                    _Weapon w = (_Weapon)item;
                    damage += w.Damage;
                }
            }
        }
        strength  += player.BasicStrength;
        intellect += player.BasicIntellect;
        agility   += player.BasicAgility;
        stamina   += player.BasicStamina;
        damage    += player.BasicDamage;
        string text = string.Format("力量:{0}\n智力:{1}\n敏捷:{2}\n体力:{3}\n攻击力:{4}\n", strength, intellect, agility, stamina, damage);

        characterPropertyText.text = text;
    }
示例#2
0
 public TurnAction(GameObject active_Ship, GameObject target_Ship, _Weapon a_Weapon)
 {
     c_Ship   = active_Ship;
     t_Ship   = target_Ship;
     c_Wep    = a_Weapon;
     c_Action = action_Type.Weapon;
 }
示例#3
0
文件: Weapon.cs 项目: MRCulpo/RPGCore
 public void addWeapon(Weapon _weapon)
 {
     this.element = _weapon.element;
     this.typeWeapon = _weapon.typeWeapon;
     this.damage += _weapon.damage;
     this.attributes += _weapon.attributes;
     //this.damage.addDamage(_weapon.damage);
     //this.attributes.addAttributes(_weapon.attributes);
 }
示例#4
0
 public void addWeapon(Weapon _weapon)
 {
     this.element     = _weapon.element;
     this.typeWeapon  = _weapon.typeWeapon;
     this.damage     += _weapon.damage;
     this.attributes += _weapon.attributes;
     //this.damage.addDamage(_weapon.damage);
     //this.attributes.addAttributes(_weapon.attributes);
 }
    void b_Enemy_Turn()
    {
        Debug.Log("Enemy Turn");
        foreach (GameObject eShip in E_Ship_Array)
        {
            //This is where the enemy turns are decided uninteliggently(not predictable)
            //Set a random int to define a random weapon to use in this turn
            if (eShip != null)
            {
                Debug.Log("we made it");
                int acc = 0;
                for (int i = 0; i < eShip.GetComponent <publicShip>().ShipClass.s_Weapons.Length; i++)
                {
                    ;
                    if (eShip.GetComponent <publicShip>().ShipClass.s_Weapons[i] == null)
                    {
                        acc = i - 1;
                        break;
                    }
                }
                int rw = UnityEngine.Random.Range(0, acc);
                //set the random weapon
                _Weapon en_Wep = eShip.GetComponent <publicShip>().ShipClass.s_Get_Weapon(rw);
                //Produce random number to pick a player ship to attack
                for (int i = 0; i < P_Ship_Array.Length; i++)
                {
                    if (P_Ship_Array[i] == null)
                    {
                        acc = i - 1;
                        break;
                    }
                }

                int rs = UnityEngine.Random.Range(0, acc);
                //add a turn to the turn holder to manipulate
                TurnAction nturn = GameObject.Find("TurnHolder").AddComponent <TurnAction>();
                //set the values in the new turn
                nturn.c_Ship   = eShip;
                nturn.t_Ship   = P_Ship_Array[rs];
                nturn.c_Wep    = en_Wep;
                nturn.c_Action = TurnAction.action_Type.Weapon;
                Debug.Log(nturn);
                //loop through the turn array. find the first null slot and add it in.
                for (int i = 0; i < Turns.Length; i++)
                {
                    Debug.Log(Turns[i]);
                    if (Turns[i] == null)
                    {
                        Turns[i] = nturn;
                        break;
                    }
                }
            }
        }
    }
    /// <summary>
    /// 解析Json文件
    /// </summary>
    public void ParseItemJson()
    {
        itemList = new List <_Item>();
        //文本在unity里面是TextAsset类型
        TextAsset itemText = Resources.Load <TextAsset>("_ItemJS"); //加载json文本

        string itemJson = itemText.text;                            //得到json文本里面的内容
        //Debug.Log(itemJson);
        JsonData data = JsonMapper.ToObject(itemJson);

        for (int i = 0; i < data.Count; i++)
        {
            int               id          = (int)data[i]["id"];
            string            name        = (string)data[i]["name"];
            _Item.ItemType    type        = (_Item.ItemType)System.Enum.Parse(typeof(_Item.ItemType), (string)data[i]["type"]);
            _Item.ItemQuality quality     = (_Item.ItemQuality)System.Enum.Parse(typeof(_Item.ItemQuality), (string)data[i]["quality"]);
            string            description = (string)data[i]["description"];
            int               capacity    = (int)data[i]["capacity"];
            int               buyPrice    = (int)data[i]["buyPrice"];
            int               sellPrice   = (int)data[i]["sellPrice"];
            string            sprite      = (string)data[i]["sprite"];
            _Item             item        = null;
            switch (type)
            {
            case _Item.ItemType.Consumable:
                int hp = (int)data[i]["hp"];
                int mp = (int)data[i]["mp"];
                item = new _Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case _Item.ItemType.Equipment:
                int strength  = (int)data[i]["strength"];
                int intellect = (int)data[i]["intellect"];
                int agility   = (int)data[i]["agility"];
                int stamina   = (int)data[i]["stamina"];
                _Equipment.EquipmentType equipType = (_Equipment.EquipmentType)System.Enum.Parse(typeof(_Equipment.EquipmentType), (string)data[i]["equipType"]);
                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)data[i]["damage"];
                _Weapon.WeaponType weaponType = (_Weapon.WeaponType)System.Enum.Parse(typeof(_Weapon.WeaponType), (string)data[i]["weaponType"]);
                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);
    }
示例#7
0
文件: Weapon.cs 项目: MRCulpo/RPGCore
        public void removeWeapon(Weapon _weapon)
        {
            this.element = _Element.Null;
            this.typeWeapon = _Weapon.Null;

            this.damage -= _weapon.damage;
            this.attributes -= _weapon.attributes;

            /*
            this.damage.removeDamage(_weapon.damage);
            this.attributes.removeAttributes(_weapon.attributes);*/
        }
示例#8
0
        public void removeWeapon(Weapon _weapon)
        {
            this.element    = _Element.Null;
            this.typeWeapon = _Weapon.Null;

            this.damage     -= _weapon.damage;
            this.attributes -= _weapon.attributes;

            /*
             * this.damage.removeDamage(_weapon.damage);
             * this.attributes.removeAttributes(_weapon.attributes);*/
        }
示例#9
0
文件: Weapon.cs 项目: MRCulpo/RPGCore
        public Weapon(Weapon _weapon)
        {
            this.id = _weapon.id;
            this.amount = _weapon.amount;
            this.image = _weapon.image;
            this.name = _weapon.name;
            this.typeItem = _weapon.typeItem;

            this.element = _weapon.element;
            this.typeWeapon = _weapon.typeWeapon;
            this.damage = new Damage(_weapon.damage);
            this.attributes = new Attributes(_weapon.attributes);
        }
示例#10
0
文件: Weapon.cs 项目: MRCulpo/RPGCore
        public Weapon()
        {
            this.id = 0;
            this.amount = 0;
            this.image = "";
            this.name = "";
            this.typeItem = _Item.Null;

            this.element = _Element.Null;
            this.typeWeapon = _Weapon.Null;
            this.damage = new Damage();
            this.attributes = new Attributes();
        }
示例#11
0
        public Weapon(Weapon _weapon)
        {
            this.id       = _weapon.id;
            this.amount   = _weapon.amount;
            this.image    = _weapon.image;
            this.name     = _weapon.name;
            this.typeItem = _weapon.typeItem;

            this.element    = _weapon.element;
            this.typeWeapon = _weapon.typeWeapon;
            this.damage     = new Damage(_weapon.damage);
            this.attributes = new Attributes(_weapon.attributes);
        }
示例#12
0
        public Weapon()
        {
            this.id       = 0;
            this.amount   = 0;
            this.image    = "";
            this.name     = "";
            this.typeItem = _Item.Null;

            this.element    = _Element.Null;
            this.typeWeapon = _Weapon.Null;
            this.damage     = new Damage();
            this.attributes = new Attributes();
        }
示例#13
0
    /// <summary>
    // deterministic start.
    /// <summary>
    public void StartMain(int inputint)
    {
        started      = true;
        i            = inputint;
        startcount   = 0;
        customran    = TSRandom.New(transform.parent.GetComponent <PhotonView>().viewID + inputint);
        parentscript = transform.parent.GetComponent <_Ship>();
        if (guntypemain == guntype.EngineUpgrade)
        {
            parentscript.MaxSpeed = parentscript.MaxSpeed * 1.15f;
        }
        if (guntypemain == guntype.HPUpgrade)
        {
            parentscript.Armor = Mathf.RoundToInt(parentscript.Armor * 1.15f);
        }
        if (guntypemain == guntype.WeaponUpgrade)
        {
            foreach (Transform gun in transform.parent)
            {
                if (gun.tag == "Pickup")
                {
                    _Weapon gunwep = gun.GetComponent <_Weapon>();
                    gunwep.timebetweenshots = gunwep.timebetweenshots * 1.15;
                }
            }
        }
        if (guntypemain == guntype.Cloak)
        {
            parentscript.iscloacked = true;
        }
        if (guntypemain == guntype.Tracker)
        {
            parentscript.isTracker = true;
        }
        unittargetcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>();
        poolmanager       = GameObject.Find("F3dPoolManager").GetComponent <F3DPoolManager>();
        team = parentscript.ShipColor;
        if (verticalmovechild == null && transform.childCount > 0 && transform.GetChild(0).childCount > 0)
        {
            verticalmovechild = transform.GetChild(0).GetChild(0).gameObject;
        }
        _Ship parent = transform.parent.GetComponent <_Ship>();

        if (Cannon_Projectile != null)
        {
            parent.Cannon_Projectile = Cannon_Projectile;
        }
        if (Missile_Projectile != null)
        {
            parent.Missile_Projectile = Missile_Projectile;
        }
        if (MiniGun_Projectile != null)
        {
            parent.MiniGun_Projectile = MiniGun_Projectile;
        }
        if (Lazer_Proectile != null)
        {
            parent.Lazer_Shot = Lazer_Proectile;
        }
        parent.shieldmaterial = shieldmatgam;
        damage      = Calculate_damage();
        audiosource = GetComponent <AudioSource>();
        WorldBase   = GameObject.Find("WorldScaleBase");
        timepassed  = 0;
    }