當前位置: 首頁>>代碼示例>>C#>>正文


C# realm.Entity類代碼示例

本文整理匯總了C#中wServer.realm.Entity的典型用法代碼示例。如果您正苦於以下問題:C# Entity類的具體用法?C# Entity怎麽用?C# Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Entity類屬於wServer.realm命名空間,在下文中一共展示了Entity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int index;
            if (state == null) index = -1;
            else index = (int) state;

            if (index < 0) //select
            {
                index = 0;
                for (int i = 0; i < children.Length; i++)
                {
                    children[i].Tick(host, time);
                    if (children[i].Status == CycleStatus.InProgress)
                    {
                        index = i;
                        break;
                    }
                }
            }
            else //run a cycle
            {
                children[index].Tick(host, time);
                if (children[index].Status == CycleStatus.Completed ||
                    children[index].Status == CycleStatus.NotStarted)
                    index = -1;
            }

            state = index;
        }
開發者ID:Club559,項目名稱:Travs-Domain-Server,代碼行數:29,代碼來源:Prioritize.cs

示例2: TickCore

 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     Pet pet;
     if (!isValidPet(host, out pet)) return;
     if (Pet == null) Pet = pet;
     TickCore(pet, time, ref state);
 }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:7,代碼來源:PetBehavior.cs

示例3: OnStateEntry

 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     Entity[] ens = host.GetNearestEntities(dist).ToArray();
     foreach (Entity e in ens)
         if (e.ObjectType == host.Manager.GameData.IdToObjectType[children])
             host.Owner.LeaveWorld(e);
 }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:7,代碼來源:RemoveEntity.cs

示例4: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            ProtectState s;
            if (state == null) s = ProtectState.DontKnowWhere;
            else s = (ProtectState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;

            Entity entity = host.GetNearestEntity(acquireRange, protectee);
            Vector2 vect;
            switch (s)
            {
                case ProtectState.DontKnowWhere:
                    if (entity != null)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
                case ProtectState.Protecting:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length > reprotectRange)
                    {
                        Status = CycleStatus.InProgress;
                        vect.Normalize();
                        float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                        host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
                        host.UpdateCount++;
                    }
                    else
                    {
                        Status = CycleStatus.Completed;
                        s = ProtectState.Protected;
                    }
                    break;
                case ProtectState.Protected:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    Status = CycleStatus.Completed;
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length > protectionRange)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
            }

            state = s;
        }
開發者ID:SirAnuse,項目名稱:fabiano-swagger-of-doom,代碼行數:60,代碼來源:Protect.cs

示例5: TickCore

 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     condition.Tick(host, time);
     if (condition.Result)
         foreach (var i in behaviors)
             i.Tick(host, time);
 }
開發者ID:Club559,項目名稱:Travs-Domain-Server,代碼行數:7,代碼來源:If.cs

示例6: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            var storage = (BuzzStorage) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            if (storage.RemainingTime > 0)
            {
                storage.RemainingTime -= time.thisTickTimes;
                Status = CycleStatus.NotStarted;
            }
            else
            {
                Status = CycleStatus.InProgress;
                if (storage.RemainingDistance <= 0)
                {
                    do
                    {
                        storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                    } while (storage.Direction.X == 0 && storage.Direction.Y == 0);
                    storage.Direction.Normalize();
                    storage.RemainingDistance = this.dist;
                    Status = CycleStatus.Completed;
                }
                float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                host.ValidateAndMove(host.X + storage.Direction.X*dist, host.Y + storage.Direction.Y*dist);
                host.UpdateCount++;

                storage.RemainingDistance -= dist;
            }

            state = storage;
        }
開發者ID:Club559,項目名稱:Travs-Domain-Server,代碼行數:35,代碼來源:Buzz.cs

