예제 #1
0
 void OnTurnStarting(LivingObject living)
 {
     if (this.UseMaxMoveTime)
     {
         m_maxMoveTimer.Change(m_config.MaxMoveTime, TimeSpan.FromMilliseconds(-1));
     }
 }
예제 #2
0
        public override void AddLiving(LivingObject living)
        {
            m_livings.Add(living);

            if (m_livings.Count == 1)
                Start();
        }
예제 #3
0
        public static void AddRandomArmor(LivingObject living, ArmorSlot slot)
        {
            var itemIDs = Items.GetItemInfos(ItemCategory.Armor).Where(ii => ii.ArmorInfo.Slot == slot).ToArray();
            var itemID = itemIDs[Helpers.GetRandomInt(itemIDs.Length)].ID;

            AddEquipment(living, itemID);
        }
예제 #4
0
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
                m_environment.SendTo(m_player, ObjectVisibility.Public);

            m_livingCount++;
        }
예제 #5
0
        internal static LivingObject Create(World world, LivingObjectBuilder builder)
        {
            var ob = new LivingObject(builder);

            ob.Initialize(world);
            return(ob);
        }
예제 #6
0
        static ItemObject PerformBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable<ObjectID> sourceObjects)
        {
            if (!VerifyBuildItem(builder, buildableItem, sourceObjects))
                return null;

            var obs = sourceObjects.Select(oid => builder.World.FindObject<ItemObject>(oid));

            MaterialID materialID;

            if (buildableItem.MaterialID.HasValue)
                materialID = buildableItem.MaterialID.Value;
            else
                materialID = obs.First().MaterialID;

            var skillLevel = builder.GetSkillLevel(buildableItem.SkillID);

            var itemBuilder = new ItemObjectBuilder(buildableItem.ItemID, materialID)
            {
                Quality = skillLevel,
            };
            var item = itemBuilder.Create(builder.World);

            foreach (var ob in obs)
                ob.Destruct();

            if (item.MoveTo(builder.Environment, builder.Location) == false)
                throw new Exception();

            return item;
        }
예제 #7
0
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
                Start();

            m_livingCount++;
        }
예제 #8
0
        public override void RemoveLiving(LivingObject living)
        {
            m_livingCount--;
            Debug.Assert(m_livingCount >= 0);

            if (m_livingCount == 0)
                Stop();
        }
예제 #9
0
 public static void AddBattleGear(LivingObject living)
 {
     Helpers.AddRandomWeapon(living);
     Helpers.AddRandomArmor(living, ArmorSlot.Torso);
     Helpers.AddRandomArmor(living, ArmorSlot.Head);
     Helpers.AddRandomArmor(living, ArmorSlot.Hands);
     Helpers.AddRandomArmor(living, ArmorSlot.Feet);
 }
예제 #10
0
        public override void RemoveLiving(LivingObject living)
        {
            var ok = m_livings.Remove(living);
            Debug.Assert(ok);

            if (m_livings.Count == 0)
                Stop();
        }
예제 #11
0
        public override void AddLiving(LivingObject living)
        {
            m_livings.Add(living);

            if (m_livings.Count == 1)
            {
                Start();
            }
        }
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
            {
                Start();
            }

            m_livingCount++;
        }
예제 #13
0
        public override void AddLiving(LivingObject living)
        {
            if (m_livingCount == 0)
            {
                m_environment.SendTo(m_player, ObjectVisibility.Public);
            }

            m_livingCount++;
        }
예제 #14
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
            {
                Die();
            }
        }
예제 #15
0
        void OnTurnEnded(LivingObject living)
        {
            // Cancel the timer
            if (this.UseMaxMoveTime)
            {
                m_maxMoveTimer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
            }

            // XXX There's a race. The timer could fire before the cancellation, but the timer action could be run after.
        }
예제 #16
0
        void UninitControllableVisionTracker(LivingObject living)
        {
            living.ParentChanged -= OnControllableParentChanged;

            if (living.Environment != null)
            {
                var tracker = GetVisionTrackerInternal(living.Environment);
                tracker.RemoveLiving(living);
            }
        }
        public override void RemoveLiving(LivingObject living)
        {
            m_livingCount--;
            Debug.Assert(m_livingCount >= 0);

            if (m_livingCount == 0)
            {
                Stop();
            }
        }
