Пример #1
0
    public void OnOKButtonClick()
    {
        if (int.Parse(Number.text) > 0 && int.Parse(Number.text) < 1000)
        {
            number = int.Parse(Number.text);
        }
        else
        {
            number = 1;
        }
        int price = info.FindObjectInDictionary(id).price_buy;

        if (player.Coin > price * number)
        {
            player.Coin -= (price * number);
            inventory.CreatGoods(id, number);
            IntNumber.gameObject.SetActive(false);
            Warn.gameObject.SetActive(false);
        }
        else
        {
            Warn.gameObject.SetActive(true);
        }
        Number.text = "1";
    }
Пример #2
0
    //protected override void Awake()
    //{
    //
    //}

    protected override void Start()
    {
        base.Start();
        goodsName = this.gameObject.name;
        GetMessage(this.gameObject.name);
        equipment   = GameObject.Find("Equipment").GetComponent <Equipment>();
        inventory   = GameObject.Find("Inventory");
        objectsInfo = GameObject.Find("GameSetting").GetComponent <ObjectsInfo>();
        information = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <PlayerInformation>();
        GetMessage(this.gameObject.name);
        objectInfo = objectsInfo.FindObjectInDictionary(id);
    }
Пример #3
0
    public bool Dress(int id)
    {
        ObjectInfo info = objects.FindObjectInDictionary(id);

        if (info.objectType != ObjectType.Equip)
        {
            return(false);
        }
        if (player.heroType == HeroType.magician)
        {
            if (info.aplicationType == AplicationType.Swordman)
            {
                return(false);
            }
        }
        if (player.heroType == HeroType.Swordman)
        {
            if (info.aplicationType == AplicationType.Magician)
            {
                return(false);
            }
        }//以上处理穿戴不成功情况
        //穿戴成功分两种情况:当前没有穿戴同类型装备/已经穿戴同类型装备
        if (info.dressType == DressType.Headgear)
        {
            if (Headgear.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = Headgear.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                Headgear.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(Headgear.GetComponentInChildren <MyDrag>().gameObject);
            }
        }

        if (info.dressType == DressType.Armor)
        {
            if (Armor.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = Armor.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                Armor.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(Armor.GetComponentInChildren <MyDrag>().gameObject);
            }
        }

        if (info.dressType == DressType.LeftHand)
        {
            if (LeftHand.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = LeftHand.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                LeftHand.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(LeftHand.GetComponentInChildren <MyDrag>().gameObject);
            }
        }

        if (info.dressType == DressType.RightHand)
        {
            if (RightHand.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = RightHand.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                RightHand.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(RightHand.GetComponentInChildren <MyDrag>().gameObject);
            }
        }

        if (info.dressType == DressType.Shoes)
        {
            if (Shoes.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = Shoes.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                Shoes.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(Shoes.GetComponentInChildren <MyDrag>().gameObject);
            }
        }

        if (info.dressType == DressType.Accessory)
        {
            if (Accessory.transform.childCount == 0)
            {
                AddEquip(id);
            }
            else
            {
                AddEquip(id);
                TakeOffName = Accessory.transform.GetChild(0).name;
                inventory.TakeBack(TakeOffName);
                Accessory.GetComponentInChildren <MyDrag>().UpdatePorperty_red();
                Destroy(Accessory.GetComponentInChildren <MyDrag>().gameObject);
            }
        }
        return(true);
    }