Esempio n. 1
0
    public void Build()
    {
        var tree   = systemTree.GetTree(n => new TreeNode <Tuple <string, SystemComponent> >((Tuple <string, SystemComponent>)n));
        var system = tree.BuildForest(m => SystemLink.Pack(m.item.Item2));
        var keys   = tree.ByElements().Where(n => n.item.Item1 != "").ToDictionary(n => n.item.Item1, n => tree.GetPath(n));

        screenSlider.sharedData.Add("system", system);
        screenSlider.sharedData.Add("keys", keys);
        screenSlider.MoveTo("constructor");
    }
Esempio n. 2
0
 protected virtual SystemLink GetLink(ContainerNodeView node)
 {
     if (node is SystemComponentView)
     {
         return(SystemLink.Pack(((SystemComponentView)node).GetItem()));
     }
     else
     {
         return(SystemLink.Pack(new FakeComponent()));
     }
 }
Esempio n. 3
0
    protected override SystemLink GetLink(ContainerNodeView node)
    {
        var l = node.GetModel();

        if (l == null)
        {
            return(SystemLink.Pack(new FakeComponent()));
        }
        else
        {
            return(SystemLink.Pack(((SystemLink)l).item));
        }
    }
Esempio n. 4
0
    protected override ShipSystemModel GetModel()
    {
        Forest <SystemLink> system = new Forest <SystemLink>();
        SystemLink          power  = SystemLink.Pack(new PowerComponent(4));
        SystemLink          gun1   = SystemLink.Pack(new GunComponent(4));
        SystemLink          gun2   = SystemLink.Pack(new GunComponent(4));

        power.AddNode(gun1);
        power.AddNode(gun2);
        system.AddTree(power);
        Dictionary <int, int[]> tackles = new Dictionary <int, int[]>()
        {
            { 2, system.GetPath(power) },
            { 0, system.GetPath(gun1) },
            { 1, system.GetPath(gun2) },
        };

        return(new ShipSystemModel("666", system.BuildForest(c => new TreeNode <SystemComponent>(c.item)), new Dictionary <string, int[]>(), new HullModel("Station", tackles)));
    }
Esempio n. 5
0
    public override bool Put(ContainerItemView item)
    {
        if (GetComponent <ContainerItemView>() != null)
        {
            return(false);
        }
        if (item.labelItem == "free")
        {
            if (((ConstuctorItemView)item).placed)
            {
                return(false);
            }
        }
        else if (item.labelItem == "installed")
        {
            item.transform.position = item.GetComponent <DADItem>().start;
            item.transform.parent.GetComponent <HullBehaviour>().SetTackle(item.transform, SystemLink.Pack(new FakeComponent()));
            constructor.RemoveTackle(item.transform);
        }
        else
        {
            return(false);
        }
        var hull = transform.parent.GetComponent <HullBehaviour>();

        var c = hull.SetTackle(transform, item.GetModel <SystemLink>());

        var citem = c.gameObject.AddComponent <ContainerItemView>();

        citem.SetLabel("installed");
        citem.SetModel(item.GetModel());
        c.gameObject.AddComponent <DADItem>();
        c.gameObject.AddComponent <FreeDragBehaviour>().offset = new Vector3(2, 2, 0);

        if (!constructor.AddTackle(c.transform))
        {
            return(false);
        }

        item.Release();
        return(true);
    }
Esempio n. 6
0
    public override bool Put(ContainerItemView item)
    {
        if (item.labelItem != "installed")
        {
            return(false);
        }

        constructor.RemoveTackle(item.transform);


        item.transform.parent.GetComponent <HullBehaviour>().SetTackle(item.transform, SystemLink.Pack(new FakeComponent()));

        tree.GetNode(item.GetModel()).Remove();
        item.Release();
        return(true);
    }