コード例 #1
0
        public void Loot()
        {
            var aPileOfLoot = ParentWorld.NearbyObject(this, 1, Interactivity.Lootable);

            if (aPileOfLoot.Count > 0)
            {
                WorldObject loot = aPileOfLoot[0];
                if (loot is AttackItem weapon)
                {
                    if (Weapon != null)
                    {
                        ParentWorld.Add(Weapon);
                        Weapon.Position = Position;
                    }
                    ParentWorld.Remove(weapon);
                    Weapon = weapon;
                    Tracer1.TraceEvent($"{this} looted a weapon");
                }
                else if (loot is DefenceItem armor)
                {
                    if (Armor != null)
                    {
                        ParentWorld.Add(Armor);
                        Armor.Position = Position;
                    }
                    ParentWorld.Remove(armor);
                    Armor = armor;
                    Tracer1.TraceEvent($"{this} looted a piece of armor");
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Removes the given node from this world.
 /// </summary>
 /// <param name="node">The node to remove.</param>
 public void RemoveNode(LevelNode node)
 {
     if (ChildNodes.Contains(node))
     {
         ParentWorld.RemoveNode(node);
         ChildNodes.Remove(node);
     }
 }
コード例 #3
0
    //----------------//
    // Updating Nodes //
    //----------------//

    /// <summary>
    /// Adds a node to this path and the parent world at the given location.
    /// </summary>
    /// <param name="node">The node to add.</param>
    /// <param name="row">The row to place the node in.</param>
    /// <param name="col">The column to place the node in.</param>
    public void AddNode(LevelNode node, int row, int col)
    {
        if (!ChildNodes.Contains(node))
        {
            ParentWorld.AddNode(node, row, col);
            ChildNodes.Add(node);
        }
    }
コード例 #4
0
    /// <summary>
    /// Deletes all child nodes in this path and removes the path from the parent world.
    /// </summary>
    public void DeletePath()
    {
        // Remove all child nodes
        ClearPath();

        // Remove this path from the parent world
        ParentWorld.RemovePath(this);
        ParentWorld = null;
    }
コード例 #5
0
        private void explode(Vector2 location)
        {
            _exploded  = true;
            this.State = EntityState.ATTACKING;
            var dynms = ParentWorld.getAllEnemyEntities();

            foreach (DynamicEntity ent in dynms)
            {
                if (ent.State != EntityState.DEAD &&
                    ent.Class != EntityClass.WEAPON &&
                    MathHelper.distanceFromPointToPoint(
                        this.Location, ent.Location) < 50)
                {
                    ent.recieveAttack(ActiveWeapon.Host, ActiveWeapon);
                }
            }
        }
コード例 #6
0
ファイル: World.cs プロジェクト: gavinsoe/Unity.Frankenchase
        public void SetCompleted(bool completed, bool recursive)
        {
            if (recursive)
            {
                foreach (World world in InnerWorldsMap.Values)
                {
                    world.SetCompleted(completed, true);
                }
            }

            // keep current completed state
            bool alreadyCompleted = IsCompleted();

            WorldStorage.SetCompleted(this, completed);

            if (!alreadyCompleted && completed && (ParentWorld != null))
            {
                ParentWorld.NotifyInnerWorldFirstCompleted(this);
            }
        }
コード例 #7
0
        public void Hit()
        {
            if (Weapon == null)
            {
                return;
            }

            var cretures = ParentWorld.NearbyObject(this, Weapon.Range, Interactivity.Attackable);

            foreach (WorldObject worldObject in cretures)
            {
                if (worldObject is Creature creature)
                {
                    Tracer1.TraceEvent($"{this} attacked {creature}");
                    creature.ReceiveHit(Weapon.Damage);
                    if (!Weapon.Splash)
                    {
                        break;
                    }
                }
            }
        }
コード例 #8
0
        public void ReceiveHit(int hitpoints)
        {
            int damage = hitpoints / Armor?.Protection ?? hitpoints;

            HitPoints -= damage;
            if (HitPoints <= 0)
            {
                Interactivity = Interactivity.Removable;
                Name         += " (Dead)";

                if (Weapon != null || Armor != null)
                {
                    var loot = (WorldObject)Armor ?? Weapon;
                    loot.Position = Position;
                    ParentWorld.Add(loot);
                }


                ParentWorld.Remove(this);
                Tracer1.TraceEvent($"{this} died");
                ParentWorld = null;
            }
        }
コード例 #9
0
 public override void destroy()
 {
     ParentWorld.kill(this);
     base.destroy();
 }
コード例 #10
0
 public virtual void destroy()
 {
     ParentWorld.removeEntity(this);
 }