Example #1
0
        /// <summary>
        /// Sends states of nearby enemies to each other
        /// </summary>
        public void PushNearbyEntities(ServerEntity entity)
        {
            foreach (ServerEntity e in m_entities.Values)
            {
                if (e.AuthState != EntityAuthState.Authorised || e.WorldID == entity.WorldID)
                {
                    //Skip unauthorised entities and don't send to self
                    continue;
                }

                float xDiff = entity.LastState.X - e.LastState.X;
                float yDiff = entity.LastState.Y - e.LastState.Y;

                float sqrdistance = (xDiff * xDiff) + (yDiff * yDiff);

                if (sqrdistance < 768 * 768)
                {
                    //Add a push state into the coalesced data packet for this entity
                    PushState state = PacketFactory.CreatePacket <PushState>();
                    state.WorldID = e.WorldID;
                    state.State   = e.LastState;

                    entity.DeferredSendPacket(state);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Incoming packets are pushed here for handling.
        /// </summary>
        protected unsafe override void HandlePacket(IPacketBase packet)
        {
            base.HandlePacket(packet);

            //Update state from the client
            if (packet is PushState)
            {
                PushState state = (PushState)packet;
                //Push their state if it's the correct world ID
                if (state.WorldID == WorldID)
                {
                    LastState = state.State;
                }
            }

            //Move the user in to a new zone
            else if (packet is RequestZoneTransfer)
            {
                RequestZoneTransfer request = (RequestZoneTransfer)packet;

                m_world.ZoneManager.RequestZoneTransfer(this, request.ZoneID);
            }

            //Resolve names
            else if (packet is WhoisRequest)
            {
                WhoisRequest  request  = (WhoisRequest)packet;
                WhoisResponse response = PacketFactory.CreatePacket <WhoisResponse>();
                response.WorldID = request.WorldID;
                string name = m_world.GetNameForWorldID(request.WorldID);
                TextHelpers.StringToBuffer(name, response.Name, name.Length);
                DeferredSendPacket(response);
            }
        }
Example #3
0
    void Start()
    {
        if (!GlobalEvents.GetCondition("pushll") && !forceOn)
        {
            this.enabled = false;
        }

        rb     = GetComponent <Rigidbody2D>();
        metals = TransformsFromGameObjects(GameObject.FindGameObjectsWithTag("Metal"));
        if (metals.Length == 0)
        {
            GetComponent <PushPull>().enabled = false;
        }
        CreateNearLine();
        CreateCurrLine();
        currAction = None;
    }
Example #4
0
    private void ChengeState()
    {
        if (PushState.Init == pushState)
        {
            pushState = PushState.Uninit;
        }
        else
        {
            pushState = PushState.Init;
        }

        if (PushMoveState.Stop == pushMoveState)
        {
            pushMoveState = PushMoveState.Move;
        }
        else
        {
            pushMoveState = PushMoveState.Stop;
        }
        switch (ColliderDirection)
        {
        case ColDirection.Front:
            ColliderDirection = ColDirection.Back;
            break;

        case ColDirection.Back:
            ColliderDirection = ColDirection.Front;
            break;

        case ColDirection.Left:
            ColliderDirection = ColDirection.Right;
            break;

        case ColDirection.Right:
            ColliderDirection = ColDirection.Left;
            break;

        default:
            Debug.LogError("ColDirectionがMax");
            break;
        }
    }
Example #5
0
        private void PrivatePush( List<System.IO.FileInfo> files, string destPath )
        {
            this.TotalItems = files.Count;
            if ( this.TotalItems == 0 ) {
                this.DialogResult = DialogResult.Cancel;
            }
            foreach ( var fi in files ) {
                this.TotalSize += fi.Length;
            }
            SpeedTest ( );
            SetItemsRemainingStatus ( this.TotalItems.ToString ( ) );
            SetCopyInfoLabel ( );
            SetTitle ( );
            DroidExplorer.Core.Threading.ThreadPool pool = new DroidExplorer.Core.Threading.ThreadPool ( 1 );

            foreach ( var fi in files ) {
                PushState ps = new PushState ( );
                string remotePath = System.IO.Path.Combine ( destPath, fi.Name );
                ps.File = fi;
                ps.RemotePath = remotePath;

                pool.Queue<PushState> ( delegate ( object o ) {
                    PushState pushState = (PushState)o;
                    try {
                        CommandRunner.Instance.PushFile ( pushState.File.FullName, pushState.RemotePath );
                        if ( this.InvokeRequired ) {
                            this.Invoke ( new SetFromStatusLabelDelegate ( this.SetFromStatus ), new object[] { Environment.MachineName, ps.File.Name,
                            CommandRunner.Instance.DefaultDevice, ps.RemotePath } );
                            this.Invoke ( new SetLabelStatusDelegate ( this.SetItemsRemainingStatus ), new object[] { ( --this.TotalItems ).ToString ( ) } );
                        } else {
                            SetFromStatus ( Environment.MachineName, ps.File.Name, CommandRunner.Instance.DefaultDevice, ps.RemotePath );
                            SetItemsRemainingStatus ( ( --this.TotalItems ).ToString ( ) );
                        }
                    } catch ( Exception ex ) {
                        this.LogError ( ex.Message, ex );
                        TransferException = ex;
                        this.DialogResult = DialogResult.Abort;
                        this.OnTransferError ( EventArgs.Empty );
                    }

                    if ( this.TotalItems == 0 ) {
                        if ( this.InvokeRequired ) {
                            this.Invoke ( new GenericDelegate ( this.Close ) );
                        } else {
                            this.Close ( );
                        }
                        this.DialogResult = DialogResult.OK;
                        this.OnTransferComplete ( EventArgs.Empty );
                    }
                }, ps );
            }

            SetFromStatus ( Environment.MachineName, files[0].Name, CommandRunner.Instance.DefaultDevice, System.IO.Path.Combine ( destPath, files[0].Name ) );

            pool.Start ( );
        }