예제 #18
0
        void SendRemoveControllable(LivingObject living)
        {
            Debug.Assert(this.IsConnected);

            Send(new Messages.ControllablesDataMessage()
            {
                Operation     = ControllablesDataMessage.Op.Remove,
                Controllables = new ObjectID[] { living.ObjectID }
            });
        }
예제 #19
0
        public override void RemoveLiving(LivingObject living)
        {
            var ok = m_livings.Remove(living);

            Debug.Assert(ok);

            if (m_livings.Count == 0)
            {
                Stop();
            }
        }
예제 #20
0
        public static void AddGem(LivingObject living)
        {
            var world = living.World;

            var materials = Materials.GetMaterials(MaterialCategory.Gem).ToArray();
            var material = materials[Helpers.GetRandomInt(materials.Length)].ID;

            var itemBuilder = new ItemObjectBuilder(ItemID.Gem, material);
            var item = itemBuilder.Create(world);

            item.MoveToMustSucceed(living);
        }
예제 #21
0
        void EndTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("EndTurnSeq {0}", living);

            AddChange(new TurnEndChange(living));

            if (TurnEnded != null)
            {
                TurnEnded(living);
            }

            this.CurrentLivingID = ObjectID.NullObjectID;
        }
예제 #22
0
        public static void AddEquipment(LivingObject living, ItemID itemID)
        {
            var world = living.World;

            var materials = Materials.GetMaterials(MaterialCategory.Metal).ToArray();
            var material = materials[Helpers.GetRandomInt(materials.Length)].ID;

            var itemBuilder = new ItemObjectBuilder(itemID, material);
            var item = itemBuilder.Create(world);

            item.MoveTo(living);

            living.EquipItem(item);
        }
예제 #23
0
        void StartTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("StartTurnSeq {0}", living);

            this.CurrentLivingID = living.ObjectID;

            living.TurnStarted();

            AddChange(new TurnStartChange(living));

            if (TurnStarting != null)
            {
                TurnStarting(living);
            }
        }
예제 #24
0
        static bool VerifyBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable<ObjectID> sourceObjects)
        {
            return true;
            /*
            if (!Contains(builder.Location))
                return false;

            var srcArray = sourceObjects.Select(oid => this.World.FindObject<ItemObject>(oid)).ToArray();

            if (srcArray.Any(o => o == null || !this.Contains(o.Location)))
                return false;

            return buildableItem.MatchItems(srcArray);
             */
        }
예제 #25
0
        void RemoveControllable(LivingObject living)
        {
            if (this.IsConnected)
            {
                SendRemoveControllable(living);

                UninitControllableVisionTracker(living);
            }

            UninitControllable(living);

            var ok = m_controllables.Remove(living);

            Debug.Assert(ok);
        }
예제 #26
0
        static bool VerifyBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable <ObjectID> sourceObjects)
        {
            return(true);

            /*
             * if (!Contains(builder.Location))
             *      return false;
             *
             * var srcArray = sourceObjects.Select(oid => this.World.FindObject<ItemObject>(oid)).ToArray();
             *
             * if (srcArray.Any(o => o == null || !this.Contains(o.Location)))
             *      return false;
             *
             * return buildableItem.MatchItems(srcArray);
             */
        }
예제 #27
0
        void OnControllableParentChanged(LivingObject living, ContainerObject _src, ContainerObject _dst)
        {
            var src = _src as EnvironmentObject;

            if (src != null)
            {
                var tracker = GetVisionTrackerInternal(src);
                tracker.RemoveLiving(living);
            }

            var dst = _dst as EnvironmentObject;

            if (dst != null)
            {
                var tracker = GetVisionTrackerInternal(src);
                tracker.AddLiving(living);
            }
        }
예제 #28
0
        static ItemObject PerformBuildItem(LivingObject builder, BuildableItem buildableItem, IEnumerable <ObjectID> sourceObjects)
        {
            if (!VerifyBuildItem(builder, buildableItem, sourceObjects))
            {
                return(null);
            }

            var obs = sourceObjects.Select(oid => builder.World.FindObject <ItemObject>(oid));

            MaterialID materialID;

            if (buildableItem.MaterialID.HasValue)
            {
                materialID = buildableItem.MaterialID.Value;
            }
            else
            {
                materialID = obs.First().MaterialID;
            }

            var skillLevel = builder.GetSkillLevel(buildableItem.SkillID);

            var itemBuilder = new ItemObjectBuilder(buildableItem.ItemID, materialID)
            {
                Quality = skillLevel,
            };
            var item = itemBuilder.Create(builder.World);

            foreach (var ob in obs)
            {
                ob.Destruct();
            }

            item.MoveToMustSucceed(builder.Environment, builder.Location);

            return(item);
        }
