Beispiel #1
0
    public override void Load(XmlNode xnode)
    {
        type = LocalType.Get(xnode.Name);

        texture = new Texture();
        name = MyXml.GetString(xnode, "name");
        variations = MyXml.GetInt(xnode, "variations", 1);
        maxHP = MyXml.GetInt(xnode, "hp");
        damage = MyXml.GetInt(xnode, "damage");
        attack = MyXml.GetInt(xnode, "attack");
        defence = MyXml.GetInt(xnode, "defence");
        armor = MyXml.GetInt(xnode, "armor");
        movementTime = MyXml.GetFloat(xnode, "movementTime");
        attackTime = MyXml.GetFloat(xnode, "attackTime");
        isWalkable = MyXml.GetBool(xnode, "walkable");
        isFlat = MyXml.GetBool(xnode, "flat");

        if (xnode.Name == "Thing") isWalkable = true;

        string s = MyXml.GetString(xnode, "type");
        if (s != "") creatureType = CreatureType.Get(s);

        s = MyXml.GetString(xnode, "corpse");
        if (creatureType != null && (creatureType.name == "Animal" || creatureType.name == "Sentient")) s = "Blood";
        if (s != "") corpse = Get(s);

        s = MyXml.GetString(xnode, "onDeath");
        if (creatureType != null && creatureType.name == "Animal") s = "Large Chunk of Meat";
        if (s != "") onDeath = ItemShape.Get(s);

        for (xnode = xnode.FirstChild; xnode != null; xnode = xnode.NextSibling)
            abilities.Add(BigBase.Instance.abilities.Get(MyXml.GetString(xnode, "name")));
    }
Beispiel #2
0
    public LocalObject(LocalShape localShape, string _uniqueName = "", Inventory _inventory = null)
    {
        uniqueName = _uniqueName;
        shape = new ShapeComponent(localShape, this);

        if (localShape.type == LocalType.Get("Destructible") || localShape.type == LocalType.Get("Container"))
        {
            hp = new HPComponent(this);
        }
        else if (localShape.type == LocalType.Get("Creature"))
        {
            hp = new HPComponent(this);
            movement = new Movement(this);
            defence = new Defence(this);
            attack = new Attack(this);
            abilities = new Abilities(this);
            fatigue = new Fatigue(this);
            eating = new Eating(this);
        }

        if (_inventory != null)
        {
            inventory = new Inventory(6, 1, "", false, null, this);
            _inventory.CopyTo(inventory);
        }
    }
Beispiel #3
0
 public ShapeComponent(LocalShape shape, LocalObject o)
     : base(o)
 {
     data = shape;
     variation = R.Next(data.variations);
 }
Beispiel #4
0
    private void AddBridges(LocalShape shape, ZPoint.Direction d)
    {
        List<Tuple<ZPoint, ZPoint.Direction, int>> bridges = new List<Tuple<ZPoint, ZPoint.Direction, int>>();

        Func<ZPoint, ZPoint.Direction, int, bool> canAddBridge = (p, dir, l) =>
        {
            ZPoint end = p.Shift(dir, l + 1);
            ZPoint.Direction d1 = ZPoint.Previous(dir);
            ZPoint.Direction d2 = ZPoint.Next(dir);

            if (!InRange(end) || !InRange(p + d1) || !InRange(p + d2)) return false;
            if (data[p.x, p.y].tile != '_' || data[end.x, end.y].tile != '_') return false;

            for (int k = 1; k <= l; k++)
            {
                ZPoint p0 = p.Shift(dir, k);
                ZPoint p1 = p0 + d1, p2 = p0 + d2;
                LocalTile sky = LocalTile.Get("Sky");

                if (this[p0] != sky || this[p1] != sky || this[p2] != sky) return false;
            }
            return true;
        };

        for (int l = 1; l <= 10; l++)
        {
            for (int j = 0; j < Size.y; j++) for (int i = 0; i < Size.x; i++)
                {
                    ZPoint p = new ZPoint(i, j);
                    if (canAddBridge(p, d, l)) bridges.Add(new Tuple<ZPoint, ZPoint.Direction, int>(p, d, l));
                }
        }

        foreach (var t in bridges.Random(2)) for (int k = 1; k <= t.Item3; k++) Add(new LocalObject(shape), t.Item1.Shift(t.Item2, k));
    }