Ejemplo n.º 1
0
        protected override bool Exec()
        {
            VarRef  playerId     = PeType.GetPlayerId(mInfo, mTrigger);
            VarRef  itemIdVarRef = PeType.GetItemId(mInfo, mTrigger);
            VarRef  count        = PatheaScript.Util.GetVarRefOrValue(mInfo, "count", VarValue.EType.Int, mTrigger);
            Functor modify       = mFactory.GetFunctor(mInfo, "modify");

            List <Pathea.PeEntity> playerList = PeType.GetPlayer((int)playerId.Value);
            int itemId = (int)itemIdVarRef.Value;

            foreach (Pathea.PeEntity player in playerList)
            {
                Pathea.PlayerPackageCmpt pkg      = player.GetCmpt <Pathea.PlayerPackageCmpt>();
                ItemAsset.ItemPackage    accessor = pkg.package._playerPak;

                int itemCount = accessor.GetCount(itemId);
                modify.Set(new Variable(itemCount), count.Var);
                modify.Do();

                int newItemCount = (int)(modify.Target.Value);

                if (newItemCount == itemCount)
                {
                    continue;
                }
                else if (newItemCount > itemCount)
                {
                    int dd = newItemCount - itemCount;


                    if (!accessor.Add(itemId, dd))
                    {
                        Debug.LogError("Add item:" + itemId + " to player:" + player + " failed.");
                    }
                    else
                    {
                        Debug.Log("Add item:" + itemId + " count:" + dd + " to player:" + player + " succeed.");
                    }
                }
                else
                {
                    int dd = itemCount - newItemCount;

                    accessor.Destroy(itemId, dd);

                    Debug.Log("remove item:" + itemId + " count:" + dd + "from player:" + player + " succeed.");
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool Do()
        {
            List <Pathea.PeEntity> list = PeType.GetPlayer((int)mPlayerId.Value);

            bool ret = true;

            foreach (Pathea.PeEntity p in list)
            {
                Pathea.PlayerPackageCmpt pkg = p.GetCmpt <Pathea.PlayerPackageCmpt>();
                int hasCount = pkg.package.GetCount((int)mItemId.Value);
                if (false == mCompare.Do(hasCount, mItemCount.Value))
                {
                    ret = false;
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        void OnResponse(object sender, DraggingMgr.EventArg e)
        {
            if (item.type != OBJECT.OBJECTTYPE.ItemProto)
            {
                return;
            }
            ItemObjDragging items = e.dragable as ItemObjDragging;

            Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>();
            if (pkg == null)
            {
                return;
            }

            if (item.isAnyPrototype)
            {
                Post();
            }
            else if (item.isAnyPrototypeInCategory)
            {
                if (ItemAsset.ItemProto.Mgr.Instance == null)
                {
                    return;
                }
                ItemAsset.ItemProto proto = ItemAsset.ItemProto.Mgr.Instance.Get(items.GetItemProtoId());
                if (proto == null)
                {
                    return;
                }
                if (item.Group == proto.editorTypeId)
                {
                    Post();
                }
            }
            else if (item.isSpecificPrototype)
            {
                if (item.Id == items.GetItemProtoId())
                {
                    Post();
                }
            }
        }