예제 #29
0
 public TurnStartChange(LivingObject living)
 {
     this.Living = living;
 }
예제 #30
0
 internal void AddLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Add(living);
 }
예제 #31
0
 public ActionProgressChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #32
0
파일: Area.cs 프로젝트: tomba/dwarrowdelf
        void CreateItems(LivingObject living, int numItems)
        {
            var gemMaterials = Materials.GetMaterials(MaterialCategory.Gem).ToArray();

            for (int i = 0; i < numItems; ++i)
            {
                var material = gemMaterials[m_random.Next(gemMaterials.Length)].ID;
                var builder = new ItemObjectBuilder(ItemID.Gem, material);
                var item = builder.Create(living.World);

                item.MoveTo(living);
            }
        }
예제 #33
0
 public virtual void AddLiving(LivingObject living)
 {
 }
예제 #34
0
 public override void RemoveLiving(LivingObject living)
 {
 }
예제 #35
0
 internal void RemoveLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Remove(living);
 }
예제 #36
0
        void StartTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("StartTurnSeq {0}", living);

            this.CurrentLivingID = living.ObjectID;

            living.TurnStarted();

            AddChange(new TurnStartChange(living));

            if (TurnStarting != null)
                TurnStarting(living);
        }
예제 #37
0
        void EndTurnSequential(LivingObject living)
        {
            trace.TraceVerbose("EndTurnSeq {0}", living);

            AddChange(new TurnEndChange(living));

            if (TurnEnded != null)
                TurnEnded(living);

            this.CurrentLivingID = ObjectID.NullObjectID;
        }
예제 #38
0
 public override void SetupLivingAsControllable(LivingObject living)
 {
     living.SetAI(new DwarfAI(living));
 }
예제 #39
0
 void UninitControllable(LivingObject living)
 {
     living.Destructed -= OnControllableDestructed;
     living.Controller  = null;
 }
예제 #40
0
 public override void AddLiving(LivingObject living)
 {
 }
예제 #41
0
 internal void RemoveLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Remove(living);
 }
예제 #42
0
 public ActionDoneChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #43
0
 internal void AddLiving(LivingObject living)
 {
     VerifyAccess();
     m_livings.Add(living);
 }
예제 #44
0
 public TurnEndChange(LivingObject living)
 {
     this.Living = living;
 }
예제 #45
0
 public override void AddLiving(LivingObject living)
 {
 }
예제 #46
0
 public ActionStartedChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #47
0
 public ActionProgressChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #48
0
 public virtual void RemoveLiving(LivingObject living)
 {
 }
예제 #49
0
 public virtual void RemoveLiving(LivingObject living)
 {
 }
예제 #50
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
                Die();
        }
예제 #51
0
 public ActionDoneChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #52
0
 internal static LivingObject Create(World world, LivingObjectBuilder builder)
 {
     var ob = new LivingObject(builder);
     ob.Initialize(world);
     return ob;
 }
예제 #53
0
 public SkillChange(LivingObject ob, SkillID skillID, byte level)
     : base(ob)
 {
     this.SkillID = skillID;
     this.Level = level;
 }
예제 #54
0
 public override void RemoveLiving(LivingObject living)
 {
 }
예제 #55
0
 public TurnStartChange(LivingObject living)
 {
     this.Living = living;
 }
예제 #56
0
 public TurnEndChange(LivingObject living)
 {
     this.Living = living;
 }
예제 #57
0
 public ActionStartedChange(LivingObject ob)
     : base(ob)
 {
 }
예제 #58
0
 public static void AddRandomWeapon(LivingObject living)
 {
     var itemIDs = Items.GetItemInfos(ItemCategory.Weapon).ToArray();
     var itemID = itemIDs[Helpers.GetRandomInt(itemIDs.Length)].ID;
     AddEquipment(living, itemID);
 }
예제 #59
0
 public LivingObject Create(World world)
 {
     return(LivingObject.Create(world, this));
 }
예제 #60
0
 public virtual void AddLiving(LivingObject living)
 {
 }