Пример #1
0
 public bool tryWear(Actor owner, Actor item)
 {
     Components.Pickables.Wearable wearable = (Components.Pickables.Wearable)item.getComponent(typeof(Components.Pickables.Wearable));
     if (wearable != null)
     {
         return(wearable.wear(owner));
     }
     else
     {
         return(false);
     }
 }
Пример #2
0
        public bool moveOrAttack(Actor owner, int targetx, int targety)
        {
            if (Program.engine.map.isWall(targetx, targety))
            {
                if (dig)
                {
                    if (targetx < Program.engine.map.width - 1 && targety < Program.engine.map.height - 1 && targetx > 1 && targety > 1)
                    {
                        Program.engine.map.dig(targetx, targety, targetx, targety);
                        Program.engine.map.updateFov = true;
                    }
                    else if (!noclip)
                    {
                        return(false);
                    }
                }
                else if (!noclip)
                {
                    return(false);
                }
            }
            else if (!noclip)
            {
                dig = false;
            }
            for (int i = 0; i < Program.engine.actorHandler.actors.Count; i++)
            {
                Actor        a = Program.engine.actorHandler.actors[i];
                Destructible d = (Destructible)a.getComponent(typeof(Destructible));
                if (a.x == targetx && a.y == targety)
                {
                    if (d != null && !d.isDead() && a.blocks)
                    {
                        if (player.mainToolSlot.item != null)
                        {
                            Components.Pickables.Wearable wearable = (Components.Pickables.Wearable)player.mainToolSlot.component;
                            if (wearable != null && wearable.activeEffects.Count > 0)
                            {
                                foreach (Effect e in wearable.activeEffects)
                                {
                                    e.applyTo(a);
                                }
                            }
                        }

                        Attacker att = (Attacker)a.getComponent(typeof(Attacker));
                        att.attack(owner, a);
                        return(false);
                    }

                    if ((d != null && !d.isDead()) || a.getComponent(typeof(Components.Pickable)) != null)
                    {
                        Message.WriteLine("There's a {0} here", a.name);
                    }
                    Components.Blocks.Activatable activatable = (Blocks.Activatable)a.getComponent(typeof(Components.Blocks.Activatable));
                    if (activatable != null)
                    {
                        bool exit = activatable.activate(player);
                        if (exit)
                        {
                            return(false);
                        }
                    }
                    if (a.blocks)
                    {
                        if (autoOpen)
                        {
                            Blocks.Door door = (Blocks.Door)a.getComponent(typeof(Blocks.Door));
                            if (door != null && !door.open)
                            {
                                if (door.lockedLevel == 0)
                                {
                                    door.open = true;
                                    Program.engine.map.updateFov = true;
                                }
                                else
                                {
                                    Message.WriteLineC(TCODColor.lightGrey, "The door is locked");
                                }
                            }
                            open = false;
                        }
                        if (!noclip)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                    }
                }
            }
            // look for corpses

            player.x = targetx;
            player.y = targety;
            open     = false;
            return(true);
        }