示例7: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cooldown;
            if (state == null) cooldown = 1000;
            else cooldown = (int)state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;

            Player player = (Player)host.GetNearestEntity(distance, null);
            if (player != null)
            {
                Vector2 vect;
                vect = new Vector2(player.X - host.X, player.Y - host.Y);
                vect.Normalize();
                float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f);
                host.ValidateAndMove(host.X + (-vect.X) * dist, host.Y + (-vect.Y) * dist);
                host.UpdateCount++;

                if (cooldown <= 0)
                {
                    Status = CycleStatus.Completed;
                    cooldown = 1000;
                }
                else
                {
                    Status = CycleStatus.InProgress;
                    cooldown -= time.thisTickTimes;
                }
            }

            state = cooldown;
        }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:34,代碼來源:StayBack.cs

示例8: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            WanderStorage storage;
            if (state == null) storage = new WanderStorage();
            else storage = (WanderStorage) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            Status = CycleStatus.InProgress;
            if (storage.RemainingDistance <= 0)
            {
                storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2));
                storage.Direction.Normalize();
                storage.RemainingDistance = period.Next(Random)/1000f;
                Status = CycleStatus.Completed;
            }
            float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
            host.ValidateAndMove(host.X + storage.Direction.X*dist, host.Y + storage.Direction.Y*dist);
            host.UpdateCount++;

            storage.RemainingDistance -= dist;

            state = storage;
        }
開發者ID:Club559,項目名稱:Travs-Domain-Server,代碼行數:26,代碼來源:Wander.cs

示例9: OnStateEntry

 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     if (host.GetNearestEntity(100, 0x5e4b) != null) return;
     Entity opener = Entity.Resolve(host.Manager, "Realm Portal Opener");
     host.Owner.EnterWorld(opener);
     opener.Move(host.X, host.Y);
 }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:7,代碼來源:RealmPortalDrop.cs

示例10: OnStateEntry

 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     if ((host as Enemy).AltTextureIndex != index)
     {
         (host as Enemy).AltTextureIndex = index;
         host.UpdateCount++;
     }
 }
開發者ID:Club559,項目名稱:Travs-Domain-Server,代碼行數:8,代碼來源:SetAltTexture.cs

示例11: OnStateEntry

 protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
 {
     host.ApplyConditionEffect(new ConditionEffect
     {
         Effect = effect,
         DurationMS = -1
     });
 }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:8,代碼來源:ConditionalEffect.cs

示例12: TickCore

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            Entity entity = Entity.Resolve(host.Manager, target);

            entity.Move(host.X, host.Y);
            host.Owner.EnterWorld(entity);
            host.Owner.LeaveWorld(host);
        }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:8,代碼來源:Transform.cs

示例13: TickCore

 protected override bool TickCore(Entity host, RealmTime time, ref object state)
 {
     if (host.GetNearestEntity(dist, target) == null && host.GetNearestEntity(dist, target2) == null)
     {
         return true;
     }
     return false;
 }
開發者ID:SirAnuse,項目名稱:fabiano-swagger-of-doom,代碼行數:8,代碼來源:EntityNotExistsTransition2.cs

示例14: TickCore

 protected override void TickCore(Entity host, RealmTime time, ref object state)
 {
     if (targetState == null)
         targetState = FindState(host.Manager.Behaviors.Definitions[(ushort) children].Item1, targetStateName);
     foreach (Entity i in host.GetNearestEntities(range, children))
         if (!i.CurrentState.Is(targetState))
             i.SwitchTo(targetState);
 }
開發者ID:SirAnuse,項目名稱:fabiano-swagger-of-doom,代碼行數:8,代碼來源:Order.cs

示例15: isValidPet

 private bool isValidPet(Entity host, out Pet p)
 {
     p = null;
     if (!(host is Pet)) return false;
     var pet = (Pet)host;
     if (PlayerOwnerRequired && pet.PlayerOwner == null) return false;
     p = pet;
     return true;
 }
開發者ID:OryxAwakening,項目名稱:Fabiano_Swagger_of_Doom,代碼行數:9,代碼來源:PetBehavior.cs


注:本文中的wServer.realm.Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。