hds.npc.doTick C# (CSharp) Method

doTick() public method

public doTick ( ) : bool
return bool
        public bool doTick()
        {
            ticksReceived++;
            // Reach the next action
            if (this.ticksReceived >= this.ticksNeeded)
            {
                int nextMoveTime = 5;
                switch (this.currentState)
                {
                    case ((int)statusList.WALKING_BACK):
                    case ((int)statusList.WALKING):
                        // stop npc
                        this.currentState = (int)statusList.STANDING;
                        this.setXPos(destination.a);
                        this.setZPos(destination.c);

                        Random rand = new Random();
                        nextMoveTime = rand.Next(10, 15);

                        this.updateAnimation((byte)npc.Animations.STAND);
                        break;

                    case ((int)statusList.STANDING_BACK):
                    case ((int)statusList.STANDING):
                        // Starts walking
                        this.currentState = (int)statusList.WALKING;
                        // ToDo: start walking NPC and recalculate
                        nextMoveTime = this.generatePathTable();
                        this.updateAnimation((byte)npc.Animations.WALK);
                        // Generate walking packet message (raw)
                        break;

                }

                this.ticksReceived = 0;
                this.ticksNeeded = nextMoveTime;
                this.updateClient = true;
            }
            else
            {
                this.updateClient = false;
            }
            return this.updateClient;
        }

Usage Example

Beispiel #1
0
        public void MoverThreadProcess()
        {
            Output.WriteLine("[WORLD SERVER]MoverThread started");

            // Moove the Mobs a little bit around
            int npcCount = WorldSocket.npcs.Count;

            lock (WorldSocket.npcs.SyncRoot)
            {
                for (int i = 0; i < npcCount; i++)
                {
                    npc thismob = (npc)WorldSocket.npcs[i];
                    // Check if Client has a view for this mob

                    if (thismob.getIsSpawned() == true)
                    {
                        thismob.doTick();
                    }
                }
            }


            // ToDo: This is the Mover Update Thread to update objects like NPCs every interval
            Thread.Sleep(1000);
        }
All Usage Examples Of hds.npc::doTick