Exemplo n.º 1
0
    public void Equip(GameObject obj)
    {
        if (modules_game_object == null)
        {
            modules_game_object = GameObject.Find("Modules");
        }
        ModuleSystemInfo module_info = obj.GetComponent <ModuleSystemInfo>();
        ItemResorce      ir          = obj.GetComponent <ItemResorce>();
        SpaceShipMovment controls    = gameObject.GetComponent <SpaceShipMovment>();

        obj.transform.parent = modules_game_object.transform;

        if (ir.Item_type == Enums.enum_item.module_command_module_type1)
        {
            command_module = obj.GetComponent <ShipModule>(); //First we need to store the item
            command_module.LoadMountPoints();
            MountPoint mp = command_module.mount_points[0];   //Set the max storage
            command_module.ShowMountPoints();
            max_storage_items = module_info.max_storage_items;
            mp.max_mounting   = max_storage_items;
        }
        else
        {
            MountPoint mp = command_module.mount_points[module_info.mount_point];
            obj.transform.position   = mp.transform.position;
            obj.transform.rotation   = mp.transform.rotation;
            module_info.mount_point  = mp.index;
            module_info.key_mappings = mp.key_mappings;
            module_info.SetRenderOrder(mp.render_order);
        }

        foreach (KeyMappingModel e in module_info.key_mappings)
        {
            controls.AddKeyBinding(e, obj);
        }

        module_info.IteminUse(module_info.is_internal_module);
    }