コード例 #1
0
ファイル: MmoActor.cs プロジェクト: azanium/PopBloop-Unity
        /// <summary>
        /// Operation Game Item Animate
        /// </summary>
        /// <param name="peer">The Mmo Peer</param>
        /// <param name="request">Operation Request</param>
        /// <param name="sendParameters">Parameters</param>
        /// <returns>Operation Response</returns>
        public OperationResponse OperationGameItemAnimate(PeerBase peer, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new GameItemAnimate(peer.Protocol, request);
            if (!operation.IsValid)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
            }

            operation.OnStart();
            Item item;
            if (string.IsNullOrEmpty(operation.ItemId))
            {
                item = this.Avatar;

                // set return values
                operation.ItemId = item.Id;
            }
            else if (this.TryGetItem(operation.ItemType.Value, operation.ItemId, out item) == false)
            {
                return operation.GetOperationResponse((int)ReturnCode.ItemNotFound, "ItemNotFound");
            }

            return this.GameItemOperationAnimate((MmoItem)item, operation, sendParameters);
        }
コード例 #2
0
ファイル: MmoActor.cs プロジェクト: azanium/PopBloop-Unity
        /// <summary>
        ///   The Game item animate operation.
        /// </summary>
        /// <param name = "item">
        ///   The mmo item.
        /// </param>
        /// <param name = "operation">
        ///   The operation.
        /// </param>
        /// <param name = "sendParameters">
        ///   The send Parameters.
        /// </param>
        /// <returns>
        ///   error code ok
        /// </returns>
        private OperationResponse GameItemOperationAnimate(MmoItem item, GameItemAnimate operation, SendParameters sendParameters)
        {
            // should always be OK
            MethodReturnValue result = this.CheckAccess(item);
            if (result)
            {
                // send event
                var eventInstance = new GameItemAnimateEvent
                {
                    ItemId = operation.ItemId,
                    GameItemId = operation.GameItemId,
                    Animation = operation.Animation,
                    AnimationAction = operation.AnimationAction,
                    AnimationSpeed = operation.AnimationSpeed,
                    AnimationWrap = operation.AnimationWrap
                };

                var eventData = new EventData((byte)EventCode.GameItemAnimate, eventInstance);
                sendParameters.ChannelId = Settings.ItemEventChannel;
                var message = new ItemEventMessage(item, eventData, sendParameters);
                item.EventChannel.Publish(message);

                // no response sent
                operation.OnComplete();
                return null;
            }

            return operation.GetOperationResponse(result);
        }