Ejemplo n.º 1
0
    public static WorldEntity Get(string name, string sprite, WorldEntityType worldEntityType)
    {
        switch (worldEntityType)
        {
        case WorldEntityType.Character:
            return(Character(name, sprite));

        case WorldEntityType.Container:
            return(Container(name, sprite));

        case WorldEntityType.Weapon:
            return(Weapon(name, sprite));

        case WorldEntityType.Armour:
            return(Armour(name, sprite));

        default:
            return(new WorldEntity
            {
                name = name,
                description = "",
                position = Vector3.zero,
                spriteName = sprite,
                character = new Character(),
                equipment = new Equipment(),
                inventory = new Inventory(),
                armour = new Armour(),
                weapon = new Weapon()
            });
        }
    }
Ejemplo n.º 2
0
    public void CreateWorldEntity(string spriteName, Vector2 position, WorldEntityType worldEntityType)
    {
        if (position.x < 0 || position.y < 0 || position.x >= SIZE || position.y >= SIZE)
        {
            return;
        }

        if (FindWorldEntity(position) != null)
        {
            return;
        }

        WorldEntity we = WorldEntityFabric.Get(spriteName, spriteName, worldEntityType);

        we.position = position;
        _worldEntities.Add(we);

        EntityContainer ec = Instantiate(entityContainerPrefab);

        ec.worldEntity        = we;
        ec.transform.position = new Vector3(position.x + 0.5f, position.y + 0.5f, -1);
        _entityContainers.Add(ec);
    }